-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
186 lines (160 loc) · 5.85 KB
/
setup.py
File metadata and controls
186 lines (160 loc) · 5.85 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
# pylint: disable=wrong-import-position,missing-module-docstring,missing-function-docstring,missing-class-docstring,invalid-name
import os
import platform
import shutil
import sys
from pathlib import Path
from setuptools import find_packages, setup
from setuptools.dist import Distribution
sys.path.insert(0, os.path.dirname(__file__))
from setuputils import build_dependencies, build_packages, relink_and_delocate
here = Path(__file__).parent.resolve()
class BinaryDistribution(Distribution):
def has_ext_modules(self):
return True
if __name__ == "__main__":
license_files_paths = list((here / "licenses").glob("*"))
license_files = [
license_file_path.relative_to(here).as_posix()
for license_file_path in license_files_paths
]
print("including license files:")
for license_file in license_files:
print(license_file)
oiio_static = os.getenv("OIIO_STATIC")
static_build = str(oiio_static) == "1"
print("=" * 80)
if static_build:
license_files.append("LICENSE-GPL")
print("Building static libraries.")
else:
license_files.append("LICENSE")
print("Building shared libraries.")
print("=" * 80)
if "bdist_wheel" in sys.argv:
# When running on Cibuildwheel, avoid rebuilding dependencies for each version.
if os.getenv("CIBUILDWHEEL") != "1":
build_dependencies()
# Build OpenColorIO and OpenImageIO
build_packages(static_build)
# Fix shared libraries on macos
if platform.system() == "Darwin":
relink_and_delocate()
# Include tools if using shared libraries version
if static_build:
# Cleanup tools directories if needed
tool_dirs = [
here / "oiio_python" / "OpenImageIO" / "tools",
here / "oiio_python" / "PyOpenColorIO" / "tools",
]
for tool_dir in tool_dirs:
if tool_dir.exists():
shutil.rmtree(tool_dir)
package_data = {
"OpenImageIO": ["*.*", "licenses/*.*"],
"PyOpenColorIO": ["*.*", "licenses/*.*"],
}
else:
tools_dir = [
here / "oiio_python" / "OpenImageIO" / "tools",
here / "oiio_python" / "PyOpenColorIO" / "tools",
]
package_data = {
"OpenImageIO": ["*.*", "tools/*", "licenses/*.*"],
"PyOpenColorIO": ["*.*", "tools/*", "licenses/*.*"],
}
include_data = True
zip_safe = False
# Define scripts based on the build type
scripts_list = []
if not static_build:
oiio_tools = ["iconvert", "idiff", "igrep", "iinfo", "maketx", "oiiotool"]
ocio_tools = [
"ocioarchive",
"ociobakelut",
"ociocheck",
"ociochecklut",
"ocioconvert",
"ociolutimage",
"ociomakeclf",
"ocioperf",
"ociowrite",
]
scripts = dict()
for tool in oiio_tools:
scripts[tool] = f"OpenImageIO._tool_wrapper:{tool}"
for tool in ocio_tools:
scripts[tool] = f"PyOpenColorIO._tool_wrapper:{tool}"
for script_name, script_path in scripts.items():
scripts_list.append(f"{script_name}={script_path}")
else:
scripts_list = []
package_data = {}
scripts = {}
include_data = False
zip_safe = True
license_files += ["LICENSE-GPL", "LICENSE"]
package_name = "oiio-static-python" if static_build else "oiio-python"
long_description = (here / "README.md").read_text(encoding="utf8")
# Use SPDX license expression instead of deprecated classifiers
if static_build:
license_expr = "Apache-2.0 OR GPL-3.0-only"
else:
license_expr = "Apache-2.0"
setup(
name=package_name,
version="3.0.10.0.1",
license=license_expr,
license_files=tuple(license_files),
package_dir={"": "oiio_python"},
packages=find_packages(where="oiio_python"),
package_data=package_data,
include_package_data=include_data,
ext_modules=[],
distclass=BinaryDistribution,
entry_points={
"console_scripts": scripts_list,
},
zip_safe=zip_safe, # Required for including DLLs and PYDs in wheel
description="Unofficial OpenImageIO Python wheels, including OpenColorIO",
long_description=long_description,
long_description_content_type="text/markdown",
author="Paul Parneix",
url="https://github.com/pypoulp/oiio-python",
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: C++",
"Programming Language :: Python :: Implementation :: CPython",
],
python_requires=">=3.8,<3.14",
install_requires=[
"numpy>=1.21.2,<2.3.0",
],
extras_require={
"dev": [
"twine",
"black==24.2.0",
"isort==5.13.2",
],
},
keywords=[
"OpenImageIO",
"OpenColorIO",
"image",
"processing",
"oiio",
"ocio",
"python",
"wrapper",
"binding",
"library",
],
)