-
Notifications
You must be signed in to change notification settings - Fork 108
Allow hyphens in fpm project names in "fpm new" #337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow hyphens in fpm project names in "fpm new" #337
Conversation
Forcing the directory, package, and module name to be the same and to be an allowable Fortran module name was a deliberate decision. Obviously, the module name must conform to these rules, and it was considered that the simplest solution was to enforce them all being consistent. This disallows such options as the package and directory name being UTF-8 and so on so it is defnitely restrictive. I do not know if the discussions are still available, but now that there is auto-discovery it is far less of an issue. The question I have is should there be an option to name the package and the module independently instead of making a special case where dashes are replaced with underscores? If we are going to relax the restriction I think it would be better to leave the default behavior as-is and allow for an optional parameter to name the directory and project. I do not know if UTF-8 or other characters are allowed or easily supported in all the places the name might appear, but I believe toml-f supports UTF-8. So if we allowed any arbitrary name would it cause issues with git, github, gitlab, the |
I agree that we might have to enforce some restrictions on the project name (e.g. I would consider newlines always invalid), but requiring it to be a valid Fortran identifier seems harsh. Allowing more freedom in fpm-new is very welcome from my side (in fact all my fpm packages but one are using hyphens in the project name). I like the idea to just underscorify everything we can't use in Fortran, in case we encounter problems with the names of the targets, archive, directories a similar approach could be used as well. The limitations of the programming language shouldn't be imposed on the user in my opinion. Also, cargo allows a |
Thanks @milancurcic, I too use hyphens commonly in package names and welcome this change. The proposed solution of replacing with underscores where needed seems reasonable. With that said, I think the relevant discussion that drives the current behaviour is #153 (Prevent Name Collisions Between Packages) where it was agreed that all module names should be prefixed by the package name. This check is not yet implemented in fpm; when implemented, there will be a small burden on users to ensure modules are correctly prefixed by the fortranised package name. Alternatively, the module namespace prefix could be specified in the manifest separately. |
As an aside: we should be thinking about the support for UTF-8. That is a
rather tricky topic, as it may well depend on what the compilers allow
(think of file names).
Note: My remark is not to complicate matters for fpm, just to remind us of
the topic in general.
Op wo 13 jan. 2021 om 09:53 schreef Laurence Kedward <
notifications@github.com>:
… Thanks @milancurcic <https://github.com/milancurcic>, I too use hyphens
commonly in package names and welcome this change. The proposed solution of
replacing with underscores where needed seems reasonable.
With that said, I think the relevant discussion that drives the current
behaviour is #153 <#153>
(Prevent Name Collisions Between Packages) where it was agreed that all
module names should be prefixed by the package name. This check is not yet
implemented in *fpm*; when implemented, there will be a small burden on
users to ensure modules are correctly prefixed by the fortranised package
name. Alternatively, the module namespace prefix could be specified in the
manifest separately.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#337 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN6YR7SCYPKAPV6PIIPXCDSZVNSDANCNFSM4V74FQJQ>
.
|
For UTF-8 support I will link to the upstream issue at TOML-Fortran (toml-f/toml-f#3) as this will become relevant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm much in favor of this change. We should keep the artificial constraints on our users as little as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me, thanks 👍
With this PR, I didn't mean to ignore #153, which I still think is important. But I forgot about it in the moment. When fpm checks that all module names do begin with the project name, the change in this PR will require an extra clause explaining the restriction to the user. For example:
or similar. So there is a bit of burden that is being put on the user with this. On the other side, with this PR
|
Even now nothing obvious breaks if the directory is renamed, as I have done myself several times so I would prefer a second parameter for naming the directory to a non-default value, but at least for now this is satisfactory for the specific case of a dash. I believe it is telling that other package managers appear to address this with an additional option, but apparently in the reverse order of precedence I would suggest (the name always names the directory and an alternate project name is allowed for). After trying it that might be better, as it allows for things like fpm new ANY_DIRECTORY_NAME --name PACKAGE_NAME appears to be how |
I think there would be value in a CLI parameter to specify a directory name different from the project name. I have projects like this. For example, the repo and directory are called "datetime-fortran" and "functional-fortran" (to help them stand out on GitHub), but the fpm project names (and modules) are called "datetime" and "functional" because "fortran" is redundant in the context of fpm.
No, currently only hyphen is converted to an underscore. I don't think this should expand to all special ASCII characters and definitely not all Unicode. If the restriction is lifted, it should be on a character by character basis and motivated by user requests.
This will error out because you need to start it with a letter. Thank you all for the feedback, I will go ahead and merge. |
fpm new
currently requires a package name to be a valid Fortran name.To have a hyphen in a package name is rather common though. For example, we have stdlib-cmake-example, there's toml-f and others, and I enjoy using hyphens as well.
This PR removes the restriction to use hyphens in new fpm package names in
fpm new
. The function that I used to do that (to_fortran_name()
) can be easily expanded to other special characters if a need arises.If you try this PR, you should get:
I also updated the error message that you get if you pass some other special character:
We can discuss at a later time if there are some other special characters that we'd want to allow.