forked from yujiali/pygco
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2877935
commit a2181a2
Showing
3 changed files
with
41 additions
and
5 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 |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
""" | ||
|
||
import os | ||
import re | ||
import sys | ||
|
||
try: | ||
|
@@ -31,6 +32,23 @@ | |
LOCAL_SOURCE = os.path.join("src", "gco_cpp") | ||
|
||
|
||
try: | ||
from importlib.util import module_from_spec, spec_from_file_location | ||
|
||
def _load_py_module(module_name, location): | ||
spec = spec_from_file_location(module_name, location) | ||
py = module_from_spec(spec) | ||
spec.loader.exec_module(py) | ||
return py | ||
|
||
except ImportError: | ||
import imp | ||
|
||
def _load_py_module(module_name, location): | ||
py = imp.load_source(module_name, location) | ||
return py | ||
|
||
|
||
class BuildExt(build_ext): | ||
"""build_ext command for use when numpy headers are needed. | ||
SEE: https://stackoverflow.com/questions/2379898 | ||
|
@@ -57,22 +75,38 @@ def finalize_options(self): | |
if sys.version_info.major == 2: | ||
# numpy v1.17 drops support for py2 | ||
SETUP_REQUIRES = INSTALL_REQUIRES = ["Cython>=0.23.1", "numpy>=1.8.2, <1.17"] | ||
encode_kw = {} | ||
else: | ||
SETUP_REQUIRES = INSTALL_REQUIRES = ["Cython>=0.23.1", "numpy>=1.8.2"] | ||
encode_kw = dict(encoding="utf_8") | ||
|
||
ABOUT = _load_py_module(module_name="about", location=os.path.join("src", "gco", "__about__.py")) | ||
|
||
with open("README.md", **encode_kw) as fp: | ||
readme = re.sub( | ||
# replace image pattern | ||
pattern=r"\!\[([\w ]+)\]\(\./(.+)\)", | ||
# with static urls and the same format | ||
repl=r"" % ABOUT.__version__, | ||
# for whole README | ||
string=fp.read(), | ||
) | ||
|
||
setup( | ||
name="gco-wrapper", | ||
url="http://vision.csd.uwo.ca/code/", | ||
package_dir={"": "src"}, | ||
packages=find_packages(where="src"), | ||
# edit also gco.__init__.py! | ||
version="3.0.9", | ||
version=ABOUT.__version__, | ||
license="MIT", | ||
author="Yujia Li & A. Mueller", | ||
author_email="[email protected]", | ||
maintainer="Jiri Borovec", | ||
maintainer_email="[email protected]", | ||
description="pyGCO: a python wrapper for the graph cuts package", | ||
long_description=readme, | ||
long_description_content_type="text/markdown", | ||
download_url="https://github.com/Borda/pyGCO", | ||
project_urls={ | ||
"Source Code": "https://github.com/Borda/pyGCO", | ||
|
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,4 @@ | ||
__version__ = "3.0.9" | ||
__version_info__ = tuple([int(i) for i in __version__.split(".")]) | ||
|
||
__all__ = ["__version__", "__version_info__"] |
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