forked from OpenWaterAnalytics/epanet-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
76 lines (57 loc) · 1.88 KB
/
Copy pathsetup.py
File metadata and controls
76 lines (57 loc) · 1.88 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
import os
import pathlib
from six import iteritems
from setuptools import setup
from setuptools.command.develop import develop
from setuptools.command.install import install
import sys
import subprocess
PACKAGE_NAME = 'epanet'
SOURCES = {
'epanet.toolkit': 'epanet_python/toolkit',
'epanet.output': 'epanet_python/output'
}
def install_microlibs(sources, develop=False):
""" Use pip to install all microlibraries. """
print("installing all microlibs in {} mode".format(
"development" if develop else "normal"))
wd = pathlib.Path.cwd()
for k, v in iteritems(sources):
try:
microlib_dir = os.fspath(wd.joinpath(v))
if develop:
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-e', '.'], cwd=microlib_dir)
else:
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '.'], cwd=microlib_dir)
except Exception as e:
print("Oops, something went wrong installing", k, microlib_dir)
print(e)
finally:
os.chdir(wd)
class DevelopCmd(develop):
""" Add custom steps for the develop command """
def run(self):
install_microlibs(SOURCES, develop=True)
develop.run(self)
class InstallCmd(install):
""" Add custom steps for the install command """
def run(self):
install_microlibs(SOURCES, develop=False)
install.run(self)
setup(
name=PACKAGE_NAME,
version="0.3.0.dev1",
cmdclass={
'install': InstallCmd,
'develop': DevelopCmd
},
author="Michael Tryby",
author_email="Michael Tryby@epa.gov",
description="epanet_python - SWIG generated python wrappers for epanet libraries",
license="CC0",
classifiers=[
'Private :: Do Not Upload to pypi server',
],
setup_requires=["pytest-runner"],
tests_require=["pytest", 'numpy']
)