|
| 1 | +import os |
| 2 | +import sys |
| 3 | +import subprocess |
| 4 | +from setuptools import setup, find_packages, Extension |
| 5 | + |
| 6 | +if sys.version_info[:2] == (3, 6): |
| 7 | + clinic_file = "tools/py36_clinic.py" |
| 8 | +elif sys.version_info[:2] == (3, 7): |
| 9 | + clinic_file = "tools/py37_clinic.py" |
| 10 | +else: |
| 11 | + raise ValueError("Must run on Python 3.6 or 3.7") |
| 12 | + |
| 13 | +if sys.platform != 'win32': |
| 14 | + tool_env = os.environ.copy() |
| 15 | + tool_env['PYTHONPATH'] = f'{os.getcwd()}/tools:' + tool_env.get('PYTHONPATH', '') |
| 16 | + subprocess.run([sys.executable, clinic_file, "shared_memory/posixshmem.c"], |
| 17 | + env=tool_env) |
| 18 | + |
| 19 | +posix_shm_mod = Extension( |
| 20 | + "shared_memory._posixshmem", |
| 21 | + define_macros=[ |
| 22 | + ("HAVE_SHM_OPEN", "1"), |
| 23 | + ("HAVE_SHM_UNLINK", "1"), |
| 24 | + ("HAVE_SHM_MMAN_H", 1), |
| 25 | + ], |
| 26 | + libraries=["rt"] if sys.platform == 'linux' else [], |
| 27 | + sources=["shared_memory/posixshmem.c"], |
| 28 | +) |
| 29 | + |
| 30 | +setup( |
| 31 | + name="shared_memory38", |
| 32 | + version="0.1.0", |
| 33 | + description="Backport of multiprocessing.shared_memory in Python 3.8", |
| 34 | + classifiers=[ |
| 35 | + 'Operating System :: OS Independent', |
| 36 | + 'Programming Language :: Python', |
| 37 | + 'Programming Language :: Python :: 3.6', |
| 38 | + 'Programming Language :: Python :: 3.7', |
| 39 | + 'Programming Language :: Python :: Implementation :: CPython', |
| 40 | + 'Topic :: Software Development :: Libraries', |
| 41 | + ], |
| 42 | + url="https://github.com/mars-project/shared_memory38", |
| 43 | + packages=find_packages(exclude=('*.tests.*', '*.tests')), |
| 44 | + ext_modules=[posix_shm_mod] if sys.platform != 'win32' else [], |
| 45 | +) |
0 commit comments