Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python requirements conflict with PyPi

I have a project that needs some DevOps TLC, so I am finally building my installation script. This will eventually be a package that will be install-able by pip locally, but may not end up in PyPI.

It has a dependency for a module called u2py. It is this package, created for U2 Database operations, not this package, for... something else. The one I want is only ever installed by a 3rd party vendor (Rocket), the one I don't want is in PyPI.

What should be the expected behavior of my package in this case? I will include a blurb about this in my readme doc, but is that sufficient?

I've thought about throwing an exception to identify when the wrong package is present, but that makes me feel weird. It seems that maybe the most pythonic thing is to NOT add this to my install script, and blindly assume import u2py results in a module I can use. If it quacks like a duck, parses DynArrays like a duck, and call()s SUBROUTINEs like a duck, then it's a duck, right? Otherwise, if there is an error the user will just go and actually read the docs.

I've looked a classifiers, but not sure if they apply here.

like image 216
Jon Avatar asked Feb 18 '20 18:02

Jon


People also ask

How do I fix pip dependency conflicts?

Unfortunately, pip makes no attempt to resolve dependency conflicts. For example, if you install two packages, package A may require a different version of a dependency than package B requires. Pip can install from either Source Distributions (sdist) or Wheel (. whl) files.

Does pip pull from PyPI?

pip is installing the packages from PyPi, yes. On the PyPi website you can find links to github where you can find the full package code, but where pip download is PyPi.

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.

When you use pip to install a package that requires one or more dependencies?

Pip relies on package authors to stipulate the dependencies for their code in order to successfully download and install the package plus all required dependencies from the Python Package Index (PyPI). But if packages are installed one at a time, it may lead to dependency conflicts.


1 Answers

Ideally there would be a way at install-time (in setup.py) to detect whether the package is being installed into a "u2 environment" or not, and could fail the installation (with an appropriate error message) if that's the case.

With this solution, you won't be able to provide built distributions (wheels) since they don't execute the setup.py file at install-time, but just publishing source distributions should be fine.

like image 116
Dustin Ingram Avatar answered Oct 18 '22 05:10

Dustin Ingram