forked from davidcaron/pye57
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
150 lines (126 loc) · 4.48 KB
/
Copy pathsetup.py
File metadata and controls
150 lines (126 loc) · 4.48 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
import os
import platform
import shutil
import sys
from pathlib import Path
# Available at setup time due to pyproject.toml
from pybind11.setup_helpers import Pybind11Extension, build_ext
from setuptools import setup
from pathlib import Path
HERE = Path(__file__).parent
about = {}
with open(HERE / "src" / "pye57" / "__version__.py") as f:
exec(f.read(), about)
version = about["__version__"]
# Assuming HERE is already defined as Path(__file__).parent
libE57_cpp = sorted(map(str, (HERE / "libE57Format" / "src").glob("*.cpp")))
# Convert each absolute path in libE57_cpp to a relative path
libE57_cpp_relative = [str(path.relative_to(HERE)) for path in map(Path, libE57_cpp)]
print("Debugging libE57_cpp relative paths:")
for path in libE57_cpp_relative:
print(path)
libraries = []
library_dirs = []
include_dirs = [
"libE57Format/include",
"libE57Format/src",
"libE57Format/extern/CRCpp/inc",
]
package_data = []
if platform.system() == "Windows":
libraries.append("xerces-c_3")
# using conda
conda_library_dir = Path(sys.executable).parent / "Library"
if conda_library_dir.exists():
library_dirs.append(str(conda_library_dir / "lib"))
include_dirs.append(str(conda_library_dir / "include"))
# using cibuildwheel
xerces_dir = Path(os.environ["TEMP"]) / "xerces_c"
if xerces_dir.exists():
library_dirs.append(str(xerces_dir / "lib"))
include_dirs.append(str(xerces_dir / "include"))
# include xerces-c dll in the package
shutil.copy2(xerces_dir / "bin" / "xerces-c_3_2.dll", HERE / "src" / "pye57")
package_data.append("xerces-c_3_2.dll")
else:
libraries.append("xerces-c")
#mike
print("Debugging libE57_cpp paths:")
for path in libE57_cpp:
print(path)
ext_modules = [
Pybind11Extension(
"pye57.libe57",
["src/pye57/libe57_wrapper.cpp"] + libE57_cpp_relative, # Use relative paths
define_macros=[("E57_DLL", "")],
include_dirs=include_dirs,
libraries=libraries,
library_dirs=library_dirs,
language="c++",
),
]
export_header_path = HERE / "libE57Format" / "include" / "E57Export.h"
class BuildExt(build_ext):
"""A custom build extension for adding compiler-specific options."""
def build_extensions(self):
ct = self.compiler.compiler_type
opts = []
revision_id = "pye57-" + "0.0.1"
if ct == "unix":
opts.append(f'-DVERSION_INFO="{version}"')
opts.append(f'-DREVISION_ID="{revision_id}"')
opts.append("-DCRCPP_USE_CPP11")
opts.append("-DCRCPP_BRANCHLESS")
opts.append("-Wno-unused-variable")
elif ct == "msvc":
opts.append(f'/DVERSION_INFO="{version}"')
opts.append(rf'/DREVISION_ID="\"{revision_id}\""')
opts.append("/DCRCPP_USE_CPP11")
opts.append("/DCRCPP_BRANCHLESS")
opts.append("/DWINDOWS")
for ext in self.extensions:
ext.extra_compile_args = opts
export_header_path.touch()
try:
super().build_extensions()
finally:
export_header_path.unlink()
with open(HERE / "README.md") as f:
long_description = "\n" + f.read()
HERE = Path(__file__).parent
about = {}
with open(HERE / "src" / "pye57" / "__version__.py") as f:
exec(f.read(), about)
about = {'__version__': '0.0.1'}
print("About dict:", about)
setup(
name="pye57",
version = "0.0.1", # Fallback to "0.0.1" if __version__ is not found
author="David Caron",
author_email="dcaron05@gmail.com",
url="https://www.github.com/davidcaron/pye57",
description="Python .e57 files reader/writer",
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=["numpy", "pyquaternion"],
ext_modules=ext_modules,
packages=["pye57"],
package_dir={"": "src"},
include_package_data=True,
package_data={"pye57": package_data},
extras_require={"test": "pytest"},
license="MIT",
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
],
cmdclass={"build_ext": BuildExt},
zip_safe=False,
python_requires=">=3.7",
)