Skip to content

Commit

Permalink
use custom installer to properly resolve dependencies for PyPy
Browse files Browse the repository at this point in the history
  • Loading branch information
wlav committed Oct 20, 2020
1 parent 6520863 commit 18a7314
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
40 changes: 40 additions & 0 deletions installer/cppyy_monkey_patch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# monkey patch to be able to select a specific backend based on PyPy's version,
# which is not possible in the pyproject.toml file as there is currently no
# marker for it (this may change, after which this file can be removed)

from setuptools.build_meta import *
try:
# _BACKEND is the primary, __legacy__ the backwards compatible backend
from setuptools.build_meta import _BACKEND
main = _BACKEND
except (NameError, ImportError):
# fallback as the name __legacy__ is actually documented (and part of __all__)
main = __legacy__

# the following ensures proper build/installation order, after which the normal
# install through setup.py picks up their wheels from the cache (TODO: note the
# duplication here with setup.py; find a better way)
_get_requires_for_build_wheel = main.get_requires_for_build_wheel
def get_requires_for_build_wheel(*args, **kwds):
try:
import __pypy__, sys
version = sys.pypy_version_info
requirements = ['cppyy-backend<=1.11', 'cppyy-cling<=6.20.4']
if version[0] == 5:
if version[1] <= 9:
requirements = ['cppyy-backend<0.3', 'cppyy-cling<6.12']
elif version[1] <= 10:
requirements = ['cppyy-backend<0.4', 'cppyy-cling<=6.15']
elif version[0] == 6:
if version[1] <= 0:
requirements = ['cppyy-backend<1.1', 'cppyy-cling<=6.15']
elif version[0] == 7:
if version[1] <= 3 and version[2] <= 2:
requirements = ['cppyy-backend<=1.10', 'cppyy-cling<=6.18.2.3']
except ImportError:
# CPython
requirements = ['CPyCppyy==1.11.5', 'cppyy-backend==1.14.1', 'cppyy-cling==6.21.4']

return requirements + _get_requires_for_build_wheel(*args, **kwds)

main.get_requires_for_build_wheel = get_requires_for_build_wheel
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[build-system]
requires = ["CPyCppyy==1.11.5; python_implementation != 'PyPy'",
"cppyy-backend==1.14.1; python_implementation != 'PyPy'",
"cppyy-cling==6.21.4; python_implementation != 'PyPy'",
"setuptools", "wheel"]
requires = ["setuptools", "wheel"]
backend-path = ["installer"]
build-backend = "cppyy_monkey_patch:main"

0 comments on commit 18a7314

Please sign in to comment.