Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 099bad8

Browse files
authored
Reference Windows API in C (#2)
1 parent 2e84634 commit 099bad8

File tree

11 files changed

+369
-152
lines changed

11 files changed

+369
-152
lines changed

MAINFEST.in

Lines changed: 0 additions & 2 deletions
This file was deleted.

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include shared_memory/posixshmem.c shared_memory/winshmem.c
2+
global-exclude clinic
3+
include tools/*

README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Backport of ``multiprocessing.shared_memory`` for Python 3.6 and 3.7. Simply import all things from ``shared_memory`` to make your code work.
2+
3+
Note that ``multiprocessing.managers.SharedMemoryManager`` is also included under ``shared_memory`` package.

setup.py

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
else:
1111
raise ValueError("Must run on Python 3.6 or 3.7")
1212

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)
1821

1922
posix_shm_mod = Extension(
2023
"shared_memory._posixshmem",
@@ -26,20 +29,39 @@
2629
libraries=["rt"] if sys.platform == 'linux' else [],
2730
sources=["shared_memory/posixshmem.c"],
2831
)
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__"]
2945

3046
setup(
3147
name="shared_memory38",
32-
version="0.1.0",
48+
version=version,
49+
author="Wenjun Si",
50+
author_email="swj0066@gmail.com",
3351
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",
3455
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",
4162
],
4263
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],
4567
)

shared_memory/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
except ImportError:
55
pass
66

7-
__version__ = '0.1.0'
7+
from ._version import __version__

shared_memory/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '0.1.1'

shared_memory/_winshmem.py

Lines changed: 0 additions & 132 deletions
This file was deleted.

0 commit comments

Comments
 (0)