-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
How to handle several repositories with same content? #3355
Comments
Have you already configured custom repositories? How do your current |
My idea (maybe wrong, tell me !) is that I would like to have something like:
It would generate 2 lock files: Content of both file would need to be synchronised (the same packages can be found on both servers). I did that by
I know that having 2 lock files would look like overkill, but this is the only way to reuse the existing behavior without having to rework everything. From what I see on !447, it looks like if the |
I see... Are lock files critical in your use case? I had in my mind that you wanted to be able to override the main source repository on a case-by-case basis (per user maybe). For example, say you have the following in your
then, for cases where A is not available (or the other way around), you might want to be able to do 1 of the 3 following suggestions:
|
lock files ensure the environment is fully reproductible for both users. But why not having several lock files? # user within the network:
$ POETRY_LOCK_FILENAME=poetry-serverA.lock poetry install
# user outside of the network:
$ POETRY_LOCK_FILENAME=poetry-serverB.lock poetry install Generation would be: $ POETRY_LOCK_FILENAME=poetry-serverA.lock poetry lock --no-update
$ POETRY_LOCK_FILENAME=poetry-serverB.lock poetry lock --no-update Would you accept a Pull Request? |
@gsemet I am not a maintainer. But yes, as far as I can tell pull requests are always welcome. Bonus points if they contain good documentation, tests, etc. Can it not be solved differently? For example you could decide to not distribute any |
I can work on a tool that would do that without touching poetry, indeed |
how can easilly change the "default" source from the |
@gsemet I do not think it is possible. |
ok thanks |
@gsemet you can also export your lock-file into
|
Hi. First thanks to take the time to try understand and help me dealing with this point. Really appreciate it. So, for your solution @kleschenko, that looks fine but the external user (the one that needs to use Server B) will have to do its virtualenv completely manually. Regarding #1632, yes it is similar, server A (and B) is a cache of Pipy + internal packages. So, for the moment we hardcode the Server A URL in the I prefere to work with lock files, because it ensure the two users (the over seeing server A and the other one using server B) will both end up with exactely the same virtualenv. I also work with Conan, and their approach is to generate as many lock file as environments. I think it is the hard way of dealing with lock files, but I think it is the safest (there are some hash, url, that may changes between two lockfile generated from the same environment (using the method I described earlier), even with same packages versions. For example, the
I do not think patching lock files will work. I think (that's my opinion, tell me yours) the best option would be:
I will do this behavior with a script or even a tool arround poetry for the moment. So far it works. But that would help a lot if this would be directly supported by poetry. It can even cover #1632 Other opion would be to completely hide "serverB" from the |
So, I completely restarted my approach. Main because having 2 sources in the pyproject.toml may have side effects, for some reason, for example one of the cache fetch a more recent version or maybe for another reason, we can have reference for some package on server B in At end, I wonder if having 2 lock files are really necessary. One we have the version of the package we need + its hash, it should not matter where it comes from. So I did a big "sed" in
Only drawback is that we should take care not to commit this change. |
@gsemet I think it was a design mistake for poetry to have Again it might seem not related to your actual issue, but I believe it is. It is all due to a common misconception people (me included) have/had about what the concept behind the index is and that then spread to many areas of Python package distribution. There is some good insight about this in this discussion. In short there should always be just 1 and only 1 index. There might be different URLs to access it, but it should still be the same content. Distributions should be the same, hashes should be the same, and so on. For a project to declare that its dependency A should be fetched from index A and dependency B from index B, is an anti-pattern. So from there it does not make sense to declare source repository URLs in the project configuration. It should be the user's decision to pick a server URL or another. Not all developers/users of a project might want to use the same URL to access the index (based on their location, network restrictions, etc.). Not all environments (production, staging, dev) have access to the same servers. Seen from this angle it becomes obvious that the contents of lockfiles should not contain server URLs either, hashes should be enough to ensure that the end result is conform to expectations. Then there is the case where a project mixes public and private dependencies, but that is another story... |
@gsemet Exactly! Right on point. |
I like the approach of conan actually. The repositories are not configured in the conanfile this is a separated configuration. You can have as many "remotes" as you want, but I still think a "default" one would be helpful for dummies. When a package A (with a given sha1), it queries each remotes sequentially until it finds the right file. |
For poetry, I believe the source repository URLs should be set via
Should be PyPI. Or a default one could be set globally (for the user) via I reckon that setting a source repository URL for the project (i.e. in
Yes, this is already what poetry (and pip) does as far as I know (which is good, assuming you can easily set the index URLs but that is not easy). |
this does not seem to work, if i remove the sources from
or even only one, it |
@gsemet No, it does not work. I did not mean to create confusion. I was just mentioning that in my opinion, this would be a better solution to use the repositories from |
ah, yes, I totally agree ! So I sed this switch in the toml file for the moment. It works but this is not elegant. |
May I know if this feature would be accepted in Poetry if I work on it ? My idea:
It basically replaces the behavior "if if not defined in pyproject.toml, it's pypi.org" by "if not defined in pyproject.toml, use local/global config, if not defined in config, use pypi.org" in both |
@gsemet Makes sense to me. But I am not a maintainer. I heard from one of them (@abn) that a rewrite of the configuration subsystem is on their minds. So maybe it could happen during or right after that rewrite. In any case, a good PR (with doc and test, etc.) is always welcome. But you could also start with a minimal draft PR, to get the discussion started, and this always open the possibility for you to use your own fork (not ideal obviously, but can be really helpful instead of waiting for merge into the main project). |
Closing as a specialized variant of #1632 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hello,
I have a use case I do not see supported by poetry. Tell me if I am wrong:
so far so good.
I also have another artifactory server B that I need to use a different authentication scheme, and behave like this:
if I do not use the lockfile, it can work. I would be happy if I could generate 2 lockfiles (with the same version of each package of course), and user could "choose" if he wants to fetch from A or from B. Any idea on how to do it properly?
The text was updated successfully, but these errors were encountered: