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

Use pdm for everything #57

Merged
merged 31 commits into from
Jul 25, 2023
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
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased](https://github.com/hynek/build-and-inspect-python-package/compare/v1.5...main)

### Changed

- This shouldn't make any difference, but all management and command running is now done by [PDM](https://pdm.fming.dev/).
[#57](https://github.com/hynek/build-and-inspect-python-package/pull/57)


## [1.5](https://github.com/hynek/build-and-inspect-python-package/compare/v1.4.1...v1.5)

Expand Down
49 changes: 25 additions & 24 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,36 @@ outputs:
runs:
using: composite
steps:
- uses: actions/setup-python@v4
id: python-baipp
- name: Resolve Lock Path
shell: bash
run: echo "PDM_CACHE=$(realpath ${{ github.action_path }}/pdm.lock)" >>$GITHUB_ENV

- uses: pdm-project/setup-pdm@v3
id: setup-pdm
with:
python-version: "3.x"
update-environment: false
cache: pip
python-version: 3.x
update-python: false
cache: true
cache-dependency-path: ${{ env.PDM_CACHE }}

- name: Create venv for tools
run: ${{ steps.python-baipp.outputs.python-path }} -Im venv /tmp/baipp
shell: bash
run: |
cd ${{ github.action_path }}

- name: Install our tools
run: >
/tmp/baipp/bin/python
-Im pip
--disable-pip-version-check
--no-python-version-warning
install -r ${{ github.action_path }}/requirements/tools.txt
shell: bash
pdm venv create --name baipp ${{ steps.setup-pdm.outputs.python-path }}
pdm use --venv baipp
pdm sync
pdm info --json

# Build SDist, then build wheel out of it.
# Set 'SOURCE_DATE_EPOCH' based on the last commit for build
# reproducibility.
- run: >
- run: |
PROJECT=$(pwd)
SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
/tmp/baipp/bin/python -m build --outdir /tmp/baipp/dist

pdm run -p ${{ github.action_path }} build --outdir /tmp/baipp/dist "$PROJECT"
shell: bash
working-directory: ${{ inputs.path }}

Expand All @@ -64,18 +68,14 @@ runs:
name: Packages
path: /tmp/baipp/dist/*

- run: /tmp/baipp/bin/check-wheel-contents /tmp/baipp/dist/*.whl
- run: pdm run -p ${{ github.action_path }} check-wheel-contents /tmp/baipp/dist/*.whl
shell: bash
working-directory: ${{ inputs.path }}

- name: Check PyPI README
shell: bash
working-directory: ${{ inputs.path }}
run: >
/tmp/baipp/bin/python
-m twine check
--strict
/tmp/baipp/dist/*
run: pdm run -p ${{ github.action_path }} check-readme /tmp/baipp/dist/*

- name: Show wheel & SDist contents hierarchically, including metadata.
shell: bash
Expand All @@ -84,7 +84,8 @@ runs:
cd /tmp/baipp/dist
mkdir -p out/sdist
mkdir -p out/wheels
/tmp/baipp/bin/python -m wheel unpack --dest out/wheels *.whl

pdm run -p ${{ github.action_path }} wheel unpack --dest /tmp/baipp/dist/out/wheels /tmp/baipp/dist/*.whl
tar xf *.tar.gz -C out/sdist

echo -e '\n<details><summary>SDist contents</summary>\n' >> $GITHUB_STEP_SUMMARY
Expand All @@ -111,7 +112,7 @@ runs:
shell: bash
working-directory: /tmp/baipp/dist/out/sdist/
run: |
cat */PKG-INFO | python -c '
cat */PKG-INFO | ${{ steps.setup-pdm.outputs.python-path }} -c '
import email.parser
import sys

Expand Down
12 changes: 11 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"

[tool.pdm.scripts]
build = "python -Im build"
check-wheel-contents = "python -Im check_wheel_contents"
check-readme = "python -Im twine check --strict"
wheel = "python -Im wheel"

[project]
name = "build-and-inspect-python-package"
version = "0" # we're not an actual package.
Expand All @@ -9,5 +19,5 @@ dependencies = [
"twine>=4.0.2",
"wheel>=0.38.4",
]
license = {text = "MIT"}
license = { text = "MIT" }
requires-python = ">=3.10"
Loading