-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
69 lines (56 loc) · 2.17 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
from setuptools import find_packages
import os
import subprocess
import sys
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
class CMakeExtension(Extension):
def __init__(self, name, sourcedir=""):
Extension.__init__(self, name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)
class CMakeBuild(build_ext):
def build_extension(self, ext):
extdir = os.path.abspath(os.path.dirname(
self.get_ext_fullpath(ext.name)))
if not extdir.endswith(os.path.sep):
extdir += os.path.sep
preset = "linux"
debug = int(os.environ.get("DEBUG", 0)
) if self.debug is None else self.debug
cfg = "Debug" if debug else "RelWithDebInfo"
cmake_args = [
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}",
f"-DPython3_ROOT_DIR={os.path.dirname(sys.executable)}",
f"-DVERSION_INFO={self.distribution.get_version()}",
"-DROLLNW_BUILD_PYTHON=ON",
"-DROLLNW_BUILD_TESTS=OFF"
]
if self.compiler.compiler_type == "msvc":
cmake_args += [
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{cfg.upper()}={extdir}"]
preset = "windows"
elif self.plat_name.startswith("macosx"):
preset = "macos"
if os.environ.get("CIBUILDWHEEL", "0") == "1":
preset = "cibuildwheel-" + preset
subprocess.check_call(["cmake", f"--preset {preset}"] + cmake_args)
subprocess.check_call(["cmake", "--build", "--preset", "default"])
setup(
name="rollnw",
version="0.45.0",
author="jmd",
author_email="[email protected]",
packages=["rollnw-stubs"],
include_package_data=True,
package_data={
"rollnw-stubs": ['__init__.pyi', 'kernel.pyi', 'model.pyi', 'nwn1.pyi', 'script.pyi']
},
description="An homage to Neverwinter Nights",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
ext_modules=[CMakeExtension("src")],
cmdclass={"build_ext": CMakeBuild},
zip_safe=False,
extras_require={"test": ["pytest>=6.0"]},
python_requires=">=3.10",
)