-
-
Notifications
You must be signed in to change notification settings - Fork 124
/
setup.py
70 lines (59 loc) · 1.88 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
from typing import List
from setuptools import setup, find_packages
from Cython.Build import cythonize
import os
import glob
import shutil
import sys
import numpy
try:
import versioneer
except ImportError:
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
import versioneer
# there were issues with other builds carrying over their cache
for d in glob.glob("*.egg-info"):
shutil.rmtree(d)
def load_requirements(path: str) -> List[str]:
requirements = []
with open(path) as f:
for line in f.readlines():
line = line.strip()
if line.startswith("git+") or line.startswith("https:"):
continue
elif line.startswith("-r "):
requirements += load_requirements(line[3:])
else:
requirements.append(line)
return requirements
required_packages = load_requirements("./requirements.txt")
try:
# try and freeze the requirements if already installed
from pip._internal.operations import freeze
first_party = {
"amulet-core",
"amulet-nbt",
"pymctranslate",
"minecraft-resource-pack",
}
installed = {r.split("==")[0].lower(): r for r in freeze.freeze() if "==" in r}
for index, r in enumerate(required_packages):
if r[0] != "#" and "~=" in r:
req = r.split("~=")[0]
if req in first_party and req in installed:
required_packages[index] = installed[req]
except:
pass
if next(glob.iglob("amulet_map_editor/**/*.pyx", recursive=True), None):
# This throws an error if it does not match any files
ext = cythonize("amulet_map_editor/**/*.pyx")
else:
ext = ()
setup(
install_requires=required_packages,
packages=find_packages(),
include_package_data=True,
cmdclass=versioneer.get_cmdclass(),
ext_modules=ext,
include_dirs=[numpy.get_include()],
)