|
10 | 10 | else: |
11 | 11 | raise ValueError("Must run on Python 3.6 or 3.7") |
12 | 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) |
| 13 | +repo_root = os.path.dirname(os.path.abspath(__file__)) |
| 14 | + |
| 15 | +tool_env = os.environ.copy() |
| 16 | +tool_env["PYTHONPATH"] = os.path.join(repo_root, "tools") \ |
| 17 | + + ":" + tool_env.get("PYTHONPATH", "") |
| 18 | +shmem_source = "winshmem" if sys.platform == "win32" else "posixshmem" |
| 19 | +subprocess.run([sys.executable, clinic_file, f"shared_memory/{shmem_source}.c"], |
| 20 | + env=tool_env) |
18 | 21 |
|
19 | 22 | posix_shm_mod = Extension( |
20 | 23 | "shared_memory._posixshmem", |
|
26 | 29 | libraries=["rt"] if sys.platform == 'linux' else [], |
27 | 30 | sources=["shared_memory/posixshmem.c"], |
28 | 31 | ) |
| 32 | +win_shm_mod = Extension( |
| 33 | + "shared_memory._winshmem", |
| 34 | + sources=["shared_memory/winshmem.c"], |
| 35 | +) |
| 36 | + |
| 37 | +def execfile(fname, globs, locs=None): |
| 38 | + locs = locs or globs |
| 39 | + exec(compile(open(fname).read(), fname, "exec"), globs, locs) |
| 40 | + |
| 41 | +version_file_path = os.path.join(repo_root, "shared_memory", "_version.py") |
| 42 | +version_ns = {"__file__": version_file_path} |
| 43 | +execfile(version_file_path, version_ns) |
| 44 | +version = version_ns["__version__"] |
29 | 45 |
|
30 | 46 | setup( |
31 | 47 | name="shared_memory38", |
32 | | - version="0.1.0", |
| 48 | + version=version, |
| 49 | + author="Wenjun Si", |
| 50 | + |
33 | 51 | description="Backport of multiprocessing.shared_memory in Python 3.8", |
| 52 | + long_description=open(os.path.join(repo_root, "README.rst"), |
| 53 | + encoding="utf-8").read(), |
| 54 | + long_description_content_type="text/x-rst", |
34 | 55 | 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', |
| 56 | + "Operating System :: OS Independent", |
| 57 | + "Programming Language :: Python", |
| 58 | + "Programming Language :: Python :: 3.6", |
| 59 | + "Programming Language :: Python :: 3.7", |
| 60 | + "Programming Language :: Python :: Implementation :: CPython", |
| 61 | + "Topic :: Software Development :: Libraries", |
41 | 62 | ], |
42 | 63 | 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 [], |
| 64 | + packages=find_packages(exclude=("*.tests.*", "*.tests")), |
| 65 | + ext_modules=[posix_shm_mod] if sys.platform != "win32" \ |
| 66 | + else [win_shm_mod], |
45 | 67 | ) |
0 commit comments