Skip to content

upload wheels from main to TestPyPI #6660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/configure-testpypi-version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import argparse
import copy
import pathlib

import tomli
import tomli_w


def split_path(path, sep="/"):
if isinstance(path, str):
return [part for part in path.split(sep) if part]
else:
return path


def extract(mapping, path, sep="/"):
parts = split_path(path, sep=sep)
cur = mapping
for part in parts:
cur = cur[part]

return cur


def update(mapping, path, value, sep="/"):
new = copy.deepcopy(mapping)

parts = split_path(path, sep=sep)
parent = extract(new, parts[:-1])
parent[parts[-1]] = value

return new


parser = argparse.ArgumentParser()
parser.add_argument("path", type=pathlib.Path)
args = parser.parse_args()

content = args.path.read_text()
decoded = tomli.loads(content)
updated = update(
decoded, "tool.setuptools_scm.local_scheme", "no-local-version", sep="."
)

new_content = tomli_w.dumps(updated)

args.path.write_text(new_content)
87 changes: 87 additions & 0 deletions .github/workflows/testpypi-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Build and Upload xarray to PyPI
on:
push:
branches:
- 'main'

# no need for concurrency limits

jobs:
build-artifacts:
runs-on: ubuntu-latest
if: github.repository == 'pydata/xarray'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-python@v3
name: Install Python
with:
python-version: 3.10

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools setuptools-scm wheel twine check-manifest
python -m pip install tomli tomli_w

- name: Disable local versions
run: |
python .github/workflows/configure-testpypi-version.py pyproject.toml
git update-index --assume-unchanged pyproject.toml

- name: Build tarball and wheels
run: |
git clean -xdf
git restore -SW .
python -m build --sdist --wheel .

- name: Check built artifacts
run: |
python -m twine check dist/*
pwd
if [ -f dist/xarray-0.0.0.tar.gz ]; then
echo "❌ INVALID VERSION NUMBER"
exit 1
else
echo "✅ Looks good"
fi

- uses: actions/upload-artifact@v3
with:
name: releases
path: dist

test-built-dist:
needs: build-artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v3
name: Install Python
with:
python-version: 3.10
- uses: actions/download-artifact@v3
with:
name: releases
path: dist
- name: List contents of built dist
run: |
ls -ltrh
ls -ltrh dist

- name: Verify the built dist/wheel is valid
if: github.event_name == 'push'
run: |
python -m pip install --upgrade pip
python -m pip install dist/xarray*.whl
python -m xarray.util.print_versions

- name: Publish package to TestPyPI
if: github.event_name == 'push'
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.TESTPYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
verbose: true
9 changes: 9 additions & 0 deletions doc/getting-started-guide/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ installed, take a look at the ``[options.extras_require]`` section in
:start-at: [options.extras_require]
:end-before: [options.package_data]

Development versions
--------------------
To install the most recent development version, install from github::

$ python -m pip install git+https://github.com/pydata/xarray.git

or from TestPyPI::

$ python -m pip install --index-url https://test.pypi.org/simple --extra-index-url https://pypi.org/simple xarray

Testing
-------
Expand Down
4 changes: 3 additions & 1 deletion doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ New Features
- Improved overall typing.
- :py:meth:`Dataset.to_dict` and :py:meth:`DataArray.to_dict` may now optionally include encoding
attributes. (:pull:`6635`)
By Joe Hamman <https://github.com/jhamman>`_.
By `Joe Hamman <https://github.com/jhamman>`_.
- Upload development versions to `TestPyPI <https://test.pypi.org>`_.
By `Justus Magin <https://github.com/keewis>`_.

Breaking changes
~~~~~~~~~~~~~~~~
Expand Down