From 76fba379e85f74c98a14284e7bccc5b074ca227b Mon Sep 17 00:00:00 2001 From: s-weigand Date: Fri, 15 Sep 2023 15:54:26 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=E2=99=BB=EF=B8=8F=20Use=20hatch=20?= =?UTF-8?q?as=20build=20backend=20(#204)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [Hatch](https://github.com/pypa/hatch) is the new modern python build system which out of the box comes with a package-aware venv setup system (`hatch shell` will set up the dev env). The package is fully configured via `pyproject.toml` eliminating the need for husk only `setup.py` and the `setup.cfg` which were needed for the old `setuptools` way of installing. One of the main advantages of this change is that `hatch` by default uses `.pth` files for editable installs which [are needed for proper static analysis and auto-completion by tools like pylance](https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#common-questions-and-issues) (vscode). While there is a [workaround for `setuptools`](https://setuptools.pypa.io/en/latest/userguide/development_mode.html#legacy-behavior) (`pip install -e . --config-settings editable_mode=compat`) that workaround is due to deprecation, so it is best to switch now. During this refactoring of the build system the documentation file format was changed from `reStructuredText` to [myst parser](https://myst-parser.readthedocs.io/en/latest/) flavored markdown using [`rst2myst`](https://rst-to-myst.readthedocs.io/en/latest/). This gives us the full `rst` power as opt-in without needing to always deal `rst`. **Note:** For the development of `pyglotaran` **AND** `pyglotaran-extras` at the same time (side by side), one should still use a common environment (e.g. conda env) with `pip install -e .` instead of `hatch shell`. But `hatch shell` is a convenient way to develop against the latest stable version of `pyglotaran` without creating a dedicated global env. ### Change summary - [๐Ÿ‘ท Use hatch as build backend](https://github.com/glotaran/pyglotaran-extras/commit/f117a4366a81fecb2086e2410dc2abaf49c65914) - [๐Ÿงน Cleanup old installation residuals](https://github.com/glotaran/pyglotaran-extras/commit/5107828c396c315c9759d6c1be9c29eb82b3458f) - [๐Ÿ“š๐Ÿ‘Œ Convert docs from RST to MD](https://github.com/glotaran/pyglotaran-extras/commit/eca6588523d9618088347de952d675bbe332d8b5) --- .../autoupdate-pre-commit-config.yml | 2 + .github/workflows/integration-tests.yml | 4 + .github/workflows/test.yml | 58 +++++---- .pre-commit-config.yaml | 8 +- .taplo.toml | 3 + CONTRIBUTING.md | 122 ++++++++++++++++++ CONTRIBUTING.rst | 116 ----------------- MANIFEST.in | 2 - Makefile | 5 +- binder/environment.yml | 4 +- docs/api_docs.md | 11 ++ docs/api_docs.rst | 11 -- docs/conf.py | 2 +- docs/contributing.md | 3 + docs/contributing.rst | 1 - docs/index.md | 19 +++ docs/index.rst | 20 --- docs/installation.md | 45 +++++++ docs/installation.rst | 51 -------- docs/requirements.txt | 16 --- docs/usage.md | 7 + docs/usage.rst | 7 - pyglotaran_extras/plotting/utils.py | 3 +- pyproject.toml | 111 +++++++++++++--- readthedocs.yml | 4 +- requirements_dev.txt | 27 ---- requirements_pinned.txt | 8 ++ setup.cfg | 51 -------- setup.py | 3 - tox.ini | 2 +- 30 files changed, 365 insertions(+), 361 deletions(-) create mode 100644 .taplo.toml create mode 100644 CONTRIBUTING.md delete mode 100644 CONTRIBUTING.rst create mode 100644 docs/api_docs.md delete mode 100644 docs/api_docs.rst create mode 100644 docs/contributing.md delete mode 100644 docs/contributing.rst create mode 100644 docs/index.md delete mode 100644 docs/index.rst create mode 100644 docs/installation.md delete mode 100644 docs/installation.rst delete mode 100644 docs/requirements.txt create mode 100644 docs/usage.md delete mode 100644 docs/usage.rst delete mode 100644 requirements_dev.txt create mode 100644 requirements_pinned.txt delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.github/workflows/autoupdate-pre-commit-config.yml b/.github/workflows/autoupdate-pre-commit-config.yml index da3dcea..27ab8e4 100644 --- a/.github/workflows/autoupdate-pre-commit-config.yml +++ b/.github/workflows/autoupdate-pre-commit-config.yml @@ -17,10 +17,12 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.10" + - uses: actions/cache@v3 with: path: ~/.cache/pre-commit key: pre-commit-autoupdate + - name: Update pre-commit config packages uses: technote-space/create-pr-action@v2 with: diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 30ded0f..5b4734e 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -32,20 +32,24 @@ jobs: example_name: ${{fromJson(needs.create-example-list.outputs.example-list)}} steps: - uses: actions/checkout@v4 + - name: Set up Python 3.10 uses: actions/setup-python@v4 with: python-version: "3.10" + - name: Install pyglotaran-extras run: | pip install wheel pip install . + - name: ${{ matrix.example_name }} id: example-run uses: glotaran/pyglotaran-examples@main with: example_name: ${{ matrix.example_name }} install_extras: false + - name: Upload Example Plots Artifact uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b293ff8..5e200fd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,10 +17,12 @@ jobs: steps: - name: Check out repo uses: actions/checkout@v4 + - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.10" + - name: Run pre-commit uses: pre-commit/action@v3.0.0 @@ -30,24 +32,27 @@ jobs: steps: - name: Check out repo uses: actions/checkout@v4 + - name: Setup conda uses: s-weigand/setup-conda@v1 with: conda-channels: conda-forge activate-conda: false + - name: Set up Python 3.10 uses: actions/setup-python@v4 with: python-version: "3.10" + - name: Install dependencies run: | conda install -y pandoc python -m pip install -U pip wheel - pip install . - python -m pip install -U -r docs/requirements.txt + python -m pip install ".[docs]" + - name: Show installed dependencies - run: | - pip freeze + run: pip freeze + - name: Build docs run: make --directory=docs clean html @@ -57,24 +62,27 @@ jobs: steps: - name: Check out repo uses: actions/checkout@v4 + - name: Setup conda uses: s-weigand/setup-conda@v1 with: conda-channels: conda-forge activate-conda: false + - name: Set up Python 3.10 uses: actions/setup-python@v4 with: python-version: "3.10" + - name: Install dependencies run: | conda install -y pandoc python -m pip install -U pip wheel - pip install . - python -m pip install -U -r docs/requirements.txt + python -m pip install ".[docs]" + - name: Show installed dependencies - run: | - pip freeze + run: pip freeze + - name: Build docs run: make --directory=docs clean linkcheck @@ -90,18 +98,21 @@ jobs: steps: - name: Check out repo uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + - name: Install dependencies run: | python -m pip install -U pip wheel - python -m pip install -U -e . - python -m pip install -r requirements_dev.txt + python -m pip install -r requirements_pinned.txt + python -m pip install -U -e ".[test]" + - name: Run tests - run: | - py.test --nbval --cov=./ --cov-report term --cov-report xml --cov-config pyproject.toml tests + run: python -m pytest --nbval --cov=./ --cov-report term --cov-report xml --cov-config pyproject.toml tests + - name: Codecov Upload continue-on-error: true uses: codecov/codecov-action@v3 @@ -117,22 +128,24 @@ jobs: steps: - name: Check out repo uses: actions/checkout@v4 + - name: Set up Python 3.10 uses: actions/setup-python@v4 with: python-version: "3.10" + - name: Install dependencies run: | python -m pip install -U pip wheel - python -m pip install -U -e . - python -m pip install -r requirements_dev.txt + python -m pip install -r requirements_pinned.txt + python -m pip install -U -e ".[test]" python -m pip install git+https://github.com/glotaran/pyglotaran + - name: Show installed dependencies - run: | - pip freeze + run: pip freeze + - name: Run tests - run: | - py.test --nbval --cov=./ --cov-report term --cov-report xml --cov-config pyproject.toml tests + run: python -m pytest --nbval --cov=./ --cov-report term --cov-report xml --cov-config pyproject.toml tests deploy: name: Deploy to PyPi @@ -141,16 +154,17 @@ jobs: needs: test steps: - uses: actions/checkout@v4 + - name: Set up Python 3.10 uses: actions/setup-python@v4 with: python-version: "3.10" + - name: Install dependencies - run: | - python -m pip install -U pip wheel + run: python -m pip install -U hatch + - name: Build dist - run: | - python setup.py sdist bdist_wheel + run: hatch build - name: Publish package uses: pypa/gh-action-pypi-publish@v1.8.10 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 72d3349..da55253 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,11 +44,6 @@ repos: - id: isort minimum_pre_commit_version: 2.9.0 - - repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.4.0 - hooks: - - id: setup-cfg-fmt - - repo: https://github.com/pre-commit/mirrors-prettier rev: v3.0.3 # Use the sha or tag you want to point at hooks: @@ -112,7 +107,7 @@ repos: - "--allow-init-docstring=True" - "--skip-checking-short-docstrings=False" name: "flake8 lint docstrings" - exclude: "^(docs/|setup.py$|tests?/)" + exclude: "^(docs/|tests?/)" additional_dependencies: [pydoclint==0.1.4] - repo: https://github.com/rstcheck/rstcheck @@ -121,6 +116,7 @@ repos: - id: rstcheck additional_dependencies: [sphinx] exclude: "^docs/_templates" + args: [--ignore-directives=autosummary] - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.10.0 diff --git a/.taplo.toml b/.taplo.toml new file mode 100644 index 0000000..34a42ca --- /dev/null +++ b/.taplo.toml @@ -0,0 +1,3 @@ +[formatting] +align_comments = false +array_auto_collapse = false diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..cb298f1 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,122 @@ +```{highlight} shell + +``` + +# Contributing + +Contributions are welcome, and they are greatly appreciated! Every little bit +helps, and credit will always be given. + +You can contribute in many ways: + +## Types of Contributions + +### Report Bugs + +Report bugs at . + +If you are reporting a bug, please include: + +- Your operating system name and version. +- Any details about your local setup that might be helpful in troubleshooting. +- Detailed steps to reproduce the bug. + +### Fix Bugs + +Look through the GitHub issues for bugs. Anything tagged with "bug" and "help +wanted" is open to whoever wants to implement it. + +### Implement Features + +Look through the GitHub issues for features. Anything tagged with "enhancement" +and "help wanted" is open to whoever wants to implement it. + +### Write Documentation + +pyglotaran_extras could always use more documentation, whether as part of the +official pyglotaran_extras docs, in docstrings, or even on the web in blog posts, +articles, and such. + +### Submit Feedback + +The best way to send feedback is to file an issue at . + +If you are proposing a feature: + +- Explain in detail how it would work. +- Keep the scope as narrow as possible, to make it easier to implement. +- Remember that this is a volunteer-driven project, and that contributions + are welcome :) + +## Get Started! + +Ready to contribute? Here's how to set up `pyglotaran_extras` for local development. + +1. Fork the `pyglotaran-extras` repo on GitHub. + +2. Clone your fork locally: + + ``` + $ git clone git@github.com:your_name_here/pyglotaran_extras.git + ``` + +3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development: + + ``` + $ mkvirtualenv pyglotaran_extras + $ cd pyglotaran-extras/ + $ pip install -e . + ``` + +4. install the `pre-commit` and `pre-push` hooks: + + ``` + $ pre-commit install && pre-commit install -t pre-push + ``` + +5. Create a branch for local development: + + ``` + $ git checkout -b name-of-your-bugfix-or-feature + ``` + + Now you can make your changes locally. + +6. When you're done making changes, check that your changes pass flake8 and the + tests, including testing other Python versions with tox: + + ``` + $ tox + ``` + + To get flake8 and tox, just pip install them into your virtualenv. + +7. Commit your changes and push your branch to GitHub: + + ``` + $ git add . + $ git commit -m "Your detailed description of your changes." + $ git push origin name-of-your-bugfix-or-feature + ``` + +8. Submit a pull request through the GitHub website. + +## Pull Request Guidelines + +Before you submit a pull request, check that it meets these guidelines: + +1. The pull request should include tests. +2. If the pull request adds functionality, the docs should be updated. Put + your new functionality into a function with a docstring, and add the + feature to the list in README.md. +3. The pull request should work for Python 3.10 and 3.11. Check + + and make sure that the tests pass for all supported Python versions. + +## Tips + +To run a subset of tests: + +``` +$ pytest tests.test_pyglotaran_extras +``` diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst deleted file mode 100644 index df56b4f..0000000 --- a/CONTRIBUTING.rst +++ /dev/null @@ -1,116 +0,0 @@ -.. highlight:: shell - -============ -Contributing -============ - -Contributions are welcome, and they are greatly appreciated! Every little bit -helps, and credit will always be given. - -You can contribute in many ways: - -Types of Contributions ----------------------- - -Report Bugs -~~~~~~~~~~~ - -Report bugs at https://github.com/glotaran/pyglotaran-extras/issues. - -If you are reporting a bug, please include: - -* Your operating system name and version. -* Any details about your local setup that might be helpful in troubleshooting. -* Detailed steps to reproduce the bug. - -Fix Bugs -~~~~~~~~ - -Look through the GitHub issues for bugs. Anything tagged with "bug" and "help -wanted" is open to whoever wants to implement it. - -Implement Features -~~~~~~~~~~~~~~~~~~ - -Look through the GitHub issues for features. Anything tagged with "enhancement" -and "help wanted" is open to whoever wants to implement it. - -Write Documentation -~~~~~~~~~~~~~~~~~~~ - -pyglotaran_extras could always use more documentation, whether as part of the -official pyglotaran_extras docs, in docstrings, or even on the web in blog posts, -articles, and such. - -Submit Feedback -~~~~~~~~~~~~~~~ - -The best way to send feedback is to file an issue at https://github.com/glotaran/pyglotaran-extras/issues. - -If you are proposing a feature: - -* Explain in detail how it would work. -* Keep the scope as narrow as possible, to make it easier to implement. -* Remember that this is a volunteer-driven project, and that contributions - are welcome :) - -Get Started! ------------- - -Ready to contribute? Here's how to set up ``pyglotaran_extras`` for local development. - -1. Fork the ``pyglotaran-extras`` repo on GitHub. -2. Clone your fork locally:: - - $ git clone git@github.com:your_name_here/pyglotaran_extras.git - -3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: - - $ mkvirtualenv pyglotaran_extras - $ cd pyglotaran-extras/ - $ pip install -e . - -4. install the ``pre-commit`` and ``pre-push`` hooks:: - - $ pre-commit install && pre-commit install -t pre-push - -5. Create a branch for local development:: - - $ git checkout -b name-of-your-bugfix-or-feature - - Now you can make your changes locally. - -6. When you're done making changes, check that your changes pass flake8 and the - tests, including testing other Python versions with tox:: - - $ tox - - To get flake8 and tox, just pip install them into your virtualenv. - -7. Commit your changes and push your branch to GitHub:: - - $ git add . - $ git commit -m "Your detailed description of your changes." - $ git push origin name-of-your-bugfix-or-feature - -8. Submit a pull request through the GitHub website. - -Pull Request Guidelines ------------------------ - -Before you submit a pull request, check that it meets these guidelines: - -1. The pull request should include tests. -2. If the pull request adds functionality, the docs should be updated. Put - your new functionality into a function with a docstring, and add the - feature to the list in README.md. -3. The pull request should work for Python 3.8 and 3.9. Check - https://github.com/glotaran/pyglotaran-extras/actions - and make sure that the tests pass for all supported Python versions. - -Tips ----- - -To run a subset of tests:: - - $ pytest tests.test_pyglotaran_extras diff --git a/MANIFEST.in b/MANIFEST.in index 6e3b857..d221ff3 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,8 +2,6 @@ include CONTRIBUTING.rst include HISTORY.md include LICENSE include README.md -include setup.cfg -include setup.py recursive-include pyglotaran_extras * recursive-include tests * diff --git a/Makefile b/Makefile index 470e9f7..e231f5e 100644 --- a/Makefile +++ b/Makefile @@ -80,9 +80,8 @@ release: dist ## package and upload a release twine upload dist/* dist: clean ## builds source and wheel package - python setup.py sdist - python setup.py bdist_wheel + hatch build ls -l dist install: clean ## install the package to the active Python's site-packages - python setup.py install + pip install . diff --git a/binder/environment.yml b/binder/environment.yml index 8032cae..22896dc 100644 --- a/binder/environment.yml +++ b/binder/environment.yml @@ -10,5 +10,5 @@ dependencies: # update outdated repo2docker version - pip - pip: - - -r ../requirements_dev.txt - - .. + - -r ../requirements_pinned.txt + - ..[] diff --git a/docs/api_docs.md b/docs/api_docs.md new file mode 100644 index 0000000..36a869b --- /dev/null +++ b/docs/api_docs.md @@ -0,0 +1,11 @@ +# Inner workings + +This is the detailed documentation of the inner workings of `pyglotaran_extras`. + +```{eval-rst} +.. autosummary:: + :toctree: api + :recursive: + + pyglotaran_extras +``` diff --git a/docs/api_docs.rst b/docs/api_docs.rst deleted file mode 100644 index 97be837..0000000 --- a/docs/api_docs.rst +++ /dev/null @@ -1,11 +0,0 @@ -============== -Inner workings -============== - -This is the detailed documentation of the inner workings of ``pyglotaran_extras``. - -.. autosummary:: - :toctree: api - :recursive: - - pyglotaran_extras diff --git a/docs/conf.py b/docs/conf.py index 7e4a610..e2ec91e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -78,7 +78,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = "en" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. diff --git a/docs/contributing.md b/docs/contributing.md new file mode 100644 index 0000000..66c1f98 --- /dev/null +++ b/docs/contributing.md @@ -0,0 +1,3 @@ +```{include} ../CONTRIBUTING.md + +``` diff --git a/docs/contributing.rst b/docs/contributing.rst deleted file mode 100644 index e582053..0000000 --- a/docs/contributing.rst +++ /dev/null @@ -1 +0,0 @@ -.. include:: ../CONTRIBUTING.rst diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..9ee9fd8 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,19 @@ +# Welcome to pyglotaran_extras's documentation! + +```{toctree} +:caption: 'Contents:' +:maxdepth: 2 + +readme +installation +usage +api_docs +contributing +changelog +``` + +## Indices and tables + +- {ref}`genindex` +- {ref}`modindex` +- {ref}`search` diff --git a/docs/index.rst b/docs/index.rst deleted file mode 100644 index 115fa9d..0000000 --- a/docs/index.rst +++ /dev/null @@ -1,20 +0,0 @@ -============================================= -Welcome to pyglotaran_extras's documentation! -============================================= - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - - readme - installation - usage - api_docs - contributing - changelog - -Indices and tables -================== -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 0000000..25eb13c --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,45 @@ +```{highlight} shell + +``` + +# Installation + +## Stable release + +To install pyglotaran_extras, run this command in your terminal: + +```console +$ pip install pyglotaran_extras +``` + +This is the preferred method to install pyglotaran_extras, as it will always install the most recent stable release. + +If you don't have [pip] installed, this [Python installation guide] can guide +you through the process. + +## From sources + +The sources for pyglotaran_extras can be downloaded from the [Github repo]. + +You can either clone the public repository: + +```console +$ git clone git://github.com/glotaran/pyglotaran-extras +``` + +Or download the [tarball]: + +```console +$ curl -OJL https://github.com/glotaran/pyglotaran-extras/tarball/main +``` + +Once you have a copy of the source, you can install it with: + +```console +$ pip install . +``` + +[github repo]: https://github.com/glotaran/pyglotaran-extras +[pip]: https://pip.pypa.io +[python installation guide]: http://docs.python-guide.org/en/latest/starting/installation/ +[tarball]: https://github.com/glotaran/pyglotaran-extras/tarball/main diff --git a/docs/installation.rst b/docs/installation.rst deleted file mode 100644 index a4a4dc9..0000000 --- a/docs/installation.rst +++ /dev/null @@ -1,51 +0,0 @@ -.. highlight:: shell - -============ -Installation -============ - - -Stable release --------------- - -To install pyglotaran_extras, run this command in your terminal: - -.. code-block:: console - - $ pip install pyglotaran_extras - -This is the preferred method to install pyglotaran_extras, as it will always install the most recent stable release. - -If you don't have `pip`_ installed, this `Python installation guide`_ can guide -you through the process. - -.. _pip: https://pip.pypa.io -.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ - - -From sources ------------- - -The sources for pyglotaran_extras can be downloaded from the `Github repo`_. - -You can either clone the public repository: - -.. code-block:: console - - $ git clone git://github.com/glotaran/pyglotaran-extras - -Or download the `tarball`_: - -.. code-block:: console - - $ curl -OJL https://github.com/glotaran/pyglotaran-extras/tarball/main - -Once you have a copy of the source, you can install it with: - -.. code-block:: console - - $ python setup.py install - - -.. _Github repo: https://github.com/glotaran/pyglotaran-extras -.. _tarball: https://github.com/glotaran/pyglotaran-extras/tarball/main diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 98febee..0000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,16 +0,0 @@ -# documentation dependencies -Sphinx>=3.2.0 -myst-parser>=0.12.0 -sphinx-rtd-theme>=1.2.0 -# Needed for the search to work -# Ref.: https://github.com/readthedocs/sphinx_rtd_theme/issues/1434 -sphinxcontrib-jquery>=4.1 -sphinx-copybutton>=0.3.0 -numpydoc>=0.8.0 -# notebook docs -nbsphinx>=0.8.1 -sphinx-last-updated-by-git>=0.3.0 -jupyterlab>=3.0.0 -matplotlib>=3.0.0 -setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability -ipython>=8.10.0 # not directly required, pinned by Snyk to avoid a vulnerability diff --git a/docs/usage.md b/docs/usage.md new file mode 100644 index 0000000..25221ed --- /dev/null +++ b/docs/usage.md @@ -0,0 +1,7 @@ +# Usage + +To use pyglotaran_extras in a project: + +``` +import pyglotaran_extras +``` diff --git a/docs/usage.rst b/docs/usage.rst deleted file mode 100644 index 8f047ac..0000000 --- a/docs/usage.rst +++ /dev/null @@ -1,7 +0,0 @@ -===== -Usage -===== - -To use pyglotaran_extras in a project:: - - import pyglotaran_extras diff --git a/pyglotaran_extras/plotting/utils.py b/pyglotaran_extras/plotting/utils.py index 5424e8a..ac52fac 100644 --- a/pyglotaran_extras/plotting/utils.py +++ b/pyglotaran_extras/plotting/utils.py @@ -450,7 +450,7 @@ def abs_max( def calculate_ticks_in_units_of_pi( values: np.ndarray | xr.DataArray, *, step_size: float = 0.5 ) -> tuple[Iterable[float], Iterable[str]]: - """Calculate tick values and labels in units of Pi. + r"""Calculate tick values and labels in units of Pi. Parameters ---------- @@ -475,6 +475,7 @@ def calculate_ticks_in_units_of_pi( dataset is saved under ``dataset.nc``. .. code-block:: python + import matplotlib.pyplot as plt from glotaran.io import load_dataset diff --git a/pyproject.toml b/pyproject.toml index aab60e1..795e7d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,83 @@ +[build-system] +build-backend = "hatchling.build" +requires = [ + "hatchling", +] + +[project] +name = "pyglotaran-extras" +description = "Supplementary package for pyglotaran with (example) plotting code." +readme = "README.md" +license = { file = "LICENSE" } +authors = [{ name = "Joris Snellenburg", email = "j.snellenburg@gmail.com" }] +requires-python = ">=3.10" +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Chemistry", + "Topic :: Scientific/Engineering :: Physics", +] +dynamic = [ + "version", +] +dependencies = [ + "cycler>=0.10", + "matplotlib>=3.3", + "numpy<1.24,>=1.21.2", + "pyglotaran>=0.7", + "tabulate>=0.8.9", + "xarray>=2022.3", +] +[project.optional-dependencies] +dev = [ + "pyglotaran_extras[docs,test]", +] +docs = [ + "jupyterlab>=3", + "myst-parser>=0.12", + "nbsphinx>=0.8.1", # notebook docs + "numpydoc>=0.8", + "Sphinx>=3.2", + "sphinx-copybutton>=0.3", + "sphinx-last-updated-by-git>=0.3", + "sphinx-rtd-theme>=1.2", + "sphinxcontrib-jquery>=4.1", # Needed for the search to work Ref.: https://github.com/readthedocs/sphinx_rtd_theme/issues/1434 +] +test = [ + "coverage[toml]", + "nbval>=0.9.6", + "pluggy>=0.7", + "pytest>=3.7.1", + "pytest-cov>=2.5.1", + "tox>=3.5.2", +] +[project.urls] +Changelog = "https://pyglotaran-extras.readthedocs.io/en/latest/changelog.html" +Documentation = "https://pyglotaran-extras.readthedocs.io" +"GloTarAn Ecosystem" = "https://glotaran.org" +Homepage = "https://github.com/glotaran/pyglotaran-extras" +Source = "https://github.com/glotaran/pyglotaran-extras" +Tracker = "https://github.com/glotaran/pyglotaran-extras/issues" + +[tool.hatch.version] +path = "pyglotaran_extras/__init__.py" + +[tool.hatch.build.targets.sdist] +include = ["/pyglotaran_extras"] + +[tool.hatch.envs.default] +features = ["dev"] + [tool.black] line-length = 99 -target-version = ['py38'] +target-version = ['py310'] exclude = ''' /( \.eggs @@ -19,26 +96,26 @@ exclude = ''' [tool.ruff] select = [ - "E", # pycodestyle - "W", # pycodestyle - "C", # mccabe - "F", # pyflakes - "UP", # pyupgrade - "D", # pydocstyle - "N", # pep8-naming + "E", # pycodestyle + "W", # pycodestyle + "C", # mccabe + "F", # pyflakes + "UP", # pyupgrade + "D", # pydocstyle + "N", # pep8-naming "YTT", # flake8-2020 "BLE", # flake8-blind-except # "FBT", # flake8-boolean-trap - "B", # flake8-bugbear - "C4", # flake8-comprehensions + "B", # flake8-bugbear + "C4", # flake8-comprehensions "T10", # flake8-debugger - "FA", # flake8-future-annotations - "EM", # flake8-errmsg + "FA", # flake8-future-annotations + "EM", # flake8-errmsg "ISC", # flake8-implicit-str-concat "INP", # flake8-no-pep420 "PIE", # flake8-pie "T20", # flake8-print - "PT", # flake8-pytest-style + "PT", # flake8-pytest-style "RSE", # flake8-raise "RET", # flake8-return "SIM", # flake8-simplify @@ -46,7 +123,7 @@ select = [ "ARG", # flake8-unused-arguments "PTH", # flake8-use-pathlib "ERA", # eradicate - "PD", # pandas-vet + "PD", # pandas-vet "PGH", # pygrep-hooks "NPY", # NumPy-specific "RUF", # Ruff-specific @@ -99,7 +176,6 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" target-version = "py310" [tool.ruff.per-file-ignores] -"setup.py" = ["D"] "tests/*" = ["ARG001"] [tool.isort] @@ -115,7 +191,6 @@ remove_redundant_aliases = true branch = true include = ['pyglotaran_extras/*'] omit = [ - 'setup.py', 'tests/*', # comment the above line if you want to see if all tests did run ] @@ -163,7 +238,7 @@ wrap-summaries = 99 wrap-descriptions = 99 [tool.interrogate] -exclude = ["setup.py", "docs", "tests/*"] +exclude = ["docs", "tests/*"] ignore-init-module = true fail-under = 100 @@ -175,6 +250,6 @@ flake8 = ["--extend-ignore=E402,F404"] [tool.pydoclint] skip-checking-short-docstrings = false style = 'numpy' -exclude = '^(docs/|setup.py$|tests?/)' +exclude = '^(docs/|tests?/)' require-return-section-when-returning-none = false allow-init-docstring = true diff --git a/readthedocs.yml b/readthedocs.yml index 40e90db..2e33e9d 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -12,6 +12,6 @@ build: python: install: - - requirements: docs/requirements.txt + - requirements: requirements_pinned.txt - method: pip - path: . + path: .[docs] diff --git a/requirements_dev.txt b/requirements_dev.txt deleted file mode 100644 index bedd899..0000000 --- a/requirements_dev.txt +++ /dev/null @@ -1,27 +0,0 @@ -# Runtime dependencies - -cycler==0.11.0 -matplotlib==3.7.2 -numpy==1.24.4 -pyglotaran==0.7.1 -tabulate==0.9.0 -xarray==2023.8.0 - -# Documentation dependencies --r docs/requirements.txt - - -# Testing dependencies -tox>=3.0.0 -# tox-direct>=0.4 -# Temporarily use the fix branch on my fork -git+https://github.com/s-weigand/tox-direct.git@fix-6 -pytest>=3.7.1 -pluggy>=0.7 -coverage[toml] -pytest-cov>=2.5.1 -nbval>=0.9.6 -# Ref https://github.com/mhammond/pywin32/issues/1709 -pywin32==306 ; sys_platform == 'win32' -# Code quality assurance -pre-commit>=2.9.0 diff --git a/requirements_pinned.txt b/requirements_pinned.txt new file mode 100644 index 0000000..59f0b4c --- /dev/null +++ b/requirements_pinned.txt @@ -0,0 +1,8 @@ +# Runtime dependencies + +cycler==0.11.0 +matplotlib==3.7.2 +numpy==1.24.4 +pyglotaran==0.7.1 +tabulate==0.9.0 +xarray==2023.8.0 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index ba7b4ba..0000000 --- a/setup.cfg +++ /dev/null @@ -1,51 +0,0 @@ -[metadata] -name = pyglotaran_extras -version = attr: pyglotaran_extras.__version__ -description = Supplementary package for pyglotaran with (example) plotting code. -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/glotaran/pyglotaran-extras -author = Joris Snellenburg -author_email = j.snellenburg@gmail.com -license = MIT -license_files = LICENSE -classifiers = - Development Status :: 4 - Beta - Intended Audience :: Science/Research - License :: OSI Approved :: MIT License - Natural Language :: English - Operating System :: OS Independent - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Topic :: Scientific/Engineering - Topic :: Scientific/Engineering :: Chemistry - Topic :: Scientific/Engineering :: Physics -project_urls = - GloTarAn Ecosystem=https://glotaran.org - Documentation=https://pyglotaran-extras.readthedocs.io - Changelog=https://pyglotaran-extras.readthedocs.io/en/latest/changelog.html - Source=https://github.com/glotaran/pyglotaran-extras - Tracker=https://github.com/glotaran/pyglotaran-extras/issues - -[options] -packages = find: -install_requires = - cycler>=0.10 - matplotlib>=3.3.0 - numpy>=1.21.2,<1.24 - pyglotaran>=0.7 - tabulate>=0.8.9 - xarray>=2022.3.0 -python_requires = >=3.10 -zip_safe = True - -[options.packages.find] -include = - pyglotaran_extras - pyglotaran_extras.* - -[rstcheck] -ignore_directives = autosummary - -[pydocstyle] -convention = numpy diff --git a/setup.py b/setup.py deleted file mode 100644 index 6068493..0000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -from setuptools import setup - -setup() diff --git a/tox.ini b/tox.ini index 542d171..4f94184 100644 --- a/tox.ini +++ b/tox.ini @@ -37,6 +37,6 @@ commands = pre-commit run --all [testenv] install_command = {envpython} -m pip install {opts} {packages} -deps = -r{toxinidir}/requirements_dev.txt +deps = -r{toxinidir}/requirements_pinned.txt commands = pytest --nbval --cov=pyglotaran_extras --cov-config {toxinidir}/pyproject.toml