forked from mars-project/shared_memory38
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
70 lines (63 loc) · 2.41 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import os
import sys
import subprocess
from setuptools import setup, find_packages, Extension
if sys.version_info[:2] == (3, 6):
clinic_file = "tools/py36_clinic.py"
elif sys.version_info[:2] == (3, 7):
clinic_file = "tools/py37_clinic.py"
else:
raise ValueError("Must run on Python 3.6 or 3.7")
repo_root = os.path.dirname(os.path.abspath(__file__))
tool_env = os.environ.copy()
tool_env["PYTHONPATH"] = os.path.join(repo_root, "tools") \
+ ":" + tool_env.get("PYTHONPATH", "")
shmem_source = "winshmem" if sys.platform == "win32" else "posixshmem"
subprocess.run([sys.executable, clinic_file, f"shared_memory/{shmem_source}.c"],
env=tool_env)
posix_shm_mod = Extension(
"shared_memory._posixshmem",
define_macros=[
("HAVE_SHM_OPEN", "1"),
("HAVE_SHM_UNLINK", "1"),
("HAVE_SHM_MMAN_H", "1"),
],
libraries=["rt"] if sys.platform == 'linux' else [],
sources=["shared_memory/posixshmem.c"],
extra_compile_args=["-Wno-implicit-function-declaration"],
)
win_shm_mod = Extension(
"shared_memory._winshmem",
sources=["shared_memory/winshmem.c"],
)
def execfile(fname, globs, locs=None):
locs = locs or globs
exec(compile(open(fname).read(), fname, "exec"), globs, locs)
version_file_path = os.path.join(repo_root, "shared_memory", "_version.py")
version_ns = {"__file__": version_file_path}
execfile(version_file_path, version_ns)
version = version_ns["__version__"]
setup(
name="shared_memory38",
version=version,
author="Wenjun Si",
author_email="swj0066@gmail.com",
description="Backport of multiprocessing.shared_memory in Python 3.8",
long_description=open(os.path.join(repo_root, "README.rst"),
encoding="utf-8").read(),
long_description_content_type="text/x-rst",
license="PSF license",
classifiers=[
"License :: OSI Approved :: Python Software Foundation License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Software Development :: Libraries",
],
url="https://github.com/mars-project/shared_memory38",
packages=find_packages(exclude=("*.tests.*", "*.tests")),
ext_modules=[posix_shm_mod] if sys.platform != "win32" \
else [win_shm_mod],
)