-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsetup.py
49 lines (42 loc) · 1.43 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
from setuptools import setup, find_packages, sic
from setuptools_rust import Binding, RustExtension
import sys
from zipfile import ZipFile
import glob
import os
from python.cod_asset_importer import version
package = False
package_argv = "--create-release-package"
if package_argv in sys.argv:
package = True
sys.argv.remove(package_argv)
rust_extension = RustExtension(
target="cod_asset_importer.cod_asset_importer",
path="./rust/cod_asset_importer/Cargo.toml",
binding=Binding.PyO3,
py_limited_api=True,
)
version_str = ".".join(map(str, version))
setup(
name="cod-asset-importer",
version=sic(version_str),
rust_extensions=[rust_extension],
package_dir={"": "python"},
packages=find_packages(where="python"),
zip_safe=False,
)
if package:
cod_asset_importer = "cod_asset_importer"
package_name = f"{cod_asset_importer}_v{version_str}"
src = os.path.join(os.curdir, "python", cod_asset_importer)
zip_file_path = os.path.join(os.curdir, "release", f"{package_name}.zip")
with ZipFile(zip_file_path, "w") as zip_file:
for ext in ("*.py", "*.pyd"):
for file in glob.iglob(os.path.join(src, ext)):
zip_file.write(
file, os.path.join(cod_asset_importer, os.path.basename(file))
)
zip_file.write(
os.path.join(os.curdir, "LICENSE"),
os.path.join(cod_asset_importer, "LICENSE"),
)