-
Notifications
You must be signed in to change notification settings - Fork 192
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
Frictionless Nimble directory structures #653
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
To elaborate a bit more on the requirements:
Regarding using git clone, it works for regular packages but not for repos that have multiple packages. It is possible to do a sparse git clone but then package structure will be a bit different and might need some extra work to fix the namespace or backwards compatibility. I think this is best left to a separate RFC. Additional advantages
Another item worth discussion is whether the Nim redirection to resolve imports should be temporary and deprecreted eventually. |
So I've hidden some comments that have gone off-topic, please create separate RFCs for those. You might be surprised, but I do actually love this idea. There are still some concerns that I have though: Semantics of the new Nim compiler package resolution
@Araq, you say this is for backwards compatibility, this implies that you do not want future code to use this shortcut. Are you expecting people to write I also want us to be very specific about the semantics of this, can you come up with an implementation? Even in pseudo-code would be helpful to make sure we're on the same page. Nimble's
|
I've just been going through the issues and wondered: while we're adopting this RFC could we also adopt scoped org packages? i.e. |
Re: using git clone In order for this to be useful, we will need to add functionality in Nimble to convert a regular repo clone into a fork when the user wants to contribute to an installed package. It is easy enough to fork manually and Using git for updating a package isn't useful either since in theory, you want multiple versions of a package to be retained. Another complication is how I vote for leaving git out of this RFC and dealing with that separately if even warranted. Re: opinionated package structure I'm not sure what the opinionated part is. Using I suggest leaving I agree the entire package should be copied as is though. If anything, this seems like the only part of this RFC that is really warranted. The code changes required would be to resolve imports relative to Re: package namespacing If we want to make changes to Nimble's package structure and resolution ( While I understand the benefit of two packages not conflicting, I don't know how important this is and whether it needs to be mixed into the same RFC. Re: multi-package repos
If we want the git repo retained in |
If it's harmless enough for "git clone", it's harmless enough for Nimble. Simple. |
You might very well install local Nimble packages, and then you'll get all sorts of generated files. A solution might be to just parse .gitignore files. |
@dom96 IMO nim-lang/RFCs#291 gives the missing ingredient to allow this RFC. Under this RFC, you'll have:
exampleconstantine package defines helpers/static_for.nim at top level (https://github.com/mratsim/constantine/blob/master/helpers/static_for.nim) however, it violates package namespacing (
instead, with nim-lang/RFCs#291 you'll have:
links |
@timotheecour I love it. Let's do it :) Edit: Actually, thinking about it some more. This will break packages like |
Currently Nimble is quite picky about the valid project structures, see https://github.com/nim-lang/nimble#project-structure. This is often annoying for Nimble users and even if it weren't, it's something people have to learn and remember and is hardly justified. "Namespacing" is often used as the justification but that is not necessarily Nimble's job. If package A and package B both offer
utils.nim
in their top level directories, it could still be possible to disambiguate manually likeimport A / utils
. And soon enough the package's users will demand sane names anyway.A slightly different, but more pressing problem is that Nimble only copies the .nim files from
srcDir
over to the "installation" destination. In other words, the installation environment differs from the devel environment. That is asking for trouble and even if it works, it means the users of a package do not see the example programs or the documentation because it is not "installed" at all!Nimble should simply
git clone
a package followed by agit checkout
to select the required version/commit. This would also simplify the creation of eventual pull requests that the package's user might want to do. But even if Nimble continues to download/copy the package's files without the hidden.git
directory, it should not touch the directory structure and it should not "install" only a selected set of files.So what previously was
$nimbleDir/p-1.0.0/p.nim
becomes$nimbleDir/p-1.0.0/p/src/p.nim
, for example. For backwards compat the Nim compiler can then resolve an import likeimport p
toimport p/src/p
.Advantages
cd $nimbleDir/foo && nimble docs
or any other build target works out of the box without any special logic in the project.nimble file.Disadvantages
The Nim compiler must do a bit more work to resolve imports. However, already it needs to be aware of the $nimbleDir, versions and "nimble develop" redirections. It is not a big deal to add slightly more logic on top of this mess if Nimble becomes easier to use and understand as a result.
Open Questions
How to handle git repos that contain multiple nimble packages?
The text was updated successfully, but these errors were encountered: