-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
pipenv lock fails when a dependent package depends on an another package served on non-default pypi server with pipenv 2022.4.8 #5053
Comments
@ysk24ok This is because of a limitation of the way that index restrictions are implemented, that dependent packages get the default source. I realize based on your report that it worked in If you can update the order of your sources so that the private index comes first, and your use case should work, though if you are not mirroring the pypi dependencies there you may need to pin your pypi packages by name to that index. If you did not wish to pin pypi packages to that index you would need to mirror them to your private package server, as recommended by pip maintainers: “To correctly make a private project installable is to point –index-url to an index that contains both PyPI and their private projects—which is our recommended best practice.” The pipenv documentation has been updated to describe this pattern in more detail, but please report back what your experience is like trying to update to follow the given advice: https://pipenv.pypa.io/en/latest/advanced/#specifying-package-indexes Just noting that I am not familiar with the dependency_links part of the setup metdata -- perhaps that could be useful to extending the feature to know where to look for sub-dependencies, but that pipenv code can be super complicated and no guarantees it will be possible, and in the short term it likely will not be. |
Thank you for you quick response.
So this behavior I reported is expected one, not a bug?
In fact,
Does that mean we have to put packages served on the public pypi server to our internal one? Not sure if it's possible for us... I'm afraid I'm gonna deviate from the original question, but do you know how to specify an index for each dependency of a package? If something like this is possible, it should be fine. setup(
name="mypackage",
version="X.Y.Z",
install_requires=[
"myanotherpackage==A.B.C @ our internal pypi server",
"requests @ public pypi server"
],
) |
@ysk24ok I think that it may still work for the ones that depend on pypi, at least I think that was my experience in testing but I also didn't have packages that depended on other packages in my own local pypi to test with and did most of my testing using a third-party torch repository. Maybe you could try it out and let me know if that for sure doesn't work?
This wouldn't be possible from the setup.py configuration that setuptools uses because it is a layer below pip and that is a layer below pipenv. I think you would need to add both packages to your top-level Pipfile, but there are other issue reports about not being able to specify the order of dependencies being installed, but they are old reports and I don't suspect that should be an issue for the current pip resolver to at least lock. Also going to note for your case you may be interested in a feature option we are working on that would allow the installation to succeed from any of the sources based on an already locked Pipfile.lock, but the resolution of packages would still need to be possible to create the lock file for that to work, so it may not be of immediate use. This basically makes the sync step behave like before and search all indexes for packages that match that version and the allowed hashes, That PR is here: #5039 |
@ysk24ok If you find that it doesn't work to just flip the order of the indexes, you could at least add the other dependent pypi packages to your top-level Pipfile with the pinned index name for pypi, and that should definitely work to resolve everything, I believe. |
Flipping the order of indices around and specifying indices for public pypi explicitly didn't solve the problem.
It shows the following error. I guess this is because
Instead, listing all packages in our internal pypi in top-level Pipfile worked.
Ideally it would be great that |
I just ran into this today too after upgrading. I'd rather not duplicate dependencies in both This seems like a regression (I may have missed things in release notes) - any chance this could be reopened until a fix is in place? Thanks for the hard work on pipenv! note: interestingly, this does seem to work ok on 2022.3.28, even though that's when the behavior seems to have changed, as per https://pipenv.pypa.io/en/latest/advanced/#specifying-package-indexes:
|
@JacobHayes It is not a regression, but intentional to prevent package confusion attacks. I had missed part of the resolver code when the initial patch rolled out in March. The recommendation from pip is to mirror your pypi dependencies to your private package server so that you can just specify that as your default index and resolution will work the way you want it without extra specifiers. If you don't want to manage that pypi mirroring, then you would have to pin to the non-default indexes. Without further enhancements to how to know which index to search the sub-dependency for, and then actually search only that index its not currently possible and there is desire to remove --extra-index-url option from pip itself. Otherwise you end up with the possibility for the package confusion attack again. The documentation you link to was recent updated to explain these concerns and recommendations. |
@JacobHayes I just thought of something else that might be helpful or could work. Since you mention that the setup.py requires the package, which calls out the version, and you don't want to manage the version in your Pipfile ... but you could add that other requirement to the Pipfile with |
I got here from #5021 - @matteius, the docs seem to describe pretty accurately what the new behaviour is, so thanks for that! I would agree with @JacobHayes that having to maintain all those internal dependencies in the We've temporarily pinned our |
Issue description
We have a
Pipfile
like this, which installsmypackage
from our private pypi server.In
setup.py
ofmypacakge
, it depends on an another package namedmyanotherpackage
and served on the same private pypi server.We'd like to update the dependencies by running
pipenv lock
.Expected result
pipenv lock
works fine and updatesPipfile.lock
.Actual result
With pipenv 2022.4.8,
pipenv lock
shows an error like this. Note that the package names and their versions are manually edited.WIth 2022.3.28, it works fine.
Steps to replicate
Just follow the steps described above if you have an alternative pypi server.
I'm sorry but I cannot paste the result of
$ pipenv --support
here as it contains the real name of the packages.The text was updated successfully, but these errors were encountered: