diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e3761e4 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,32 @@ +name: Tests + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.10", "3.11"] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e ".[dev]" + + - name: Run tests + run: | + pytest diff --git a/.gitignore b/.gitignore index 37bb40f..1f8f5d9 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ dist/ venv* docs/.buildinfo docs/.doctrees +_version.py diff --git a/README.md b/README.md index f6e95b8..a817975 100644 --- a/README.md +++ b/README.md @@ -30,26 +30,22 @@ pip install rtdpy ## Issues/Requests/Contributions See [CONTRIBUTING.md](CONTRIBUTING.md) -## Testing -Tests are written using `pytest`. `numpy` and `scipy` must also be installed in the environment if using `pytest` directly. `tox` can also be used to test against Python versions 3.5, 3.6, and 3.7. See [pytest documentation](https://docs.pytest.org/en/latest/) for how to use and interpret pytest results. - +## Development and Testing It is recommended to use a virtual environment for developing/testing. ```bash git clone https://github.com/Merck/rtdpy.git # or use your forked repo cd rtdpy python3 -m venv .venv -source .venv/bin/activate -pip install -e . # will also install numpy and scipy dependencies -pip install pytest tox +source .venv/bin/activate # On Windows: .venv\Scripts\activate +pip install -e ".[dev]" # install package with dev dependencies -# run all tests +# run all tests with coverage pytest - -# run tests and style check for Python versions 3.5, 3.6, and 3.7, if available. -tox ``` +Tests are written using `pytest` and configuration is in `pyproject.toml`. See [pytest documentation](https://docs.pytest.org/en/latest/) for more details. + Author: Matthew Flamm Email: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..6472515 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,106 @@ +[build-system] +requires = ["setuptools>=64", "setuptools_scm>=8"] +build-backend = "setuptools.build_meta" + +[project] +name = "rtdpy" +dynamic = ["version"] +description = "Python package for residence time distribution analysis" +readme = "README.md" +license = {text = "MIT"} +authors = [ + {name = "Matthew Flamm", email = "matthew.flamm@merck.com"} +] +requires-python = ">=3.10" +dependencies = [ + "numpy<1.24", + "scipy<1.14", +] +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "License :: OSI Approved :: MIT License", + "Topic :: Scientific/Engineering", +] + +[project.urls] +Homepage = "https://merck.github.io/rtdpy" +Repository = "https://github.com/Merck/rtdpy" +Documentation = "https://merck.github.io/rtdpy" + +[tool.setuptools_scm] +version_file = "rtdpy/_version.py" + +[tool.setuptools.packages.find] +where = ["."] +include = ["rtdpy*"] + +[project.optional-dependencies] +dev = [ + "numpy==1.23.5", + "scipy==1.13.1", + "pytest>=7.0", + "pytest-cov>=4.0", + "ruff>=0.1.0", +] +docs = [ + "sphinx", + "numpydoc>=1.0.0", + "matplotlib", + "ipython", +] + +[tool.pytest.ini_options] +testpaths = ["tests"] +addopts = [ + "--cov=rtdpy", + "--cov-report=term-missing", + "--cov-report=html", + "--strict-markers", +] +markers = [] + +[tool.coverage.run] +source = ["rtdpy"] +omit = [ + "*/tests/*", + "*/__init__.py", +] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "def __repr__", + "raise AssertionError", + "raise NotImplementedError", + "if __name__ == .__main__.:", + "if TYPE_CHECKING:", +] + +[tool.ruff] +line-length = 89 +target-version = "py310" +exclude = [ + ".git", + ".venv", + "venv", + "__pycache__", + "build", + "dist", +] + +[tool.ruff.lint] +select = [ + "E", # pycodestyle errors + "W", # pycodestyle warnings + "F", # pyflakes + "I", # isort + "B", # flake8-bugbear + "C4", # flake8-comprehensions +] +ignore = [] + +[tool.ruff.lint.per-file-ignores] +"__init__.py" = ["F401"] # Allow unused imports in __init__.py diff --git a/requirements_docs.txt b/requirements_docs.txt deleted file mode 100644 index a9d0716..0000000 --- a/requirements_docs.txt +++ /dev/null @@ -1,7 +0,0 @@ -sphinx -# pin numpydoc due to reference issues in 0.9.x -numpydoc>=1.0.0 -matplotlib -ipython -scipy -numpy diff --git a/rtdpy/__init__.py b/rtdpy/__init__.py index 0f0f796..17b0b48 100644 --- a/rtdpy/__init__.py +++ b/rtdpy/__init__.py @@ -9,4 +9,8 @@ from .ad_hi_peclet import AD_hi_peclet from .convection import Convection from .rtd import RTDInputError, RTD -from .version import __version__ + +try: + from ._version import __version__ +except ImportError: + __version__ = "unknown" diff --git a/rtdpy/version.py b/rtdpy/version.py deleted file mode 100644 index ad703d0..0000000 --- a/rtdpy/version.py +++ /dev/null @@ -1,2 +0,0 @@ -"""Version number.""" -__version__ = '0.6.0' diff --git a/setup.py b/setup.py deleted file mode 100644 index 9b6b162..0000000 --- a/setup.py +++ /dev/null @@ -1,27 +0,0 @@ -from setuptools import setup - -exec(open('rtdpy/version.py').read()) - -with open('README.md', 'r') as fh: - long_description = fh.read() - -setup( - name='rtdpy', - version=__version__, - packages=['rtdpy'], - license='LICENSE', - author='Matthew Flamm', - author_email='matthew.flamm@merck.com', - url='https://merck.github.io/rtdpy', - description='Python package for residence time distribution analysis', - long_description=long_description, - long_description_content_type='text/markdown', - install_requires=['numpy', - 'scipy'], - classifiers=[ - "Development Status :: 4 - Beta", - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Topic :: Scientific/Engineering", - ], -) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 8ed49d6..0000000 --- a/tox.ini +++ /dev/null @@ -1,21 +0,0 @@ -[tox] -envlist = py35,py36,py37,lint - -[testenv] -deps = - pytest - pytest-cov - numpy - scipy -commands = - pytest --cov=rtdpy/ --cov-report=term-missing - -[testenv:lint] -deps = - flake8 -commands = - flake8 rtdpy - -[flake8] -max-line-length = 89 -exclude = rtdpy/__init__.py \ No newline at end of file