Skip to content

Commit

Permalink
Update packaging configuration and workflow (#147)
Browse files Browse the repository at this point in the history
* Add separate workflow for uploading to TestPyPI

* Remove version_scheme for Test PyPI

* Remove cache step

* Use node_and_date

* Remove setup.py
  • Loading branch information
maxrjones authored Jan 8, 2023
1 parent 463227f commit 553e5ee
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 17 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches: main
pull_request:
branches: main
paths-ignore:
- ".github/workflows/*-release.yaml"
- "asv_bench/**"
- "doc/**"
schedule:
- cron: "0 0 * * *"

Expand Down Expand Up @@ -54,12 +58,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/dev-requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- run: |
python -m pip install -e .[dev]
python -m pip install --no-deps --upgrade \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pypi-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
# Change setuptools-scm local_scheme to "no-local-version" so the
# local part of the version isn't included, making the version string
# compatible with PyPI.
sed --in-place "s/dirty-tag/no-local-version/g" pyproject.toml
sed --in-place "s/node-and-date/no-local-version/g" pyproject.toml
- name: Build tarball and wheels
run: |
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/testpypi-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build and Upload xbatcher to TestPyPI
on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read

jobs:
publish-testpypi:
name: Publish to Test PyPI
runs-on: ubuntu-latest
if: github.repository == 'xarray-contrib/xbatcher'

steps:
- name: Checkout
uses: actions/[email protected]
with:
# fetch all history so that setuptools-scm works
fetch-depth: 0

- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.10"

- name: Install dependencies
run: python -m pip install build

- name: Fix up version string for TestPyPI
if: ${{ !startsWith(github.ref, 'refs/tags') }}
run: |
sed --in-place "s/node-and-date/no-local-version/g" pyproject.toml
- name: Build tarball and wheels
run: |
python -m build
echo "Generated files:"
ls -lh dist/
- name: Verify the built dist/wheel is valid
run: |
python -m pip install --upgrade pip
python -m pip install dist/xbatcher*.whl
python -m xbatcher.util.print_versions
- name: Publish package to TestPyPI
uses: pypa/[email protected]
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
# verbose: true
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Or from source as::
for more details.

Documentation
------------
-------------

Documentation is hosted on ReadTheDocs: https://xbatcher.readthedocs.org

Expand Down
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build-system]
requires = [
"setuptools>=61",
"setuptools-scm"
"setuptools>=64",
"setuptools-scm[toml]>=6.2"
]
build-backend = "setuptools.build_meta"

Expand Down Expand Up @@ -54,13 +54,12 @@ repository = "https://github.com/xarray-contrib/xbatcher"
include = ["xbatcher*"]

[tool.setuptools_scm]
version_scheme = "post-release"
local_scheme = "dirty-tag"
local_scheme = "node-and-date"
fallback_version = "999"

[tool.isort]
profile = "black"
known_third_party = ["numpy", "pytest", "setuptools", "sphinx_autosummary_accessors", "torch", "xarray"]
known_third_party = ["numpy", "pytest", "sphinx_autosummary_accessors", "torch", "xarray"]

[tool.pytest.ini_options]
log_cli = true
Expand Down
4 changes: 0 additions & 4 deletions setup.py

This file was deleted.

0 comments on commit 553e5ee

Please sign in to comment.