Merge branch 'feature/plugins' of https://github.com/natcap/invest into feature/plugins
This commit is contained in:
commit
9665164bd5
|
@ -132,22 +132,21 @@ jobs:
|
|||
NATCAP_INVEST_GDAL_LIB_PATH="$CONDA_PREFIX/Library" python -m build --wheel
|
||||
ls -la dist
|
||||
|
||||
# Uncomment this when we uncomment the C++ extensions
|
||||
# # This produces a wheel that should work on any distro with glibc>=2.39.
|
||||
# # This is a very recent version. If we want to support older versions, I
|
||||
# # suspect we would need to build GDAL from source on an appropriate
|
||||
# # system (such as a manylinux docker container) to ensure compatibility.
|
||||
# # Symbols used in libgdal are the cause of the high minimum version,
|
||||
# # possibly because of installing with conda.
|
||||
# - name: Audit and repair wheel for manylinux
|
||||
# if: matrix.os == 'ubuntu-latest'
|
||||
# run: |
|
||||
# ldd --version
|
||||
# pip install auditwheel
|
||||
# WHEEL=$(find dist -name "natcap[._-]invest*.whl")
|
||||
# auditwheel show $WHEEL
|
||||
# auditwheel repair $WHEEL --plat manylinux_2_39_x86_64 -w dist
|
||||
# rm $WHEEL # remove the original wheel
|
||||
# This produces a wheel that should work on any distro with glibc>=2.39.
|
||||
# This is a very recent version. If we want to support older versions, I
|
||||
# suspect we would need to build GDAL from source on an appropriate
|
||||
# system (such as a manylinux docker container) to ensure compatibility.
|
||||
# Symbols used in libgdal are the cause of the high minimum version,
|
||||
# possibly because of installing with conda.
|
||||
- name: Audit and repair wheel for manylinux
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
ldd --version
|
||||
pip install auditwheel
|
||||
WHEEL=$(find dist -name "natcap[._-]invest*.whl")
|
||||
auditwheel show $WHEEL
|
||||
auditwheel repair $WHEEL --plat manylinux_2_39_x86_64 -w dist
|
||||
rm $WHEEL # remove the original wheel
|
||||
|
||||
- name: Install wheel and run model tests
|
||||
run: |
|
||||
|
@ -158,7 +157,7 @@ jobs:
|
|||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Wheel for ${{ matrix.os }} ${{ matrix.python-version }}
|
||||
path: dist
|
||||
path: dist/*.whl
|
||||
|
||||
- name: Upload conda env artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
|
|
|
@ -17,7 +17,7 @@ numpy>=1.11.0,!=1.16.0
|
|||
Rtree>=0.8.2,!=0.9.1
|
||||
shapely>=2.0.0
|
||||
scipy>=1.9.0,!=1.12.*
|
||||
pygeoprocessing>=2.4.6
|
||||
pygeoprocessing==2.4.7
|
||||
taskgraph>=0.11.0
|
||||
psutil>=5.6.6
|
||||
chardet>=3.0.4
|
||||
|
|
78
setup.py
78
setup.py
|
@ -39,6 +39,26 @@ else:
|
|||
).stdout.split()[0][2:]] # get the first argument which is the library path
|
||||
|
||||
|
||||
if platform.system() == 'Windows':
|
||||
compiler_args = ['/std:c++20']
|
||||
compiler_and_linker_args = []
|
||||
if 'NATCAP_INVEST_GDAL_LIB_PATH' not in os.environ:
|
||||
raise RuntimeError(
|
||||
'env variable NATCAP_INVEST_GDAL_LIB_PATH is not defined. '
|
||||
'This env variable is required when building on Windows. If '
|
||||
'using conda to manage your gdal installation, you may set '
|
||||
'NATCAP_INVEST_GDAL_LIB_PATH="$CONDA_PREFIX/Library".')
|
||||
library_dirs = [f'{os.environ["NATCAP_INVEST_GDAL_LIB_PATH"]}/lib']
|
||||
include_dirs.append(f'{os.environ["NATCAP_INVEST_GDAL_LIB_PATH"]}/include')
|
||||
else:
|
||||
compiler_args = [subprocess.run(
|
||||
['gdal-config', '--cflags'], capture_output=True, text=True
|
||||
).stdout.strip()]
|
||||
compiler_and_linker_args = ['-std=c++20']
|
||||
library_dirs = [subprocess.run(
|
||||
['gdal-config', '--libs'], capture_output=True, text=True
|
||||
).stdout.split()[0][2:]] # get the first argument which is the library path
|
||||
|
||||
class build_py(_build_py):
|
||||
"""Command to compile translation message catalogs before building."""
|
||||
|
||||
|
@ -61,35 +81,35 @@ class build_py(_build_py):
|
|||
|
||||
setup(
|
||||
install_requires=_REQUIREMENTS,
|
||||
# ext_modules=cythonize([
|
||||
# Extension(
|
||||
# name=f'natcap.invest.{package}.{module}',
|
||||
# sources=[f'src/natcap/invest/{package}/{module}.pyx'],
|
||||
# include_dirs=include_dirs,
|
||||
# extra_compile_args=compiler_args + package_compiler_args + compiler_and_linker_args,
|
||||
# extra_link_args=compiler_and_linker_args,
|
||||
# language='c++',
|
||||
# libraries=['gdal'],
|
||||
# library_dirs=library_dirs,
|
||||
# define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]
|
||||
# ) for package, module, package_compiler_args in [
|
||||
# ('delineateit', 'delineateit_core', []),
|
||||
# ('recreation', 'out_of_core_quadtree', []),
|
||||
# # clang-14 defaults to -ffp-contract=on, which causes the
|
||||
# # arithmetic of A*B+C to be implemented using a contraction, which
|
||||
# # causes an unexpected change in the precision in some viewshed
|
||||
# # tests on ARM64 (mac M1). See these issues for more details:
|
||||
# # * https://github.com/llvm/llvm-project/issues/91824
|
||||
# # * https://github.com/natcap/invest/issues/1562
|
||||
# # * https://github.com/natcap/invest/pull/1564/files
|
||||
# # Using this flag on gcc and on all versions of clang should work
|
||||
# # as expected, with consistent results.
|
||||
# ('scenic_quality', 'viewshed', ['-ffp-contract=off']),
|
||||
# ('ndr', 'ndr_core', []),
|
||||
# ('sdr', 'sdr_core', []),
|
||||
# ('seasonal_water_yield', 'seasonal_water_yield_core', [])
|
||||
# ]
|
||||
# ], compiler_directives={'language_level': '3'}),
|
||||
ext_modules=cythonize([
|
||||
Extension(
|
||||
name=f'natcap.invest.{package}.{module}',
|
||||
sources=[f'src/natcap/invest/{package}/{module}.pyx'],
|
||||
include_dirs=include_dirs,
|
||||
extra_compile_args=compiler_args + package_compiler_args + compiler_and_linker_args,
|
||||
extra_link_args=compiler_and_linker_args,
|
||||
language='c++',
|
||||
libraries=['gdal'],
|
||||
library_dirs=library_dirs,
|
||||
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]
|
||||
) for package, module, package_compiler_args in [
|
||||
('delineateit', 'delineateit_core', []),
|
||||
('recreation', 'out_of_core_quadtree', []),
|
||||
# clang-14 defaults to -ffp-contract=on, which causes the
|
||||
# arithmetic of A*B+C to be implemented using a contraction, which
|
||||
# causes an unexpected change in the precision in some viewshed
|
||||
# tests on ARM64 (mac M1). See these issues for more details:
|
||||
# * https://github.com/llvm/llvm-project/issues/91824
|
||||
# * https://github.com/natcap/invest/issues/1562
|
||||
# * https://github.com/natcap/invest/pull/1564/files
|
||||
# Using this flag on gcc and on all versions of clang should work
|
||||
# as expected, with consistent results.
|
||||
('scenic_quality', 'viewshed', ['-ffp-contract=off']),
|
||||
('ndr', 'ndr_core', []),
|
||||
('sdr', 'sdr_core', []),
|
||||
('seasonal_water_yield', 'seasonal_water_yield_core', [])
|
||||
]
|
||||
], compiler_directives={'language_level': '3'}),
|
||||
include_dirs=[numpy.get_include()],
|
||||
cmdclass={
|
||||
'build_py': build_py
|
||||
|
|
|
@ -29,9 +29,6 @@ pyname_to_module = {}
|
|||
for _, _name, _ispkg in pkgutil.iter_modules(natcap.invest.__path__):
|
||||
if _name in {'__main__', 'cli', 'ui_server'}:
|
||||
continue # avoid a circular import
|
||||
if _name in {'delineateit', 'ndr', 'scenic_quality', 'sdr',
|
||||
'seasonal_water_yield', 'recreation'}:
|
||||
continue # avoid compiled models for development of plugin feature branch
|
||||
_module = importlib.import_module(f'natcap.invest.{_name}')
|
||||
if _ispkg:
|
||||
for _, _sub_name, _ in pkgutil.iter_modules(_module.__path__):
|
||||
|
@ -45,7 +42,7 @@ for _, _name, _ispkg in pkgutil.iter_modules(natcap.invest.__path__):
|
|||
# discover plugins: identify packages whose name starts with invest-
|
||||
# and meet the basic API criteria for an invest plugin
|
||||
for _, _name, _ispkg in pkgutil.iter_modules():
|
||||
if _name.startswith('invest-'):
|
||||
if _name.startswith('invest'):
|
||||
_module = importlib.import_module(_name)
|
||||
if is_invest_compliant_model(_module):
|
||||
pyname_to_module[_name] = _module
|
||||
|
|
|
@ -25,10 +25,6 @@ REGRESSION_DATA = os.path.join(
|
|||
os.path.dirname(__file__), '..', 'data', 'invest-test-data',
|
||||
'delineateit')
|
||||
|
||||
# Skipping all compiled model tests temporarily for feature/plugins
|
||||
pytestmark = pytest.mark.skip(
|
||||
reason="Temporarily ignoring compiled models for feature/plugins")
|
||||
|
||||
@contextlib.contextmanager
|
||||
def capture_logging(logger, level=logging.NOTSET):
|
||||
"""Capture logging within a context manager.
|
||||
|
|
|
@ -17,10 +17,6 @@ gdal.UseExceptions()
|
|||
REGRESSION_DATA = os.path.join(
|
||||
os.path.dirname(__file__), '..', 'data', 'invest-test-data', 'ndr')
|
||||
|
||||
# Skipping all compiled model tests temporarily for feature/plugins
|
||||
pytestmark = pytest.mark.skip(
|
||||
reason="Temporarily ignoring compiled models for feature/plugins")
|
||||
|
||||
class NDRTests(unittest.TestCase):
|
||||
"""Regression tests for InVEST SDR model."""
|
||||
|
||||
|
|
|
@ -43,10 +43,6 @@ SAMPLE_DATA = os.path.join(REGRESSION_DATA, 'input')
|
|||
|
||||
LOGGER = logging.getLogger('test_recreation')
|
||||
|
||||
# Skipping all compiled model tests temporarily for feature/plugins
|
||||
pytestmark = pytest.mark.skip(
|
||||
reason="Temporarily ignoring compiled models for feature/plugins")
|
||||
|
||||
def _timeout(max_timeout):
|
||||
"""Timeout decorator, parameter in seconds."""
|
||||
def timeout_decorator(target):
|
||||
|
|
|
@ -20,10 +20,6 @@ _SRS = osr.SpatialReference()
|
|||
_SRS.ImportFromEPSG(32731) # WGS84 / UTM zone 31s
|
||||
WKT = _SRS.ExportToWkt()
|
||||
|
||||
# Skipping all compiled model tests temporarily for feature/plugins
|
||||
pytestmark = pytest.mark.skip(
|
||||
reason="Temporarily ignoring compiled models for feature/plugins")
|
||||
|
||||
class ScenicQualityTests(unittest.TestCase):
|
||||
"""Tests for the InVEST Scenic Quality model."""
|
||||
|
||||
|
|
|
@ -15,10 +15,6 @@ REGRESSION_DATA = os.path.join(
|
|||
os.path.dirname(__file__), '..', 'data', 'invest-test-data', 'sdr')
|
||||
SAMPLE_DATA = os.path.join(REGRESSION_DATA, 'input')
|
||||
|
||||
# Skipping all compiled model tests temporarily for feature/plugins
|
||||
pytestmark = pytest.mark.skip(
|
||||
reason="Temporarily ignoring compiled models for feature/plugins")
|
||||
|
||||
def assert_expected_results_in_vector(expected_results, vector_path):
|
||||
"""Assert one feature vector maps to expected_results key/value pairs."""
|
||||
watershed_results_vector = gdal.OpenEx(vector_path, gdal.OF_VECTOR)
|
||||
|
|
|
@ -17,10 +17,6 @@ REGRESSION_DATA = os.path.join(
|
|||
os.path.dirname(__file__), '..', 'data', 'invest-test-data',
|
||||
'seasonal_water_yield')
|
||||
|
||||
# Skipping all compiled model tests temporarily for feature/plugins
|
||||
pytestmark = pytest.mark.skip(
|
||||
reason="Temporarily ignoring compiled models for feature/plugins")
|
||||
|
||||
def make_simple_shp(base_shp_path, origin):
|
||||
"""Make a 100x100 ogr rectangular geometry shapefile.
|
||||
|
||||
|
|
Loading…
Reference in New Issue