Skip to content

Commit cc5ee57

Browse files
authored
Merge pull request #41 from michaeltryby/dev
Building wheels for py36 and py37 on build worker
2 parents b1e2ca1 + c378423 commit cc5ee57

File tree

7 files changed

+108
-67
lines changed

7 files changed

+108
-67
lines changed

appveyor.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
environment:
44
passphrase:
55
secure: En1qcj1/l2B3Nov+vOHlfRrFZk00bg1HPRouD64Gzfw=
6+
CIBW_SKIP: cp27-* cp34-* cp35-* *-win32
7+
CIBW_BEFORE_BUILD: pip install six
8+
CIBW_TEST_COMMAND: pytest {project}\\tests
9+
CIBW_TEST_REQUIRES: pytest numpy
610
matrix:
711
- PYTHON: "C:\\Python36-x64"
812

@@ -18,5 +22,19 @@ build: off
1822

1923

2024
test_script:
21-
- before_build.bat %APPVEYOR_BUILD_FOLDER%
25+
- before_build.bat
2226
- "%PYTHON%\\python.exe -m tox -v"
27+
28+
after_test:
29+
- "%PYTHON%\\python.exe -m pip install cibuildwheel==0.10.1"
30+
- "%PYTHON%\\python.exe -m cibuildwheel --output-dir wheelhouse .\\epanet_python\\output"
31+
- "%PYTHON%\\python.exe -m cibuildwheel --output-dir wheelhouse .\\epanet_python\\toolkit"
32+
33+
artifacts:
34+
- path: "wheelhouse\\*.whl"
35+
name: Wheels
36+
37+
cache:
38+
- C:\ProgramData\chocolatey\bin -> appveyor.yml
39+
- C:\ProgramData\chocolatey\lib -> appveyor.yml
40+
- C:\projects\epanet-python\.tox -> tox.ini

before_build.bat

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,20 @@
66
:: Author: Michael E. Tryby
77
:: US EPA - ORD/NRMRL
88
::
9+
:: Requires:
10+
:: CMake
11+
:: Visual Studio 2015
12+
:: SWIG
13+
::
14+
:: Note:
15+
:: This script must be located at the root of the project folder
16+
: in order to work correctly.
17+
::
918

10-
set PROJECT_PATH=%~1
19+
20+
:: Determine project path and strip trailing \ from path
21+
set "PROJECT_PATH=%~dp0"
22+
IF %PROJECT_PATH:~-1%==\ set "PROJECT_PATH=%PROJECT_PATH:~0,-1%"
1123

1224
set TOOLKIT_PATH=\epanet_python\toolkit\epanet\toolkit
1325
set OUTPUT_PATH=\epanet_python\output\epanet\output
@@ -32,3 +44,14 @@ copy /Y ..\include\*.h %PROJECT_PATH%\%TOOLKIT_PATH%
3244
copy /Y .\bin\Release\epanet-output.dll %PROJECT_PATH%\%OUTPUT_PATH%
3345
copy /Y .\lib\Release\epanet-output.lib %PROJECT_PATH%\%OUTPUT_PATH%
3446
copy /Y ..\tools\epanet-output\include\*.h %PROJECT_PATH%\%OUTPUT_PATH%
47+
48+
49+
:: Generate swig wrappers
50+
cd %PROJECT_PATH%\%TOOLKIT_PATH%
51+
swig -python -py3 toolkit.i
52+
cd %PROJECT_PATH%\%OUTPUT_PATH%
53+
swig -python -py3 output.i
54+
55+
56+
:: Return to project root
57+
cd %PROJECT_PATH%

epanet_python/output/epanet/output/__init__.py

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

33
#
44
# __init__.py - EPANET output package
5-
#
5+
#
66
# Date Created: August 15, 2018
77
#
88
# Author: Michael E. Tryby
@@ -19,7 +19,7 @@
1919
__credits__ = "Maurizio Cingi"
2020
__license__ = "CC0 1.0 Universal"
2121

22-
__version__ = "0.1.1"
22+
__version__ = "0.2.0"
2323
__date__ = "August 15, 2018"
2424

2525
__maintainer__ = "Michael Tryby"
@@ -29,7 +29,7 @@
2929

3030
from enum import Enum, auto
3131

32-
from epanet.output import output as oapi
32+
from epanet.output import output as oapi
3333

3434

3535
class Units(Enum):
@@ -41,107 +41,107 @@ class Units(Enum):
4141
HEADLOSS = auto()
4242
RX_RATE = auto()
4343
UNITLESS = auto()
44-
NONE = auto()
44+
NONE = auto()
4545

4646
class RxUnits(Enum):
47-
MGH = auto()
47+
MGH = auto()
4848
UGH = auto()
4949

5050

5151
class OutputMetadata():
5252
'''
5353
Simple attribute name and unit lookup.
5454
'''
55-
55+
5656
_unit_labels_us_ = {
5757
Units.HYD_HEAD: "ft",
5858
Units.VELOCITY: "ft/sec",
59-
Units.HEADLOSS: "ft/1000ft",
59+
Units.HEADLOSS: "ft/1000ft",
6060
Units.UNITLESS: "unitless",
6161
Units.NONE: "",
62-
62+
6363
RxUnits.MGH: "mg/hr",
6464
RxUnits.UGH: "ug/hr",
65-
65+
6666
oapi.FlowUnits.CFS: "cu ft/s",
6767
oapi.FlowUnits.GPM: "gal/min",
6868
oapi.FlowUnits.MGD: "M gal/day",
6969
oapi.FlowUnits.IMGD: "M Imp gal/day",
7070
oapi.FlowUnits.AFD: "ac ft/day",
71-
72-
oapi.PressUnits.PSI: "psi",
73-
74-
oapi.QualUnits.NONE: "",
71+
72+
oapi.PressUnits.PSI: "psi",
73+
74+
oapi.QualUnits.NONE: "",
7575
oapi.QualUnits.MGL: "mg/L",
7676
oapi.QualUnits.UGL: "ug/L",
77-
oapi.QualUnits.HOURS: "hrs",
77+
oapi.QualUnits.HOURS: "hrs",
7878
oapi.QualUnits.PRCNT: "%"}
7979

8080
_unit_labels_si_ = {
8181
Units.HYD_HEAD: "m",
8282
Units.VELOCITY: "m/sec",
83-
Units.HEADLOSS: "m/Km",
83+
Units.HEADLOSS: "m/Km",
8484
Units.UNITLESS: "unitless",
8585
Units.NONE: "",
86-
86+
8787
RxUnits.MGH: "mg/hr",
8888
RxUnits.UGH: "ug/hr",
89-
89+
9090
oapi.FlowUnits.LPS: "L/sec",
9191
oapi.FlowUnits.LPM: "L/min",
9292
oapi.FlowUnits.MLD: "M L/day",
9393
oapi.FlowUnits.CMH: "cu m/hr",
9494
oapi.FlowUnits.CMD: "cu m/day",
95-
95+
9696
oapi.PressUnits.MTR: "meters",
9797
oapi.PressUnits.KPA: "kPa",
98-
99-
oapi.QualUnits.NONE: "",
98+
99+
oapi.QualUnits.NONE: "",
100100
oapi.QualUnits.MGL: "mg/L",
101101
oapi.QualUnits.UGL: "ug/L",
102-
oapi.QualUnits.HOURS: "hrs",
102+
oapi.QualUnits.HOURS: "hrs",
103103
oapi.QualUnits.PRCNT: "%"}
104104

105-
105+
106106
def __init__(self, output_handle):
107-
107+
108108
self.units = list()
109109
# If outputhandle not initialized use default settings
110-
if output_handle == None:
111-
self.units = [oapi.FlowUnits.GPM.value,
112-
oapi.PressUnits.PSI.value,
110+
if output_handle == None:
111+
self.units = [oapi.FlowUnits.GPM.value,
112+
oapi.PressUnits.PSI.value,
113113
oapi.QualUnits.NONE.value]
114114
# Else quary the output api for unit settings
115115
else:
116-
for u in oapi.Units:
116+
for u in oapi.Units:
117117
self.units.append(oapi.getunits(output_handle, u))
118-
119-
# Convert unit settings to enums
118+
119+
# Convert unit settings to enums
120120
self._flow = oapi.FlowUnits(self.units[0])
121121
self._press = oapi.PressUnits(self.units[1])
122122
self._qual = oapi.QualUnits(self.units[2])
123-
123+
124124
# Determine unit system from flow setting
125125
if self._flow.value <= oapi.FlowUnits.AFD.value:
126126
self._unit_labels = type(self)._unit_labels_us_
127127
else:
128-
self._unit_labels = type(self)._unit_labels_si_
129-
128+
self._unit_labels = type(self)._unit_labels_si_
129+
130130
# Determine mass units from quality settings
131131
if self._qual == oapi.QualUnits.MGL:
132132
self._rx_rate = RxUnits.MGH
133133
elif self._qual == oapi.QualUnits.UGL:
134134
self._rx_rate = RxUnits.UGH
135135
else:
136-
self._rx_rate = Units.NONE
136+
self._rx_rate = Units.NONE
137137

138138

139139
self._metadata = {
140140
oapi.NodeAttribute.DEMAND: ("Demand", self._unit_labels[self._flow]),
141141
oapi.NodeAttribute.HEAD: ("Head", self._unit_labels[Units.HYD_HEAD]),
142142
oapi.NodeAttribute.PRESSURE: ("Pressure", self._unit_labels[self._press]),
143143
oapi.NodeAttribute.QUALITY: ("Quality", self._unit_labels[self._qual]),
144-
144+
145145
oapi.LinkAttribute.FLOW: ("Flow", self._unit_labels[self._flow]),
146146
oapi.LinkAttribute.VELOCITY: ("Velocity", self._unit_labels[Units.VELOCITY]),
147147
oapi.LinkAttribute.HEADLOSS: ("Unit Headloss", self._unit_labels[Units.HEADLOSS]),
@@ -152,7 +152,7 @@ def __init__(self, output_handle):
152152
oapi.LinkAttribute.FRCTN_FCTR: ("Friction Factor", self._unit_labels[Units.UNITLESS])
153153
}
154154

155-
155+
156156
def get_attribute_metadata(self, attribute):
157157
'''
158158
Takes an attribute enum and returns a tuple with name and units.

epanet_python/output/setup.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,24 @@
2424
microlib_name = 'epanet.output'
2525

2626
setup(
27-
name = microlib_name,
28-
version = "0.1.2a0",
27+
name = 'epanet.output',
28+
version = "0.2.0.dev0",
2929
ext_modules = [
3030
Extension("epanet.output._output",
31+
sources = ['epanet/output/output_wrap.c'],
3132
include_dirs = ['epanet/output'],
3233
libraries = ['epanet-output'],
3334
library_dirs = ['epanet/output'],
34-
sources = ['epanet/output/output.i'],
35-
swig_opts=['-py3'],
3635
language = 'C'
3736
)
3837
],
38+
39+
# tox can't find swmm module at test time unless namespace is declared
3940
namespace_packages=['epanet'],
40-
packages = {microlib_name},
41+
42+
packages = {'epanet.output'},
4143
py_modules = ['output'],
42-
# include_package_data=True
43-
package_data = {microlib_name:['*epanet-output.dll', '*epanet-output.so']},
44+
package_data = {'epanet.output':['*epanet-output.dll', '*epanet-output.so']},
4445

45-
# install_requires = []
46+
zip_safe=False,
4647
)

epanet_python/toolkit/setup.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,33 @@
88
#
99
# Requires:
1010
# Platform C language compiler
11-
# SWIG
1211
#
1312

14-
try:
15-
from setuptools import setup, Extension
16-
from setuptools.command.build_ext import build_ext
17-
except ImportError:
18-
from distutils.core import setup, Extension
19-
from distutils.command.build_ext import build_ext
2013

14+
from setuptools import setup, Extension
15+
from setuptools.command.build_ext import build_ext
2116

22-
microlib_name = 'epanet.toolkit'
2317

2418
setup(
25-
name = microlib_name,
26-
version = "0.0.3a0",
19+
name = 'epanet.toolkit',
20+
version = "0.2.0.dev0",
2721
ext_modules = [
2822
Extension("epanet.toolkit._toolkit",
29-
sources = ['epanet/toolkit/toolkit.i'],
30-
swig_opts = ['-py3'],
23+
sources = ['epanet/toolkit/toolkit_wrap.c'],
3124
include_dirs = ['epanet/toolkit'],
3225
library_dirs = ['epanet/toolkit'],
3326
libraries = ['epanet_py'],
3427
language = 'C'
3528
)
3629
],
30+
31+
# tox can't find epanet module at test time unless namespace is declared
3732
namespace_packages = ['epanet'],
38-
packages = {microlib_name},
33+
34+
packages = {'epanet.toolkit'},
3935
py_modules = ['toolkit'],
40-
# include_package_data=True
41-
package_data = {microlib_name:['*epanet_py.dll', '*epanet_py.so']},
36+
package_data = {'epanet.toolkit':['*epanet_py.dll', '*epanet_py.so']},
37+
38+
zip_safe=False
4239

4340
)

setup.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,21 @@ def run(self):
5656

5757
setup(
5858
name=PACKAGE_NAME,
59-
version="0.2.0a",
59+
version="0.3.0.dev0",
60+
61+
cmdclass={
62+
'install': InstallCmd,
63+
'develop': DevelopCmd
64+
},
65+
6066
author="Michael Tryby",
6167
author_email="Michael [email protected]",
6268
description="epanet_python - SWIG generated python wrappers for epanet libraries",
6369
license="CC0",
6470
classifiers=[
6571
'Private :: Do Not Upload to pypi server',
6672
],
67-
cmdclass={
68-
'install': InstallCmd,
69-
'develop': DevelopCmd
7073

71-
},
7274
setup_requires=["pytest-runner"],
73-
tests_require=["pytest"]
75+
tests_require=["pytest", 'numpy']
7476
)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ deps =
1414
PyYAML
1515
coveralls
1616
commands =
17-
coverage run --source=epanet_python setup.py test
17+
coverage run --source epanet_python --omit */tests/test_*.py setup.py test
1818
coveralls

0 commit comments

Comments
 (0)