Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip name conflict

My project depends on some public packages and some private ones. One of these private ones has the same name as another public package on PyPi (let's call it 'conflicting'). In my setup.py file I have

install_requires = ['public_a', 'public_b', 'conflicting' ],
dependency_links = ['https:blah/blah/blah/conflicting.git#egg=conflicting']

Even though I specify the egg in my dependency links, pip still installs the public package 'conflicting'. Is there a way to prioritize private packages when there is a name conflict?

like image 261
Andrew Avatar asked May 21 '15 21:05

Andrew


People also ask

Are PIP package names case sensitive?

Packages housed within the Gitlab PyPi Registry are case-sensitive when retrieved. Using the latest stable pip ( 20.2. 2 ), this makes packages with capital letters impossible to retrieve as pip will make the name lowercase.

How do I use PIP conflict checker?

Usage. Simply run the command pipconflictchecker. If any dependency conflicts are found an output dump of all conflicts will be shown, and an exit code of 1 will be returned.

What is PIP package name?

Pip is one of the most famous and widely used package management system to install and manage software packages written in Python and found in Python Package Index (PyPI). Pip is a recursive acronym that can stand for either "Pip Installs Packages" or "Pip Installs Python".

Does PIP dependency resolution?

Pip does not provide true dependency resolution, but this can be solved by using it in conjunction with a requirements. txt file. Requirements. txt files can be used to make pip resolve dependency conflicts between different packages.


2 Answers

I know it's a bit of a hack, but this is easy and it actually works:

Add 100 to your local package's version numbers. As long as pip can find your local package via the --extra-index or --find-links options, it will compare the version numbers and take the highest available version that meets the versioning constraints specified in the setup.py of the dependent package. If your package has the higher version, it will win.

like image 159
hosford42 Avatar answered Nov 05 '22 13:11

hosford42


You can set up your own PyPi server and use it as primary source and the global one as secondary. This will prioritize your packages over the public ones.

e.g. manually: pip install --index-url=<your-pipy-server> --extra-index-url=https://pypi.python.org/simple <your package>

Of course, errors could occur if the version you are trying to install is missing on your server but available from the conflicting public package.

like image 36
haphi Avatar answered Nov 05 '22 13:11

haphi