-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
84 lines (61 loc) · 1.93 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import sys
import os
import platform
import shutil
import io
import json
import tarfile
import urllib.request
from time import time
from pathlib import Path
from setuptools import setup, Extension
if platform.system() == "Darwin":
# ???
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
BUILD_WEB = False
if "BUILD_WEB" in os.environ:
BUILD_WEB = True
BUILD_NIGHTLY = False
if "BUILD_NIGHTLY" in os.environ:
BUILD_NIGHTLY = True
BASE_PATH = Path(os.getcwd())
BUILD_PATH = BASE_PATH / "build"
NOVA_PATH = BUILD_PATH / "nova-physics"
VERSION = "1.0.0"
with open("README.md") as _f:
LONG_DESCRIPTION = _f.read()
def download(nightly: bool):
""" Download the latest Nova Physics commit. """
print("Downloading latest commit...")
response = urllib.request.urlopen(
f"https://github.com/kadir014/nova-physics/archive/refs/heads/main.tar.gz"
if nightly else
f"https://github.com/kadir014/nova-physics/archive/refs/tags/{VERSION}.tar.gz"
)
data = response.read()
with tarfile.open(mode="r:gz", fileobj=io.BytesIO(data)) as tar:
name = tar.getmembers()[0].name
tar.extractall(BUILD_PATH)
os.rename(BUILD_PATH / name, BUILD_PATH / "nova-physics")
print("Downloaded and extracted commit.")
if __name__ == "__main__":
start = time()
# Remove build directory
if os.path.exists(BUILD_PATH):
shutil.rmtree(BUILD_PATH)
if os.path.exists("src"):
shutil.rmtree("src")
shutil.copytree("nova-physics-python/src", "src")
download(BUILD_NIGHTLY)
setup(
name = "nova-physics",
version = VERSION,
description = "Nova Physics Engine",
long_description=LONG_DESCRIPTION,
setup_requires=["cffi>=1.0.0"],
cffi_modules=["src/cffi_comp.py:ffibuilder"],
install_requires=["cffi>=1.0.0"],
py_modules=["nova"],
package_dir={"": "src"},
)