-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
188 lines (159 loc) · 6.78 KB
/
setup.py
File metadata and controls
188 lines (159 loc) · 6.78 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#type: ignore
from setuptools import setup, Extension
from Cython.Build import cythonize
import sys, os
import platform
import multiprocessing
import numpy
cwd = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(cwd, "pmma", "build"))
def add_source(name: str):
return [
os.path.join("pmma", "core", "pyx_src", f"{name}.pyx"),
os.path.join("pmma", "core", "cpp_src", f"{name}.cpp")
]
if sys.platform.startswith("win"):
compile_args = ["/O2", "/fp:fast", "/GL", "/GF", "/GS-", "/std:c++20", "/wd4551", "/wd4251"] # disable warning 4551 & 4251 which is an issue for Cython
link_args = ["/LTCG"]
elif sys.platform.startswith("linux"):
compile_args = [
"-O3", "-ffast-math", "-funroll-loops", "-fstrict-aliasing", "-fomit-frame-pointer", "-std=c++20"
]
link_args = []
elif sys.platform == "darwin":
compile_args = [
"-O3", "-ffast-math", "-funroll-loops", "-fstrict-aliasing", "-fomit-frame-pointer", "-std=c++20"
]
link_args = [
"-framework", "Cocoa",
"-framework", "OpenGL",
"-framework", "IOKit",
"-framework", "CoreVideo",
]
arch = platform.machine()
if arch == "arm64":
compile_args.append("-arch")
compile_args.append("arm64")
link_args.append("-arch")
link_args.append("arm64")
else:
raise NotImplementedError("Unsupported platform")
shared_name = 'PMMA_Core'
def make_ext(component, extra_cpp=None, add_numpy=False, raw_depends=[]):
sources = [os.path.join("pmma", "core", "pyx_src", component)]
if extra_cpp is not None:
sources.extend(extra_cpp)
depends = []
for item in raw_depends:
depends.append(os.path.join("pmma", "core", "pyx_src", item))
lib_dirs = [os.path.join(cwd, "pmma", "lib")]
libs = [shared_name]
includes = [os.path.join(cwd, "pmma", "core", "hpp_src"), os.path.join(cwd, "pmma", "extern", "include")]
if add_numpy:
includes += [numpy.get_include()]
macros = []
if add_numpy:
macros.append(('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION'))
name = component.split(os.sep)[-1].replace(".pyx", "")
return Extension(
name=name,
sources=sources,
language="c++",
include_dirs=includes,
library_dirs=lib_dirs,
libraries=libs,
extra_compile_args=compile_args,
extra_link_args=link_args,
define_macros=macros,
depends=depends
)
ext_modules = [
make_ext("AdvancedMathematics.pyx", add_numpy=True),
make_ext("Display.pyx", add_numpy=True, raw_depends=["CoreTypes.pyx"]),
make_ext(os.path.join("Events", "KeyEvents.pyx")),
make_ext(os.path.join("Events", "KeyPadEvents.pyx")),
make_ext(os.path.join("Events", "WindowEvents.pyx")),
make_ext(os.path.join("Events", "ControllerEvents.pyx"), add_numpy=True),
make_ext(os.path.join("Events", "MouseEvents.pyx"), add_numpy=True),
make_ext("FractalBrownianMotion.pyx", add_numpy=True),
make_ext("CoreTypes.pyx", add_numpy=True),
make_ext("PerlinNoise.pyx", add_numpy=True),
make_ext("PMMA_Core.pyx", raw_depends=["General.pyx"]),
make_ext("TextRenderer.pyx", add_numpy=True),
make_ext("General.pyx", add_numpy=True),
make_ext("Shapes2D.pyx", add_numpy=True, raw_depends=["CoreTypes.pyx"]),
make_ext("Passport.pyx", raw_depends=["General.pyx", "Logger.pyx"]),
make_ext("Logger.pyx"),
make_ext("Animation.pyx", add_numpy=True, raw_depends=["CoreTypes.pyx"])
]
# Read the long description from README.md
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
# Read the requirements from requirements.txt
with open("requirements.txt", "r", encoding="utf-8") as req_file:
requirements = req_file.read().splitlines()
packages = ['pmma']
if __name__ == '__main__':
multiprocessing.freeze_support()
use_parallel = True
if '--no-parallel' in sys.argv:
use_parallel = False
sys.argv.remove('--no-parallel')
annotate_build = "--annotate_build" in sys.argv
if annotate_build:
sys.argv.remove("--annotate_build")
if use_parallel:
cython_command = cythonize(ext_modules, compiler_directives={"language_level": "3"}, annotate=annotate_build, nthreads=multiprocessing.cpu_count())
else:
cython_command = cythonize(ext_modules, compiler_directives={"language_level": "3"}, annotate=annotate_build)
setup(
name="pmma",
version="5.0.16",
author="PycraftDev",
author_email="thomasjebbo@gmail.com",
description="Python Multi-Media API (PMMA) is a multi-purpose API designed to make working on multi-media projects easier and faster!",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/PycraftDeveloper/PMMA",
project_urls={
"Bug Tracker": "https://github.com/PycraftDeveloper/PMMA/issues",
},
classifiers=[
"Development Status :: 3 - Alpha", # Becomes beta with release of PMMA 6.
"Environment :: Console",
"Environment :: Win32 (MS Windows)",
"Environment :: X11 Applications",
"Intended Audience :: Developers",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Information Technology",
"Intended Audience :: Other Audience",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: Microsoft :: Windows :: Windows 8",
"Operating System :: Microsoft :: Windows :: Windows 8.1",
"Operating System :: Microsoft :: Windows :: Windows 10",
"Operating System :: Microsoft :: Windows :: Windows 11",
"Operating System :: POSIX :: Linux",
"Programming Language :: C++",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Artistic Software",
"Topic :: Desktop Environment",
"Topic :: Games/Entertainment",
"Topic :: Multimedia", #definitely this one!
"Topic :: Scientific/Engineering :: Visualization",
"Topic :: Software Development",
"Topic :: System",
"Topic :: Utilities",
"Typing :: Stubs Only"
],
packages=packages, # Include the pmma package and all its sub-packages
python_requires=">=3.8",
install_requires=requirements,
include_package_data=True,
ext_modules=cython_command, # nthreads=multiprocessing.cpu_count()
)
# Use: `python -m trove_classifiers` to see complete list of classifiers.