diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4dd6174..5702c85 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -16,12 +16,12 @@ jobs: python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] runs-on: ${{ matrix.platform }} + steps: - - uses: actions/checkout@v4 - - name: Get history and tags for SCM versioning to work - run: | - git fetch --prune --unshallow - git fetch --depth=1 origin +refs/tags/*:refs/tags/* + - name: Check out source repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 - name: Install uv with Python ${{ matrix.python-version }} uses: astral-sh/setup-uv@v6 with: diff --git a/.github/workflows/codacy-coverage-reporter.yaml b/.github/workflows/codacy-coverage-reporter.yaml index 579c725..856a946 100644 --- a/.github/workflows/codacy-coverage-reporter.yaml +++ b/.github/workflows/codacy-coverage-reporter.yaml @@ -9,41 +9,28 @@ on: jobs: build: - strategy: - matrix: - platform: [ubuntu-latest] - python-version: ["3.11"] - - runs-on: ${{ matrix.platform }} - + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - - name: Get history and tags for SCM versioning to work - run: | - git fetch --prune --unshallow - git fetch --depth=1 origin +refs/tags/*:refs/tags/* - - - name: Install uv with Python ${{ matrix.python-version }} + - name: Check out source repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 + - name: Install uv with Python uses: astral-sh/setup-uv@v6 with: - python-version: ${{ matrix.python-version }} - + python-version: "3.11" - name: Install dependencies and pyproximal run: uv sync --locked --all-extras --all-groups - - name: Coverage with pytest run: | uv run coverage run -m pytest uv run coverage xml uv run coverage html - - name: Upload HTML coverage report uses: actions/upload-artifact@v4 with: name: coverage-html path: htmlcov/ - - name: Run codacy-coverage-reporter if: github.event_name == 'push' uses: codacy/codacy-coverage-reporter-action@v1 diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index fb48608..01e3a23 100755 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -1,28 +1,67 @@ # This workflow uploads PyProx on PyPI using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries +# For more information see: https://github.com/python-attrs/attrs/blob/main/.github/workflows/pypi-package.yml name: PyProximal-deploy on: + push: + tags: ["*"] release: - types: [published] + types: + - published + workflow_dispatch: jobs: - deploy: + build-package: + name: Build & verify package runs-on: ubuntu-latest + + steps: + - name: Check out source repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 + - name: Build and inspect package + uses: hynek/build-and-inspect-python-package@v2 + + release-test-pypi: + name: Publish in-dev package to test.pypi.org + if: github.repository_owner == 'PyLops' && github.ref_type == 'tag' + runs-on: ubuntu-latest + needs: build-package + permissions: + contents: read + id-token: write + + steps: + - name: Download package + uses: actions/download-artifact@v8 + with: + name: Packages + path: dist + + - name: Upload package to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + attestations: true + repository-url: https://test.pypi.org/legacy/ + + release-pypi: + name: Publish released package to pypi.org + if: github.repository_owner == 'PyLops' && github.event.action == 'published' + runs-on: ubuntu-latest + needs: build-package + permissions: + contents: read + id-token: write + steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 + - name: Download package + uses: actions/download-artifact@v8 with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + name: Packages + path: dist + + - name: Upload package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} + attestations: true diff --git a/.github/workflows/mypy.yaml b/.github/workflows/mypy.yaml index 08fbd56..1c40c80 100644 --- a/.github/workflows/mypy.yaml +++ b/.github/workflows/mypy.yaml @@ -9,7 +9,9 @@ jobs: name: MyPy steps: - name: Check out source repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 + with: + fetch-depth: 0 - name: Install uv with Python uses: astral-sh/setup-uv@v6 with: diff --git a/.github/workflows/ruff.yaml b/.github/workflows/ruff.yaml index c4ba642..3ab4a5c 100644 --- a/.github/workflows/ruff.yaml +++ b/.github/workflows/ruff.yaml @@ -10,8 +10,10 @@ jobs: name: Lint steps: - name: Check out source repository - uses: actions/checkout@v4 - - name: ruff Lint + uses: actions/checkout@v6 + with: + fetch-depth: 0 + - name: Lint with ruff uses: astral-sh/ruff-action@v3 with: src: "./pyproximal" diff --git a/.gitignore b/.gitignore index a0f8e75..4b851c1 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,7 @@ build dist pyproximal.egg-info/ -# setuptools_scm generated # +# hatchling generated # pyproximal/version.py # Development # diff --git a/README.md b/README.md index 231b558..76750b5 100644 --- a/README.md +++ b/README.md @@ -107,33 +107,37 @@ This repository is organized as follows: ## Getting started You need **Python 3.10 or greater**. -#### From Conda +#### From PyPI +To get the most out of PyProximal straight out of the box, we recommend using +the PyPI distribution via `uv`: -To get the most out of PyLops straight out of the box, we recommend `conda` to install PyLops: ```bash -conda install -c conda-forge pyproximal +uv pip install pyproximal ``` -#### From PyPI -You can also install pyproximal with `pip`: +or directly via `pip`: + ```bash pip install pyproximal ``` -or via `uv`: + +#### From Conda +You can also install PyProximal via `conda`: + ```bash -uv pip install pyproximal +conda install -c conda-forge pyproximal ``` #### From Github -Finally, you can also directly install from the main branch (although this is not recommended): +Finally, you can also directly install from the main branch (although this is not recommended) via `uv`: -``` -pip install git+https://git@github.com/PyLops/pyproximal.git@main -``` -or via `uv`: ```bash uv add git+https://github.com/PyLops/pyproximal.git --branch main ``` +or via `pip`: +```bash +pip install git+https://git@github.com/PyLops/pyproximal.git@main +``` ## Contributing *Feel like contributing to the project? Adding new operators or tutorial?* @@ -150,8 +154,8 @@ Execute the following command in your terminal: git clone https://github.com/your_name_here/pyproximal.git ``` -### 2. Install PyLops in a new Conda environment -To ensure that further development of PyLops is performed within the same environment (i.e., +### 2. Install PyProximal in a new Conda environment +To ensure that further development of PyProximal is performed within the same environment (i.e., same dependencies) as that defined by ``environment-dev.yml``/``environment-dev-arm.yml`` files, we suggest to work off a new Conda enviroment. diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 2272ec7..127bfac 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -113,7 +113,7 @@ will also be run as part of our CI. .. tab-set:: - .. tab-item:: conda + .. tab-item:: :iconify:`devicon:anaconda` conda .. code-block:: bash diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 3af93dc..a16d6d9 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -5,7 +5,6 @@ Dependencies ************ - The mandatory dependencies of PyProximal are limited to: * Python 3.10 or greater @@ -38,8 +37,8 @@ First install `pyproximal` with your package manager of choice. >> conda install --channel conda-forge pyproximal - Most of the dependencies (all required and some of the optional) are - automatically installed for you. + which installs also the *required* dependencies, if not already present + in your environment. .. tab-item:: :iconify:`material-icon-theme:uv` uv @@ -47,17 +46,16 @@ First install `pyproximal` with your package manager of choice. >> uv add pyproximal - Only the *required* dependencies are installed. To install - some of the optional dependencies, run: + which installs also the *required* dependencies, if not already present + in your environment. To also install the optional dependencies, run: .. code-block:: bash >> uv add "pyproximal[advanced]" - From Source =========== -To access the latest source from github: +To access the latest source from GitHub: .. tab-set:: @@ -81,7 +79,8 @@ Step-by-step installation for developers Fork PyProximal =============== -Fork the `PyProximal repository `_ and clone it by executing the following in your terminal: +Fork the `PyProximal repository `_ and clone it +by executing the following in your terminal: .. code-block:: bash @@ -89,7 +88,6 @@ Fork the `PyProximal repository `_ and clo Install dependencies ==================== - We recommend installing dependencies into a separate environment. For that end, we provide a `Makefile` with useful commands for setting up the environment. @@ -178,8 +176,8 @@ At this point, the user must check the changes and then stage them before trying Final steps =========== -PyLops does not enforce the use of a linter as a pre-commit hook, but we do highly encourage using one before submitting a Pull Request. -A properly configured linter (``ruff``) can be run with: +PyProximal does enforce the use of a linter (``ruff``), which is run both as a pre-commit hook and as a GitHub Action. +The linter can also be run locally with: .. tab-set:: diff --git a/environment-dev-arm.yml b/environment-dev-arm.yml index d386d10..845d36b 100644 --- a/environment-dev-arm.yml +++ b/environment-dev-arm.yml @@ -22,7 +22,6 @@ dependencies: - bm4d - bm3d - pytest-runner - - setuptools_scm - pooch - shibuya - sphinx-design diff --git a/environment-dev.yml b/environment-dev.yml index e39a571..b5f8651 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -23,7 +23,6 @@ dependencies: - bm4d - bm3d - pytest-runner - - setuptools_scm - pooch - shibuya - sphinx-design diff --git a/pyproject.toml b/pyproject.toml index fc6022b..cd2ee8a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,9 @@ [build-system] requires = [ - "setuptools >= 65", - "setuptools_scm[toml]", - "wheel", + "hatchling", + "hatch-vcs" ] -build-backend = "setuptools.build_meta" +build-backend = "hatchling.build" [project] name = "pyproximal" @@ -70,11 +69,21 @@ doc = [ "image", ] -[tool.setuptools.packages.find] -exclude = ["pytests"] +[project.urls] +Homepage = "https://github.com/PyLops/pyproximal" +Documentation = "https://pyproximal.readthedocs.io/en/stable" +Discussions = "https://github.com/PyLops/pyproximal/discussions" +Issues = "https://github.com/PyLops/pyproximal/issues" -[tool.setuptools_scm] -version_file = "pyproximal/version.py" +[tool.hatch] +version.source = "vcs" +build.hooks.vcs.version-file = "pyproximal/version.py" + +[tool.hatch.build.targets.wheel] +packages = ["pyproximal"] + +[tool.hatch.build.targets.sdist] +exclude = ["/.github", "/testdata"] [tool.pytest.ini_options] addopts = "--verbose"