This repository was archived by the owner on Jul 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsetup.py
More file actions
76 lines (67 loc) · 2.42 KB
/
setup.py
File metadata and controls
76 lines (67 loc) · 2.42 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
import os
import os.path
import shutil
import stat
import subprocess
from setuptools import Extension, setup
from Cython.Build import cythonize
from Cython.Compiler import Options
VERSION = "0.12.6"
# A helper for rmtree. On Windows, read-only files can't be deleted by rmtree, so we make them not readonly.
def handle_remove_readonly(func, path, exc):
os.chmod(path, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) # 0777
func(path)
extension_args = {}
Options.language_level = 3
# scikit-build isn't always present.
from skbuild import cmaker
# we can go via scikit-build to try to run CMake. This is reliable enough on Linux and Mac, but will probably
# give people trouble on Windows, thus us publishing wheels.
# Find this file:
root_dir = os.path.split(os.path.abspath(__file__))[0]
vendored_dir = os.path.join(root_dir, "synthizer-vendored")
os.chdir(root_dir)
synthizer_lib_dir = ""
if 'CI_SDIST' not in os.environ:
# Configure and build Synthizer itself.
cmake = cmaker.CMaker()
# Force Ninja on all platforms. This lets us work on Windows reliably if run
# from an MSVC shell, where reliably means fail noisily and obviously at the
# beginning if the world is insane.
cmake.configure(
cmake_source_dir=vendored_dir,
generator_name="Ninja",
clargs=[
"-DCMAKE_BUILD_TYPE=Release",
"-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded",
"-DCMAKE_POSITION_INDEPENDENT_CODE=TRUE",
"-DSYZ_INTEGRATING=ON",
],
)
cmake.make()
# what actually happens here is that Synthizer only installs one path. It is
# unfortunately the case that skbuild is making architecture specific
# directories so, instead of guessing, just grab it.
synthizer_lib_dir = os.path.split(os.path.abspath(cmake.install()[0]))[0]
extension_args = {
"include_dirs": [os.path.join(vendored_dir, "include")],
"library_dirs": [synthizer_lib_dir],
"libraries": ["synthizer"],
}
extensions = [
Extension("synthizer.synthizer", ["synthizer/synthizer.pyx"], **extension_args),
]
setup(
name="synthizer",
version=VERSION,
author="Synthizer Developers",
author_email="ahicks@ahicks.io",
url="https://synthizer.github.io",
ext_modules=cythonize(extensions, language_level=3),
zip_safe=False,
include_package_data=True,
packages=["synthizer"],
package_data={
"synthizer": ["*.pyx", "*.pxd", "*.pyi", "py.typed"],
},
)