Skip to content
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

support PEP517 #24

Merged
merged 3 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ jobs:
from __init__ import __version__
assert __version__ == '9.2.3', f'::error:: assert version {__version__} == 9.2.3'
"
setup_py_version='${{ steps.set-package-version.outputs.setup-py-version }}'
assert_equal "$setup_py_version" '1!9.2.3'
package_version='${{ steps.set-package-version.outputs.package-version }}'
assert_equal "$package_version" '1!9.2.3'
# Check changes to init file are staged
exact_grep "M __init__.py" <(git status -s)

Expand Down
17 changes: 12 additions & 5 deletions build-python-package/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ inputs:
runs:
using: composite
steps:
- name: Install dependencies
shell: bash
run: python3 -m pip install wheel

- name: Build
shell: bash
run: python3 setup.py bdist_wheel sdist
run: |
if [[ -f setup.py ]]; then
# old style setup.py project
# (must manually install build dependencies)
python3 -m pip install wheel
python3 setup.py bdist_wheel sdist
oliver-sanders marked this conversation as resolved.
Show resolved Hide resolved
else
# PEP517 project
# (must install a builder, this installs build deps for us)
python3 -m pip install build
python3 -m build
oliver-sanders marked this conversation as resolved.
Show resolved Hide resolved
fi
26 changes: 17 additions & 9 deletions stage-1/set-python-package-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ inputs:
required: false
default: true
outputs:
setup-py-version:
package-version:
description: Version number as outputted by setup.py (might be different from __init__.py, e.g. if epoch prefixed)
value: ${{ steps.get-setup-py-version.outputs.version }}
value: ${{ steps.get-package-version.outputs.version }}
runs:
using: composite
steps:
Expand Down Expand Up @@ -53,21 +53,29 @@ runs:
git add "$INIT_FILE"
fi

- name: Get setup.py version
- name: Get package version
# Might differ slightly from __init__.py, e.g. if epoch prefixed
id: get-setup-py-version
id: get-package-version
shell: bash
run: |
setup_py_version=$( python setup.py --version )
if [[ ! -f setup.py ]]; then
oliver-sanders marked this conversation as resolved.
Show resolved Hide resolved
# get version from the setup.py for pre PEP517 projects
package_version=$( python setup.py --version )
oliver-sanders marked this conversation as resolved.
Show resolved Hide resolved
else
# shim to get the project version from a PEP517 project
echo 'from setuptools import setup; setup()' > setup.py
oliver-sanders marked this conversation as resolved.
Show resolved Hide resolved
package_version=$( python setup.py --version )
rm setup.py
fi
# Check version number is valid:
cmp_py_versions "$setup_py_version" "$setup_py_version"
echo "setup.py version: ${setup_py_version}"
echo "::set-output name=version::$setup_py_version"
cmp_py_versions "$package_version" "$package_version"
echo "package version: ${package_version}"
echo "::set-output name=version::$package_version"

- name: Check version doesn't already exist on PyPI.org
shell: bash
working-directory: ${{ github.action_path }}
env:
PYPI_PACKAGE_NAME: ${{ inputs.pypi-package-name }}
SETUP_PY_VERSION: ${{ steps.get-setup-py-version.outputs.version }}
SETUP_PY_VERSION: ${{ steps.get-package-version.outputs.version }}
run: node check-pypi.js
6 changes: 5 additions & 1 deletion stage-2/comment-on-pr/comment-on-pr.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ You can still publish the dist to PyPI manually:

(Make sure you have commit \`${pr_event.merge_commit_sha}\` checked out)
\`\`\`shell
# Create the build
# Create the build (old style for setup.py projects)
python3 setup.py bdist_wheel sdist

# Create the build (PEP517)
python -m build

# Upload your build to PyPI
twine upload dist/*
\`\`\`
Expand Down