zneak zneak - 11 months ago 99
Python Question

How do I `install_requires` a bdist package uploaded to PyPI?

I have a Python package that depends on an executable. Since the executable takes a rather long time to build, I'd like to use

bdist
to distribute it through my company's internal PyPI index. I need it on both macOS and Linux.

My
setup.py
works fine on both operating systems. After running
python setup.py bdist upload -r private-pypi
, the index has the two following packages:


  • foo-0.0.1.linux-x86_64.tar.gz

  • foo-0.0.1.macosx-10.12-intel.tar.gz



However, I'm running into issues specifying the
foo
package as an
install_requires
requirement in other projects. I have another
bar
package that needs it. I have the following requirement for it (in both
setup.py
and a
requirements.txt
file):

foo>=0.0.1,==0.*


We have several other packages and this requirement format has worked for all of them, but not this one. The error that I get is:


Could not find a version that satisfies the requirement
foo==0.*,>=0.0.1
(from
bar==1.6.12
) (from versions:
0.0.1.linux-x86_64
,
0.0.1.macosx-10.12-intel
)

No matching distribution found for
foo==0.*,>=0.0.1
(from
bar==1.6.12
)


I get this error even on the same machines that built the packages that have been uploaded to PyPI.

In this case, the
bar
package is installed with
pip install --upgrade /path/to/bar
(and
.pypirc
is configured to look at our internal PyPI index), but it's also available on the same private PyPI index. Although I haven't tried just
pip install
ing it from there, I suspect that I would get the same error.

AFAIK, this is our only package that is distributed as a
bdist
instead of an
sdist
. Source distributions don't have a platform appended to their version number (it'd be
-0.0.1.tar.gz
instead of
-0.0.1.linux-x86_64.tar.gz
), so the problem is almost certainly there.

That still leaves me at loss for a solution. I'm baffled that
bdist
made a package version that
pip
can't seem to parse.

My goal is to get this package on PyPI with the executable included, and then be able to download it with clients while still constraining the version. How should I be doing this instead?

Answer Source

Using bdist_wheel appears to have solved the problem.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download