pythonpip

Pip install only pure-python packages


Is there a way to configure pip to install only pure-python packages with pure-python dependencies? I'd like to be able to write a python project that is compatible with both Jython and CPython.


Solution

  • Looking through the file that implements the various command line options for pip and reading the documentation, it would appear that none of these options have the ability to exclude packages based on this criterion. --no-binary and --only-binary seem to deal with compilation in general rather than excluding packages with non-python content.

    https://github.com/pypa/pip/blob/de6e4b5c9ea942e6c961066f1ad7f5398b730dfa/pip/cmdoptions.py

    The python wheel PEP has metadata that shows what part of the package is a purelib and gets expanded into site-packages, and a Root-Is-Purelib boolean field which seems to indicate that the entire package is pure python. https://www.python.org/dev/peps/pep-0491/ It might be possible to configure pip to exclude everything but wheels and then filter the wheels based on metadata.

    The deprecated --use-wheel flag seems to cause pip to prefer wheels, but not to exclude non-wheels. There does not seem to be a way to block wheels from being installed based on their metadata.