From 7bcae32b84afee80325e576b600baf263e2fceae Mon Sep 17 00:00:00 2001 From: Tim Cera Date: Mon, 22 Apr 2024 19:14:50 -0400 Subject: [PATCH 1/3] (feat) change to a pyproject.toml to publish to pypi * Moved metadata from setup.py to pyproject.toml and removed setup.py * Moved README.md to README.rst and rewrote. * Made a VERSION file to contain version number. + Allows version number to be read by pyproject.toml. + Refactored _version.py to read version number from VERSION file. * Made a publish.py to ease and document publishing to pypi. --- README.md | 177 ------------------------------------- README.rst | 233 +++++++++++++++++++++++++++++++++++++++++++++++++ VERSION | 1 + _version.py | 5 +- publish.py | 39 +++++++++ pyproject.toml | 86 ++++++++++++++++++ setup.py | 121 ------------------------- 7 files changed, 363 insertions(+), 299 deletions(-) delete mode 100644 README.md create mode 100644 README.rst create mode 100644 VERSION create mode 100644 publish.py create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/README.md b/README.md deleted file mode 100644 index 55c26951..00000000 --- a/README.md +++ /dev/null @@ -1,177 +0,0 @@ -# Hydrologic Simulation Program - Python (HSP2) - -The **[Hydrologic Simulation Program–Python (HSP2)](https://github.com/respec/HSPsquared)** watershed model is -is a port of the well-established [Hydrological Simulation Program - FORTRAN (HSPF)](https://www.epa.gov/ceam/hydrological-simulation-program-fortran-hspf), re-coded with modern scientific Python and data formats. - -HSP2 (pronouced "HSP-squared") is being developed by an open source team launched and led by RESPEC with internal funding and now in collaboration with LimnoTech and with additional support from the U.S. Army Corps of Engineers, Engineer Research and Development Center (ERDC), Environmental Laboratory. - -HSP2 currently supports all HSPF hydrology and detailed water quality modules. Support for specialty modules is currently in progress. See our [Release Notes](https://github.com/respec/HSPsquared/releases) for up-to-date details. - -Read our wiki for more information on our motivation and goals for HSP2: -- [Wiki Home & HSP2 Goals](https://github.com/respec/HSPsquared/wiki) -- [About-HSPF](https://github.com/respec/HSPsquared/wiki/About-HSPF) -- [Why-HSP2?](https://github.com/respec/HSPsquared/wiki/Why-HSP2%3F) -- [HSP2 Design Details](https://github.com/respec/HSPsquared/wiki/HSP2_Design_Details) - -The [HSPF Conversion Project](https://github.com/respec/HSPsquared/blob/archivePy2/Why%20HSP2%20(EAA).pdf) slides (January 2017) and the [Introduction to HSP2 by Jason Love (RESPEC)](https://www.youtube.com/watch?v=aeLScKsP1Wk) video (December 2017) provide additional background on the [intial release](https://github.com/respec/HSPsquared/releases/tag/0.7.7). - -HSPsquared is released under the [GNU Affero General Public License (AGPL), copyrighted 2017 by RESPEC](https://github.com/respec/HSPsquared/blob/master/LICENSE). - - -## Repository Directories - -- **[HSP2](HSP2)** contains the hydrology and water quality code modules converted from HSPF, along with the main programs to run HSP2. - -- **[HSP2tools](HSP2tools)** contains supporting software modules such as the code to convert legacy WDM and UCI files to HDF5 files for HSP2, and to provide additional new and legacy capabilities. - -- **[HSP2IO](HSP2IO)** is new in v0.10 and contains an abstracted approach to getting data in and out of HSP2 for flexibility and performance and also to support future automation and model coupling. - - NOTE: With v0.10 the I/O abstraction classes provide an alternate approach to running HSP2. Our plan is to migrate solely using the I/O abstracted methods, but we will maintain both approaches for for several more releases for backward compability. - -- **[docs](docs)** contains relevant reference documentation. - -- **[examples](examples)** contains examples of how to use HSP2, organized as interactive Juptyer Notebook tutorials. - -- **[tests](tests)** contains HSPF use cases, their input files, code to compare HSP2 vs HSPF model outputs ([`tests/convert/conversion_test.py`](tests/convert/conversion_test.py)), and code to test for - performance. - - -# Getting Started - -We recommend getting started by: - -1. Following our [HSP2 Installation](#HSP2-Installation) Instructions. - -2. Opening our [interactive HSP2 tutorials](examples) in [JupyterLab](https://jupyterlab.readthedocs.io/en/stable/). - - -# HSP2 Installation - -HSP2 is designed to work with Python 3.7, 3.8, and 3.9. - -We presently **recommend Python 3.8**. - -We provide two options to installing HSP2, yet strongly recommend option 1. -1. [Install Option 1 using `conda`](#install-option-1-using-conda) -2. [Install Option 2 using `pip`](#install-option-2-using-pip) - -Install using only one of these options. - -## Install Option 1 using `conda` - -Follow these steps to install using the [conda](https://docs.conda.io/en/latest/) package manager. - -### 1. Install the Anaconda Python Distribution - -We recommend installing the [latest release](https://docs.anaconda.com/anaconda/reference/release-notes/) of [**Anaconda Individual Edition**](https://www.anaconda.com/distribution), which includes the conda, a complete Python (and R) data science stack, and the helpful Anaconda Navigator GUI. -- Follow [Anaconda Installation](https://docs.anaconda.com/anaconda/install/) documentation. - -A lighter-weight alternative is to install [Miniconda](https://docs.conda.io/en/latest/miniconda.html). - -### 2. Clone or Download this HSPsquared repository - -From the [HSP2squared](https://github.com/respec/HSPsquared) Github page, click on the green "Code" dropdown button near the upper right. Select to either "Open in GitHub Desktop" (i.e. git clone) or "Download ZIP". We recommend using GitHub Desktop, to most easily receive updates. - -Place your copy of the HSPsquared folder in any convenient location on your computer. - -### 3. Create a Conda Environment for HSP2 Modeling (optional) - -Although HSP2 can be run from the default `base` environment created by Anaconda, we recommend creating a custom environment that includes the exact combination of software dependencies that we've in development and testing. - -Create the `hsp2_py38` environment from our [`environment.yml`](environment.yml) file, which lists all primary dependencies, using one of these approaches: -1. Use the **Import** button on [Anaconda Navigator's Environments tab](https://docs.anaconda.com/anaconda/navigator/overview/#environments-tab), or -2. Use the following [`conda create`](https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html#managing-environments) command in your terminal or console, replacing `path/environment.yml` with the full file pathway to the [`environment.yml`](environment.yml) file in the local cloned repository. - - ```shell - conda env create --file path/environment.yml - ``` -To update your environment, either use Anaconda Navigator, or run the following command: - -```shell -conda env update --file path/environment.yml --prune -``` - -or - -```shell -conda env create --file path/environment.yml --force -``` - -NOTE: The [`environment_dev.yml`](environment_dev.yml) file provides an alternate environment that provides additional capabilities and newer libraries useful to the development team. It is tested to also work with the current HSP2 codebase and will likely serve as a preview of future updates to [`environment.yml`](environment.yml). - - -### 4. Add your HSPsquared Path to Anaconda sites-packages - -To have access to the `HSP2`, `HSP2tools`, and `HSP2IO` modules in your Python environments, it is necessary to have a path to your copy of HSPsquared in Anaconda's `sites-packages` directory (i.e. something like `$HOME/path/to/anaconda/lib/pythonX.X/site-packages` or `$HOME/path/to/anaconda/lib/site-packages` similar). - -- The easiest way to do this is to use the [conda develop](https://docs.conda.io/projects/conda-build/en/latest/resources/commands/conda-develop.html) command in the console or terminal like this, replacing `/path/to/module/` with the full file pathway to the local cloned HSPsquared repository: - - ```console - conda-develop /path/to/module/ - ``` - -You should now be able to run the Tutorials and create your own Jupyter Notebooks! - - - -## Install Option 2 using `pip` - -Installing HSP2 using `pip`, the [Package Installer for Python](https://packaging.python.org/en/latest/guides/tool-recommendations/), is an alternative method to installing with `conda`. - -**WARNING**: If you followed [Install Option 1 using `conda`](#install-option-1-using-conda), then DO NOT also install using `pip`. Your install is complete and you can ignore all installatino steps below. - - -### 1. Install Python and Pip - -Instructions for downloading Python to your computer based on your operating system can be found in [this helpful wiki](https://wiki.python.org/moin/BeginnersGuide/Download). - -Check to see if `pip` is installed by running the following in the command line: - -```shell -pip help -``` - -If you get an error, you will need to [install pip](https://pip.pypa.io/en/stable/installation/). Otherwise, both Python and pip are on your machine. - -### 2. Clone or Download this HSPsquared repository - -Follow the instructions - in [Install with Conda Step 2](#clone-or-download-this-hspsquared-repository), above. - - -### 3. Create a Python Environment for HSP2 Modeling (optional) - -We strongly recommend creating custom Python virtual environment for using HSP2, following the [`venv` — Creation of virtual environments](https://docs.python.org/3.9/library/venv.html) package documentation to create and activate a new environment for running HSP2. - -### 4. PIP install HSP2 - -Navigate to your copy of the HSPsquared folder on your computer in the command line. - -To install from the current local directory using pip: - -```shell -pip install . -``` - -### 5. Run HSP2 from the Command Line - -The pip installed 'hsp2' command has help created from the function docstrings in HSP2tools/HSP2_CLI.py. - -Use the help to learn how to use the model and each sub-command: - -```shell -hsp2 --help -``` - -```shell -hsp2 import_uci --help -``` - -```shell -hsp2 run --help -``` - -Intended workflow from the command line: -``` -hsp2 import_uci import_test.uci new_model.h5 -hsp2 run new_model.h5 -``` diff --git a/README.rst b/README.rst new file mode 100644 index 00000000..08350efd --- /dev/null +++ b/README.rst @@ -0,0 +1,233 @@ +Hydrologic Simulation Program - Python (HSP2) +============================================= + +The Hydrologic Simulation Program–Python (HSP2_) watershed model is is a port +of the well-established Hydrological Simulation Program - FORTRAN (HSPF_), +re-coded with modern scientific Python and data formats. + +HSP2 (pronouced "HSP-squared") is being developed by an open source team +launched and led by RESPEC with internal funding. Our list of collaborators is +growing, now including LimnoTech and with additional support from the U.S. Army +Corps of Engineers (Engineer Research and Development Center (ERDC), +Environmental Laboratory), modelers at the Virginia Department of Environmental +Quality, and others. + +HSP2 currently supports all HSPF hydrology and detailed water quality modules. +Support for specialty modules is currently in progress. See our `Release +Notes`_ for up-to-date details. + +Read our wiki for more information on our motivation and goals for HSP2: +- `Wiki Home & HSP2 Goals `_ +- `About-HSPF `_ +- `Why-HSP2? `_ +- `HSP2 Design Details `_ + +The `HSPF Conversion Project`_ slides (January 2017) and the `Introduction to +HSP2 by Jason Love (RESPEC)`_ video (December 2017) provide additional +background on the `initial release`_. + +HSPsquared is released under the `GNU Affero General Public License (AGPL), +copyrighted 2017 by RESPEC`_. + +Source Code Directories +----------------------- + +- **HSP2** contains the hydrology and water quality code modules converted from + HSPF, along with the main programs to run HSP2. + +- **HSP2tools** contains supporting software modules such as the code to + convert legacy WDM and UCI files to HDF5 files for HSP2, and to provide + additional new and legacy capabilities. + +- **HSP2IO** is new in v0.10 and contains an abstracted approach to getting + data in and out of HSP2 for flexibility and performance and also to support + future automation and model coupling. - NOTE: With v0.10 the I/O abstraction + classes provide an alternate approach to running HSP2. Our plan is to migrate + solely using the I/O abstracted methods, but we will maintain both approaches + for for several more releases for backward compatibility. + +- **docs** contains relevant reference documentation. + +- **examples** contains examples of how to use HSP2, organized as interactive + Jupyter Notebook tutorials. + +- **tests** contains HSPF use cases, their input files, code to compare HSP2 vs + HSPF model outputs and code to test for performance. + +Getting Started +=============== +We recommend getting started by: + +1. Following our `HSP2 Installation`_ Instructions. + +2. Opening our interactive JupyterLab_ HSP2 tutorials in the `examples` + sub-directory. + +HSP2 Installation +================= +We **recommend Python 3.10**. + +Install From Pre-built Packages +------------------------------- + +We currently provide a PyPI package for HSP2. + +```console +pip install hsp2 +``` + +Install From Source +------------------- +We provide two options to installing HSP2, yet recommend option 1. + +Install using only one of these options. + +Install Option 1 using "conda" +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Follow these steps to install using the conda_ package manager. + +1. Install the Anaconda Python Distribution ++++++++++++++++++++++++++++++++++++++++++++ +Install the `latest release`_ of the Anaconda Distribution, which includes the +conda package manager, a complete Python (and R) data science stack, and the +Anaconda Navigator GUI. Follow `Anaconda Installation`_ documentation. + +A lighter-weight alternative is to install Miniconda_. + +2. Clone or Download this HSPsquared Repository ++++++++++++++++++++++++++++++++++++++++++++++++ +From the HSP2squared_ Github page, click on the green "Code" drop down button +near the upper right. Select to either "Open in GitHub Desktop" (i.e. git +clone) or "Download ZIP". We recommend using GitHub Desktop, to most easily +receive updates. + +Place your copy of the HSPsquared folder in any convenient location on your +computer. + +3. Create a Conda Environment for HSP2 Modeling (optional) +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +Although HSP2 can be run from the default `base` environment created by +Anaconda, we recommend creating a custom environment that includes the exact +combination of software dependencies that we've in development and testing. + +Use the following `conda create`_ command in your terminal or console, + + ```console + conda create -c conda-forge -n hsp2_310 python=3.10 + ``` + +Install the necessary and optional packages for HSP2 in the new environment: + + ```console + conda install -c conda-forge -n hsp2_310 mando numba pandas pytables + conda install -c conda-forge -n hsp2_310 h5py jupyterlab matplotlib notebook + ``` + +4. Add your HSPsquared Path to Anaconda sites-packages +++++++++++++++++++++++++++++++++++++++++++++++++++++++ +To have access to the `HSP2`, `HSP2tools`, and `HSP2IO` modules in your Python +environments, it is necessary to have a path to your copy of HSPsquared in +Anaconda's `sites-packages` directory (i.e. something like +`$HOME/path/to/anaconda/lib/pythonX.X/site-packages` or +`$HOME/path/to/anaconda/lib/site-packages` similar). + +- The easiest way to do this is to use the `conda develop`_ command in the + console or terminal like this, replacing `/path/to/module/` with the full + file pathway to the local cloned HSPsquared repository: + + ```console + conda activate hsp2_310 + conda-develop /path/to/module/ + ``` + +You should now be able to run the Tutorials and create your own Jupyter +Notebooks! + +Install From Source Code Option 2 Using `pip` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Installing HSP2 using `pip`, the `Package Installer for Python`_ +is an alternative method to installing with `conda`. + +**WARNING**: If you followed `Install Option 1 using "conda"`_, then you should +not also install using `pip`. Your install is complete and you can ignore all +installation steps below. + +1. Install Python ++++++++++++++++++ +Instructions for downloading Python to your computer based on your operating +system can be found in `this helpful wiki`_. + +2. Clone or Download this HSPsquared Repository ++++++++++++++++++++++++++++++++++++++++++++++++ +From the HSP2squared_ Github page, click on the green "Code" drop down button +near the upper right. Select to either "Open in GitHub Desktop" (i.e. git +clone) or "Download ZIP". We recommend using GitHub Desktop, to most easily +receive updates. + +Place your copy of the HSPsquared folder in any convenient location on your +computer. + +3. Create a Python Environment for HSP2 Modeling (optional) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +Create a custom Python virtual environment for using HSP2, following the `venv +— Creation of virtual environments`_ package documentation to create and +activate a new environment for running HSP2. + + ```console + python -m venv hsp2_env /path/to/python/virtual/environments/hsp2_env + ``` + +4. PIP install HSP2 ++++++++++++++++++++ +Navigate to your copy of the HSPsquared folder on your computer in the command +line. + +To install from the current local directory using pip: + + ```console + source /path/to/python/virtual/environments/hsp2_env/bin/activate + pip install . + ``` + +5. Run HSP2 from the Command Line ++++++++++++++++++++++++++++++++++ +The pip installed 'hsp2' command has help created from the function docstrings +in HSP2tools/HSP2_CLI.py. + +Use the help to learn how to use the model and each sub-command: + ```console + hsp2 --help + ``` + + ```console + hsp2 import_uci --help + ``` + + ```console + hsp2 run --help + ``` + +Intended workflow from the command line: + ```console + hsp2 import_uci import_test.uci new_model.h5 + hsp2 run new_model.h5 + ``` + +.. _HSP2: https://github.com/respec/HSPsquared +.. _HSPF: https://www.epa.gov/ceam/hydrological-simulation-program-fortran-hspf +.. _`Release Notes`: https://github.com/respec/HSPsquared/releases +.. _`HSPF Conversion Project`: https://github.com/respec/HSPsquared/blob/archivePy2/Why%20HSP2%20(EAA).pdf +.. _`Introduction to HSP2 by Jason Love (RESPEC)`: https://www.youtube.com/watch?v=aeLScKsP1Wk +.. _`initial release`: https://github.com/respec/HSPsquared/releases/tag/0.7.7 +.. _`GNU Affero General Public License (AGPL), copyrighted 2017 by RESPEC`: https://github.com/respec/HSPsquared/blob/master/LICENSE +.. _JupyterLab: https://jupyterlab.readthedocs.io/en/stable/ +.. _conda: https://docs.conda.io/en/latest/ +.. _`latest release`: https://docs.anaconda.com/anaconda/reference/release-notes/ +.. _`Anaconda Installation`: https://docs.anaconda.com/anaconda/install/ +.. _Miniconda: https://docs.conda.io/en/latest/miniconda.html +.. _HSP2squared: https://github.com/respec/HSPsquared +.. _`conda create`: https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html#managing-environments +.. _`conda develop`: https://docs.conda.io/projects/conda-build/en/latest/resources/commands/conda-develop.html +.. _`Package Installer for Python`: https://packaging.python.org/en/latest/guides/tool-recommendations/ +.. _`this helpful wiki`: https://wiki.python.org/moin/BeginnersGuide/Download +.. _`venv — Creation of virtual environments`: https://docs.python.org/3.9/library/venv.html diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..e0cbcd58 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.11.0a1 diff --git a/_version.py b/_version.py index f323a57b..2fb6788e 100644 --- a/_version.py +++ b/_version.py @@ -1 +1,4 @@ -__version__ = '0.11.0' +import os + +with open(os.path.join(os.path.dirname(__file__), "VERSION"), encoding="ascii") as version_file: + __version__ = version_file.read().strip() diff --git a/publish.py b/publish.py new file mode 100644 index 00000000..96685304 --- /dev/null +++ b/publish.py @@ -0,0 +1,39 @@ +""" +Publish package to PyPI. + +This script is used to publish the package to PyPI. It is a simple script that +uses the `build` module to create the source distribution and wheel, and then +uses `twine` to upload the package to PyPI. + +Need to install the following packages: +- build (if using PyPI), python-build (if using conda-forge) +- twine +""" + +import shlex +import shutil +import subprocess + +PKG_NAME = "hsp2" + +with open("VERSION", encoding="ascii") as version_file: + version = version_file.readline().strip() + +shutil.rmtree("build", ignore_errors=True) + +subprocess.run(shlex.split("python3 -m build --sdist"), check=True) +subprocess.run(shlex.split("python3 -m build --wheel"), check=True) +sdist = f"dist/{PKG_NAME}-{version}.tar.gz" +wheel = f"dist/{PKG_NAME}-{version}*.whl" + +for file in [sdist, wheel]: + subprocess.run( + shlex.split(f"twine check {file}"), + check=True, + ) + subprocess.run( + shlex.split(f"twine upload --skip-existing {file}"), + check=True, + ) + +shutil.rmtree("build", ignore_errors=True) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..ccb512b6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,86 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = [ + "setuptools>=45", + "setuptools_scm[toml]>=6.2", + "wheel", + "oldest-supported-numpy" +] + +[project] +name = "hsp2" +dynamic = ["version", "readme"] +description = "Hydrological Simulation Program - Python" +dependencies = [ + "mando", + "numba", + "pandas", + "tables" +] +authors = [ + {name = "RESPEC, Inc", email = "Paul.Duda@respec.com"} +] +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Science/Research", + "Intended Audience :: End Users/Desktop", + "Intended Audience :: Developers", + "Environment :: Console", + "License :: OSI Approved :: GNU Affero General Public License v3", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Scientific/Engineering", + "Topic :: Software Development :: Libraries :: Python Modules" +] +keywords = [ + "hydrology", + "hydrological", + "hydraulic", + "hspf", + "simulation", + "python", +] +license = {file = "LICENSE"} +requires-python = ">=3.10" + +[project.scripts] +hsp2 = "HSP2tools.HSP2_CLI:main" + +[project.urls] +documentation = "http://www.respec.com/product/hydrologic-simulation-program-python-hsp%C2%B2/" +github = "https://github.com/respec/HSPsquared" + +[tool.check-manifest] +ignore = [ + "docs/_function_autosummary/*", + ".coverage", + ".deepsource.toml", + ".ipynb_checkpoints/*" +] + +[tool.commitizen] +name = "cz_conventional_commits" +tag_format = "v$version" +update_changelog_on_bump = true +version = "0.11.0a1" +version_files = ["VERSION"] + +[tool.isort] +profile = "black" + +[tool.setuptools] +license-files = ["LICENSE"] +include-package-data = true + +[tool.setuptools.dynamic] +readme = {file = "README.rst"} +version = {file = "VERSION"} + +[tool.setuptools.packages.find] +exclude = ["tests*", "examples*", "tools*", "docs*"] +where = ["HSP2", "HSP2tools", "HSP2IO"] + +[tool.setuptools_scm] diff --git a/setup.py b/setup.py deleted file mode 100644 index 41727de5..00000000 --- a/setup.py +++ /dev/null @@ -1,121 +0,0 @@ -import os -import re -import shlex -import sys - -from setuptools import setup - -exec(open("./_version.py").read()) - -if sys.argv[-1] == "publish": - os.system(shlex.quote("cleanpy .")) - os.system(shlex.quote("python setup.py sdist")) - os.system(shlex.quote(f"twine upload dist/HSPsquared-{__version__}.tar.gz")) - sys.exit() - -README = open("./README.md").read() - -pypi_map = {"jupyter-lsp-python": "python-lsp-server[all]"} - - -def process_env_yaml(fname, dev=False): - yaml_lines = [] - with open("environment.yml") as fp: - collect = False - for line in fp.readlines(): - # Handle comments - line = line.split("#")[0].rstrip() - - # Handle blank lines - if not line.strip(): - continue - - line = line.strip(" -").replace(" ", "") - - if collect is True: - words = re.split("=|<|>", line) - # Shouldn't have interactivity, development tools, conda, pip, - # or python as a dependency. - if dev is True: - if words[0] in [ - "conda", - "conda-build", - "hdf5", - "nb_conda" "pip", - "python", - "pip:", - ]: - continue - else: - if words[0] in [ - "jupyterlab", - "ipywidgets", - "matplotlib", - "conda", - "conda-build", - "pip", - "python", - "lckr-jupyterlab-variableinspector", - "jupyter-lsp-python", - "jupyterlab-lsp", - "pip:", - "hdf5", - "nb_conda", - ]: - continue - - # On PyPI pytables is tables. - if words[0] == "pytables": - line = line.replace("pytables", "tables") - - yaml_lines.append(line) - - if line.rstrip() == "dependencies:": - collect = True - yaml_lines = [pypi_map.get(i, i) for i in yaml_lines] - return yaml_lines - - -install_requires = process_env_yaml("environment.yml") - -extras_require = { - "dev": process_env_yaml("environment_dev.yml", dev=True) + ["cleanpy", "twine"] -} - -setup( - name="hsp2", - version=__version__, - description="Hydrological Simulation Program - Python", - long_description=README, - classifiers=[ - # Get strings from - # http://pypi.python.org/pypi?%3Aaction=list_classifiers - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Science/Research", - "Intended Audience :: End Users/Desktop", - "Intended Audience :: Developers", - "Environment :: Console", - "License :: OSI Approved :: GNU Affero General Public License v3", - "Natural Language :: English", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Topic :: Scientific/Engineering", - "Topic :: Software Development :: Libraries :: Python Modules", - ], - keywords="hydrology hydrological hydraulic hspf", - author="RESPEC, Inc", - author_email="", - url="http://www.respec.com/product/hydrologic-simulation-program-python-hsp%C2%B2/", - packages=["HSP2", "HSP2tools", "HSP2IO"], - py_modules=["_version"], - include_package_data=True, - package_data={"HSP2tools": ["data/*"]}, - zip_safe=False, - install_requires=install_requires, - extras_require=extras_require, - entry_points={"console_scripts": ["hsp2=HSP2tools.HSP2_CLI:main"]}, - test_suite="tests", - python_requires=">3.6", -) From 43af3bcc7c9032ab84add90d1eac1a652b294a7d Mon Sep 17 00:00:00 2001 From: Tim Cera Date: Mon, 22 Apr 2024 20:35:07 -0400 Subject: [PATCH 2/3] (ci) update github workflows to work with pyproject.toml. --- .github/workflows/hsp2-conda-install-test-dev.yml | 7 ++++--- .github/workflows/hsp2-pip-install-test-dev.yml | 9 +++++---- .github/workflows/hsp2-pip-install-test.yml | 10 +++++----- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/hsp2-conda-install-test-dev.yml b/.github/workflows/hsp2-conda-install-test-dev.yml index 4749103b..4c6e299c 100644 --- a/.github/workflows/hsp2-conda-install-test-dev.yml +++ b/.github/workflows/hsp2-conda-install-test-dev.yml @@ -1,5 +1,5 @@ name: Python conda dev application -# this is a standard setup copied from +# this is a standard setup copied from # https://docs.github.com/en/enterprise-server@3.10/actions/automating-builds-and-tests/building-and-testing-python on: push: @@ -22,7 +22,8 @@ jobs: python-version: "3.11" - name: Install dependencies run: | - $CONDA/bin/conda env update --file environment_dev.yml --name base + $CONDA/bin/conda env update --name base + $CONDA/bin/conda install -c conda-forge --name base mando numba pandas pytables $CONDA/bin/conda install flake8 - name: Install hsp2 run: | @@ -34,7 +35,7 @@ jobs: $CONDA/bin/flake8 . --count --select=E9,F63,F7,F82 --ignore=F821 --show-source --statistics --exclude=HSP2/ACIDPH.py,build/lib/HSP2/ACIDPH.py # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide $CONDA/bin/flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest + - name: Test with pytest run: | $CONDA/bin/conda install pytest $CONDA/bin/pytest tests/ptest/test_sysexit.py diff --git a/.github/workflows/hsp2-pip-install-test-dev.yml b/.github/workflows/hsp2-pip-install-test-dev.yml index 1d3ec89a..5729bc1e 100644 --- a/.github/workflows/hsp2-pip-install-test-dev.yml +++ b/.github/workflows/hsp2-pip-install-test-dev.yml @@ -1,5 +1,5 @@ name: Python dev application -# this is a standard setup copied from +# this is a standard setup copied from # https://docs.github.com/en/enterprise-server@3.10/actions/automating-builds-and-tests/building-and-testing-python on: push: @@ -23,19 +23,20 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install build pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + pip install mando numba pandas tables - name: Install hsp2 run: | # install the hsp2 executable using dev environment - sudo pip install -e .[dev] + sudo pip install .[dev] - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --ignore=F821 --show-source --statistics --exclude=HSP2/ACIDPH.py,build/lib/HSP2/ACIDPH.py # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest + - name: Test with pytest run: | pytest tests/ptest/test_sysexit.py # Add more tests here. Example (note, benchmark takes a long time to run and could crush the free monthly 2,000 minutes during times of high activity) diff --git a/.github/workflows/hsp2-pip-install-test.yml b/.github/workflows/hsp2-pip-install-test.yml index d0ced94e..f7f283c2 100644 --- a/.github/workflows/hsp2-pip-install-test.yml +++ b/.github/workflows/hsp2-pip-install-test.yml @@ -1,5 +1,5 @@ name: Python application -# this is a standard setup copied from +# this is a standard setup copied from # https://docs.github.com/en/enterprise-server@3.10/actions/automating-builds-and-tests/building-and-testing-python on: push: @@ -16,15 +16,15 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python 3.8 + - name: Set up Python 3.10 uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.10" - name: Install dependencies run: | python -m pip install --upgrade pip pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + pip install mando numba pandas tables - name: Install hsp2 run: | # install the hsp2 executable @@ -35,7 +35,7 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --ignore=F821 --show-source --statistics --exclude=HSP2/ACIDPH.py,build/lib/HSP2/ACIDPH.py # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest + - name: Test with pytest run: | pytest tests/ptest/test_sysexit.py # add additional test, ex: From 1dca5ba14c35abf9440ee63e978bd0a37ba88b0d Mon Sep 17 00:00:00 2001 From: Tim Cera Date: Mon, 22 Apr 2024 22:43:53 -0400 Subject: [PATCH 3/3] (fix) replaced mando with cltoolbox mando used old import locations for Collections. --- HSP2tools/HSP2_CLI.py | 8 ++++---- README.rst | 2 +- pyproject.toml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/HSP2tools/HSP2_CLI.py b/HSP2tools/HSP2_CLI.py index fb4bae6e..4d1d94e6 100644 --- a/HSP2tools/HSP2_CLI.py +++ b/HSP2tools/HSP2_CLI.py @@ -1,4 +1,4 @@ -import mando +import cltoolbox from HSP2.main import main as hsp2main from HSP2tools.readUCI import readUCI @@ -7,7 +7,7 @@ from HSP2IO.io import IOManager -@mando.command(doctype="numpy") +@cltoolbox.command() def run(hdfname, saveall=True, jupyterlab=False): """Run a HSPsquared model. @@ -26,7 +26,7 @@ def run(hdfname, saveall=True, jupyterlab=False): hsp2main(io_manager, saveall=saveall, jupyterlab=jupyterlab) -@mando.command(doctype="numpy") +@cltoolbox.command() def import_uci(ucifile, h5file): """Import UCI and WDM files into HDF5 file. @@ -57,7 +57,7 @@ def import_uci(ucifile, h5file): def main(): - mando.main() + cltoolbox.main() if __name__ == "__main__": diff --git a/README.rst b/README.rst index 08350efd..d2cdf9d0 100644 --- a/README.rst +++ b/README.rst @@ -119,7 +119,7 @@ Use the following `conda create`_ command in your terminal or console, Install the necessary and optional packages for HSP2 in the new environment: ```console - conda install -c conda-forge -n hsp2_310 mando numba pandas pytables + conda install -c conda-forge -n hsp2_310 cltoolbox numba pandas pytables conda install -c conda-forge -n hsp2_310 h5py jupyterlab matplotlib notebook ``` diff --git a/pyproject.toml b/pyproject.toml index ccb512b6..01326ec9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ name = "hsp2" dynamic = ["version", "readme"] description = "Hydrological Simulation Program - Python" dependencies = [ - "mando", + "cltoolbox", "numba", "pandas", "tables"