-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
34 lines (29 loc) · 1.3 KB
/
Copy pathsetup.py
File metadata and controls
34 lines (29 loc) · 1.3 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
"""Build the native library into the wheel; no Python headers are needed."""
import os
import subprocess
import sys
from pathlib import Path
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
class CMakeBuild(build_ext):
def build_extension(self, ext):
if not sys.platform.startswith("linux"):
raise RuntimeError("PointZip currently supports Linux x86_64/aarch64.")
source = Path(__file__).resolve().parent
output = Path(self.get_ext_fullpath(ext.name)).resolve()
build = Path(self.build_temp).resolve() / ext.name
build.mkdir(parents=True, exist_ok=True)
output.parent.mkdir(parents=True, exist_ok=True)
subprocess.check_call([
"cmake", "-S", str(source), "-B", str(build),
"-DCMAKE_BUILD_TYPE=Release",
"-DCMAKE_MAKE_PROGRAM=make", "-G", "Unix Makefiles",
f"-DPOINTZIP_PYTHON_OUTPUT_DIR={output.parent}",
f"-DPOINTZIP_PYTHON_OUTPUT_NAME={output.name}",
])
subprocess.check_call([
"cmake", "--build", str(build), "--target", "pointzip", "--parallel",
os.environ.get("CMAKE_BUILD_PARALLEL_LEVEL", "4"),
])
setup(ext_modules=[Extension("pointzip._native", sources=[])],
cmdclass={"build_ext": CMakeBuild})