-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
99 lines (89 loc) · 2.87 KB
/
Copy pathsetup.py
File metadata and controls
99 lines (89 loc) · 2.87 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from setuptools import setup, Extension
import setuptools.command.build_ext
class BuildExt(setuptools.command.build_ext.build_ext):
def build_extension(self, *args, **kwargs):
compile_docstrings()
return super().build_extension(*args, **kwargs)
def compile_docstrings():
with open("cpp/docstrings.txt") as input, open(
"cpp/docstrings.autogen.h", "w"
) as output:
key = None
text = ""
def write():
if key:
stripped_text = "\n".join(
line.rstrip() for line in text.rstrip().split("\n")
)
output.write(f"static constexpr char const* {key} = ")
delim = "TEXT"
x = 0
while f"){ delim }" in stripped_text:
delim = f"TEXT{x}"
x += 1
output.write(f'R"{ delim }({ stripped_text }){ delim }";\n')
for line in input:
if line.startswith("<@>"):
write()
key = line[3:].strip()
text = ""
else:
text += line
write()
with open("README.rst", "r") as fh:
long_description = fh.read()
with open("pyimmutable/__version__.py", "r") as fh:
versiondict = {"__builtins__": {}}
exec(fh.read(), versiondict)
version = versiondict["version"]
setup(
name="pyimmutable",
version=version,
description="Immutable dict and lists",
long_description=long_description,
long_description_content_type="text/x-rst",
url="https://github.com/spacedentist/pyimmutable",
download_url=(
f"https://github.com/spacedentist/pyimmutable/archive/{version}.tar.gz"
),
author="Sven Over",
author_email="sp@cedenti.st",
license="MIT",
packages=["pyimmutable"],
ext_modules=[
Extension(
"_pyimmutable",
sources=[
"cpp/ImmutableDict.cpp",
"cpp/ImmutableList.cpp",
"cpp/main.cpp",
"cpp/util.cpp",
],
depends=[
"cpp/Hash.h",
"cpp/ImmutableDict.h",
"cpp/ImmutableList.h",
"cpp/PyObjectRef.h",
"cpp/util.h",
"cpp/docstrings.txt",
],
language="c++",
include_dirs=["lib/immer"],
extra_compile_args=["-std=c++17"],
extra_link_args=[
"-static-libgcc",
"-static-libstdc++",
"-Wl,--strip-all",
],
)
],
classifiers=[
"Development Status :: 3 - Alpha",
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
test_suite="pyimmutable.tests",
setup_requires=["tox"],
cmdclass={"build_ext": BuildExt},
)