Reputation: 10953
I have a package with PyPy support and for CPython users it has mypy
as an additional dependency which I specify as
import platform
from setuptools import setup
...
install_requires = [...]
if platform.python_implementation() != 'PyPy':
install_requires.append('mypy>=0.630')
setup(...,
install_requires=install_requires)
and locally it works fine, but when I create source distribution via CPython like
> python setup.py sdist
and try to install it via PyPy
> pypy3 -m pip install path/to/package.tar.gz
it tries to install mypy
(and fails since mypy
uses CPython-specific packages), so it looks like dependencies are taken for CPython version (for which distribution was created).
How can I specify dependencies and create source distribution once so it will work for both CPython & PyPy versions (and upload to PyPI afterwards)?
Upvotes: 2
Views: 609
Reputation: 148880
Your current script tests the platform at build time, and not at install time.
What you need to use is not the platform
module, but environment markers defined in PEP 508:
from setuptools import setup
...
install_requires = [...,
'mypy>=0.630; implementation_name != "PyPy"']
setup(...,
install_requires=install_requires)
References:
Upvotes: 2