-
Notifications
You must be signed in to change notification settings - Fork 99
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
Enforce module naming #828
Conversation
The base implementation is completed, but I would like to discuss with the team @fortran-lang/fpm @everythingfunctional @milancurcic @certik @arteevraina @henilp105 @minhqdao before moving forward with tests and other:
Output is decently informative, but mismatches are treated as fatal errors. For example in the "New" enforced names:
Revert to old behavior:
Since this change will break most existing projects including most of the fpm examples, another option would be to allow people some time to change their packages:
|
Another thought: the current prefixing rule does not need a separator like Package If a separator was mandatory, we would instead have So in hindsight it would seem that using a separator could spare us from some of these edge cases. |
That is actually a good point. I hadn't considered that. Note that we haven't prevented a package named
I think it should be an option in the |
Yes - I think that adding the separator would exclude further potential issues, but the obvious bottleneck is Fortran requiring unique names <=63 chars; begin with a letter; case insensitive; only allowed symbol is That is far more restrictive than what name a package could have. However, if we think in terms of using registries, which have namespaces to resolve further complexity, the odds of having a project require dependencies with name collisions will be very low, which the package maintainers can still cope with by slightly changing their package names. |
A cool F77-like option would be to hash the package name to a unique 6-character identifier, but I don't think anyone would be happy to rename their packages with some random 6-character string. |
This is a very good idea. Remove CLI option? Or, |
@everythingfunctional if you agree I'll open a separate PR to start documenting the basic Fortran naming rules and the package naming conventions in the fpm documentation on the basis of the PyPI example. On the separator, I agree my original
The
|
That sounds reasonable. Go ahead. |
The new naming policy requires package modules names to: 1) Begin with the fortrannized package name 2) Either be exactly equal to it; 3) Or if longer, have a `__` separator between the package name ant the rest of the name 4) Dangling separator (`package__`) is not allowed
Ready for merge IMHO @everythingfunctional @certik @henilp105 @arteevraina @minhqdao |
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 think that looks good. I have not checked the actual checking logic if it does what we need, but I assume that we can iterate on if it is not correct.
Thank you - I think the only big decision right now is about the |
Why not enforcing the package name with one prefix by default. Then allow overriding the prefix to enforce in |
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 think this a reasonable design and looks reasonable to me.
I think I've finished the flexible prefix implementation. See more details at the docs page. Now we have two options, a more flexible and a stricter one, I think these will save us 99.9% of the headaches. This PR at toml-f shows how simple it is to enforce naming with the customized prefix rule. It paves the way to enforcing these rules by default building fpm: all custom prefixes of the dependencies are loaded from their fpm.toml and enforced during build. The latest commit also paves the way to build fpm itself with module naming enforced: I've renamed all When we're all on the same page with these updates, we can start enforcing naming here and there. Note that the registry will have to keep a list of custom prefixes, so when a user uploads a new package / wants to change it, they're granted or forbidden permission to do it. |
Hi @perazz, I haven't had a chance to look at the implementation, but the description of the rules (here) sounds pretty good. However,
This should not be necessary. The prefix rules should only be enforced for library modules (i.e. |
Following up on toml-f/toml-f#121, I would suggest that we allow a transition phase of one release in fpm for packages to adopt the new change and also to avoid breaking the build of fpm itself.
This way we can avoid deadlocking us due to TOML Fortran containing a dash in the package name. |
The current PR does not enforce names by default so it fits item 1. well imho. |
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.
Looks good to me. With three approvals I will go ahead and merge.
Draft PR to implement enforced module naming conventions, see #823