-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from jingpengw/master
release the package to pypi
- Loading branch information
Showing
12 changed files
with
8,676 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ build | |
*checkpoints* | ||
*.nfs | ||
*.sw[pmno] | ||
waterz/evaluate.cpp | ||
jwu/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
language: python | ||
|
||
python: | ||
- '3.7' | ||
- '3.8' | ||
- '3.9' | ||
|
||
services: | ||
- docker | ||
|
||
env: | ||
- DOCKER_IMAGE=quay.io/pypa/manylinux1_x86_64 PLAT=manylinux1_x86_64 | ||
- DOCKER_IMAGE=quay.io/pypa/manylinux1_i686 PRE_CMD=linux32 PLAT=manylinux1_i686 | ||
- DOCKER_IMAGE=quay.io/pypa/manylinux2010_x86_64 PLAT=manylinux2010_x86_64 | ||
|
||
before_install: | ||
- docker pull $DOCKER_IMAGE | ||
|
||
install: | ||
- sudo find /usr -name '*.pyc' -delete | ||
- sudo apt update | ||
- sudo apt install libboost-dev | ||
- pip install -r requirements.txt | ||
- pip install . | ||
|
||
script: | ||
- pytest --cov-append --cov=./waterz ./tests --verbose | ||
|
||
after_success: | ||
- coveralls | ||
- chmod +x ./travis/build-wheels.sh | ||
- docker run --rm -e PLAT=$PLAT -v `pwd`:/io $DOCKER_IMAGE $PRE_CMD /io/travis/build-wheels.sh | ||
- ls wheelhouse/ | ||
- | | ||
if [[ $TRAVIS_TAG ]]; then | ||
echo "upload wheel file." | ||
python -m pip install twine | ||
python -m twine upload wheelhouse/waterz*.whl | ||
fi | ||
notifications: | ||
email: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
include requirements.txt | ||
include README.md | ||
|
||
recursive-include waterz *.hpp | ||
recursive-include waterz *.pyx | ||
recursive-include waterz *.h | ||
recursive-include waterz *.h | ||
|
||
include waterz/frontend_agglomerate.cpp | ||
include waterz/evaluate.cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["setuptools", "numpy", "wheel"] | ||
build-backend = "setuptools.build_meta" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
numpy | ||
cython | ||
|
||
# dev | ||
|
||
pytest | ||
coveralls | ||
pytest-cov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,75 @@ | ||
from setuptools import setup | ||
from setuptools import setup, find_packages | ||
from setuptools.extension import Extension | ||
from Cython.Build import cythonize | ||
import numpy | ||
from setuptools.command.build_ext import build_ext as _build_ext | ||
# from Cython.Build import cythonize | ||
import os | ||
import builtins | ||
|
||
VERSION = '0.9.5' | ||
|
||
PACKAGE_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
|
||
with open(os.path.join(PACKAGE_DIR, "README.md"), "r") as fh: | ||
long_description = fh.read() | ||
|
||
|
||
class build_ext(_build_ext): | ||
"""We assume no numpy at the begining | ||
https://stackoverflow.com/questions/19919905/how-to-bootstrap-numpy-installation-in-setup-py | ||
""" | ||
def finalize_options(self): | ||
_build_ext.finalize_options(self) | ||
# Prevent numpy from thinking it is still in its setup process: | ||
builtins.__NUMPY_SETUP__ = False | ||
import numpy | ||
self.include_dirs.append(numpy.get_include()) | ||
|
||
|
||
source_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'waterz') | ||
include_dirs = [ | ||
source_dir, | ||
os.path.join(source_dir, 'backend'), | ||
# os.path.dirname(get_python_inc()), | ||
numpy.get_include(), | ||
# numpy.get_include(), | ||
] | ||
extensions = [ | ||
Extension( | ||
'waterz.evaluate', | ||
sources=['waterz/evaluate.pyx', 'waterz/frontend_evaluate.cpp'], | ||
sources=['waterz/evaluate.cpp', 'waterz/frontend_evaluate.cpp'], | ||
include_dirs=include_dirs, | ||
language='c++', | ||
extra_link_args=['-std=c++11'], | ||
extra_compile_args=['-std=c++11', '-w']) | ||
] | ||
|
||
|
||
setup( | ||
name='waterz', | ||
version='0.8', | ||
description='Simple watershed and agglomeration for affinity graphs.', | ||
url='https://github.com/funkey/waterz', | ||
author='Jan Funke', | ||
author_email='[email protected]', | ||
license='MIT', | ||
requires=['cython','numpy'], | ||
packages=['waterz'], | ||
package_data={ | ||
'': [ | ||
'waterz/*.h', | ||
'waterz/*.hpp', | ||
'waterz/*.cpp', | ||
'waterz/*.cpp', | ||
'waterz/*.pyx', | ||
'waterz/backend/*.hpp', | ||
] | ||
}, | ||
include_package_data=True, | ||
zip_safe=False, | ||
ext_modules=cythonize(extensions) | ||
name='waterz', | ||
version=VERSION, | ||
description='Simple watershed and agglomeration for affinity graphs.', | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
url='https://github.com/funkey/waterz', | ||
author='Jan Funke, Jingpeng Wu', | ||
author_email='[email protected]', | ||
license='MIT', | ||
cmdclass={'build_ext': build_ext}, | ||
setup_requires=['numpy'], | ||
install_requires=['numpy', 'cython'], | ||
tests_require=['pytest'], | ||
packages=find_packages(), | ||
package_data={ | ||
'': ['*.pyx', '*.hpp', '*.cpp', '*.h', '*.py', 'backend/*.hpp'], | ||
'backend': ['*.hpp'] | ||
}, | ||
zip_safe=False, | ||
ext_modules=extensions, | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
], | ||
requires_python=">=3.6, <4", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import sys | ||
from pathlib import Path | ||
|
||
# waterz is not locally importable; | ||
# this snippet forces the tests to use the installed version. | ||
# See here for more details: | ||
# https://stackoverflow.com/questions/67176036/how-to-prevent-pytest-using-local-module | ||
project_dir = str(Path(__file__).resolve().parent.parent) | ||
sys.path = [p for p in sys.path if not p.startswith(project_dir)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import numpy as np | ||
import waterz as wz | ||
from math import isclose | ||
|
||
|
||
def test_evaluate(): | ||
# make the random value consistent with different runs | ||
np.random.seed(0) | ||
|
||
seg = np.random.randint(500, size=(3, 3, 3), dtype=np.uint64) | ||
scores = wz.evaluate(seg, seg) | ||
assert scores['voi_split'] == 0.0 | ||
assert scores['voi_merge'] == 0.0 | ||
assert scores['rand_split'] == 1.0 | ||
assert scores['rand_merge'] == 1.0 | ||
|
||
seg2 = np.random.randint(500, size=(3,3,3), dtype=np.uint64) | ||
scores = wz.evaluate(seg, seg2) | ||
#print('scores: ', scores) | ||
# Note that these values are from the first run | ||
# I have not double checked that this is correct or not. | ||
# This assertion only make sure that future changes of | ||
# code will not change the result of the evaluation | ||
assert isclose(scores['rand_split'], 0.8181818181818182) | ||
assert isclose(scores['rand_merge'], 0.8709677419354839) | ||
assert isclose(scores['voi_split'], 0.22222222222222232) | ||
assert isclose(scores['voi_merge'], 0.14814814814814792) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
set -e -x | ||
|
||
# Install a system package required by our library | ||
#yum check-update | ||
yum install -y boost-devel | ||
|
||
# Compile wheels | ||
for PYBIN in /opt/python/*/bin; do | ||
"${PYBIN}/pip" install -r /io/requirements.txt | ||
"${PYBIN}/pip" wheel /io/ -w wheelhouse/ | ||
done | ||
|
||
# Bundle external shared libraries into the wheels | ||
for whl in wheelhouse/*.whl; do | ||
auditwheel repair "$whl" --plat $PLAT -w /io/wheelhouse/ | ||
done | ||
|
||
# Install packages and test | ||
for PYBIN in /opt/python/*/bin/; do | ||
"${PYBIN}/pip" install waterz --no-index -f /io/wheelhouse | ||
done |
Oops, something went wrong.