Skip to content

Commit da62368

Browse files
authored
Merge pull request #23 from michaeltryby/dev
Reorganizing package layout
2 parents 1a95f18 + c1c3096 commit da62368

File tree

18 files changed

+241
-130
lines changed

18 files changed

+241
-130
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*.exp
1313
*.so
1414
*.h
15+
buildlib/
1516

1617
build/
1718
dist/
@@ -23,3 +24,5 @@ output_wrap.c
2324

2425
toolkit.py
2526
toolkit_wrap.c
27+
28+
swmm_python/toolkit/tests/data/test.*

before_build.bat

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
::
2+
:: before_build.bat - Prepares for swmm toolkit and output module builds
3+
::
4+
:: Date Created: 12/21/2018
5+
::
6+
:: Author: Michael E. Tryby
7+
:: US EPA - ORD/NRMRL
8+
::
9+
10+
set PROJECT_PATH=%~1
11+
12+
set TOOLKIT_PATH=\swmm_python\toolkit\swmm\toolkit
13+
set OUTPUT_PATH=\swmm_python\output\swmm\output
14+
15+
16+
mkdir buildlib
17+
cd buildlib
18+
git clone --branch=feature-wrapper https://github.com/michaeltryby/Stormwater-Management-Model.git swmm
19+
cd swmm
20+
21+
22+
mkdir buildprod
23+
cd buildprod
24+
cmake -G"Visual Studio 14 2015 Win64" -DBUILD_TESTS=0 ..
25+
cmake --build . --config Release
26+
27+
28+
copy /Y .\bin\Release\swmm5.dll %PROJECT_PATH%\%TOOLKIT_PATH%
29+
copy /Y .\lib\Release\swmm5.lib %PROJECT_PATH%\%TOOLKIT_PATH%
30+
copy /Y ..\include\*.h %PROJECT_PATH%\%TOOLKIT_PATH%
31+
32+
copy /Y .\bin\Release\swmm-output.dll %PROJECT_PATH%\%OUTPUT_PATH%
33+
copy /Y .\lib\Release\swmm-output.lib %PROJECT_PATH%\%OUTPUT_PATH%
34+
copy /Y ..\tools\swmm-output\include\*.h %PROJECT_PATH%\%OUTPUT_PATH%

output/tests/data/__init__.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

setup.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
3+
import os
4+
import pathlib
5+
6+
from six import iteritems
7+
8+
from setuptools import setup
9+
from setuptools.command.develop import develop
10+
from setuptools.command.install import install
11+
12+
13+
import sys
14+
import subprocess
15+
16+
17+
PACKAGE_NAME = 'swmm'
18+
SOURCES = {
19+
'swmm.toolkit': 'swmm_python/toolkit',
20+
'swmm.output': 'swmm_python/output'
21+
}
22+
23+
24+
def install_microlibs(sources, develop=False):
25+
""" Use pip to install all microlibraries. """
26+
print("installing all microlibs in {} mode".format(
27+
"development" if develop else "normal"))
28+
wd = pathlib.Path.cwd()
29+
for k, v in iteritems(sources):
30+
try:
31+
microlib_dir = os.fspath(wd.joinpath(v))
32+
if develop:
33+
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-e', '.'], cwd=microlib_dir)
34+
else:
35+
subprocess.check_call([sys.executable, '-m', 'pip', 'install', '.'], cwd=microlib_dir)
36+
except Exception as e:
37+
print("Oops, something went wrong installing", k, microlib_dir)
38+
print(e)
39+
finally:
40+
os.chdir(wd)
41+
42+
43+
class DevelopCmd(develop):
44+
""" Add custom steps for the develop command """
45+
def run(self):
46+
install_microlibs(SOURCES, develop=True)
47+
develop.run(self)
48+
49+
50+
class InstallCmd(install):
51+
""" Add custom steps for the install command """
52+
def run(self):
53+
install_microlibs(SOURCES, develop=False)
54+
install.run(self)
55+
56+
57+
setup(
58+
name=PACKAGE_NAME,
59+
version="0.2.0a",
60+
author="Michael Tryby",
61+
author_email="Michael [email protected]",
62+
description="swmm_python - SWIG generated python wrappers for swmm libraries",
63+
license="CC0",
64+
classifiers=[
65+
'Private :: Do Not Upload to pypi server',
66+
],
67+
cmdclass={
68+
'install': InstallCmd,
69+
'develop': DevelopCmd
70+
71+
}
72+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11

22

3+
aenum
4+
35
-e ./

output/setup.py renamed to swmm_python/output/setup.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
#
44
# setup.py - Setup script for swmm_output python extension
5-
#
5+
#
66
# Created: 7/2/2018
77
# Author: Michael E. Tryby
88
# US EPA - ORD/NRMRL
99
#
1010
# Requires:
11-
# Platform C language compiler
11+
# Platform C language compiler
1212
# SWIG
1313
#
1414

@@ -20,12 +20,14 @@
2020
from distutils.command.build_ext import build_ext
2121

2222

23+
microlib_name = 'swmm.output'
24+
2325
setup(
24-
name = "swmm-output",
26+
name = microlib_name,
2527
version = "0.3.0-dev",
2628

2729
ext_modules = [
28-
Extension("swmm.output._output",
30+
Extension("swmm.output._output",
2931
include_dirs = ['swmm/output/'],
3032
libraries = ['swmm-output'],
3133
library_dirs = ['swmm/output/'],
@@ -34,10 +36,11 @@
3436
language='C'
3537
)
3638
],
37-
packages = ['swmm.output'],
39+
namespace_packages=['swmm'],
40+
packages = [microlib_name],
3841
py_modules = ['output'],
39-
package_data = {'swmm.output':['*swmm-output.dll', '*swmm-output.so']},
40-
42+
package_data = {microlib_name:['*swmm-output.dll', '*swmm-output.so']},
43+
4144
install_requires = [
4245
'aenum'
4346
]
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)