Skip to content

Commit 192f8cf

Browse files
hynekfrostming
andauthored
Use pdm for everything (#57)
* Use pdm for everything * don't need this * don't need tools * Disable caches for now * Wrong cache * paths * debug * more debug * more debug * jfc * wtf * jfc * cleanup * needs absolute * all of them * Try caching again * resolve * bash * fix path * Actually use venv * Don't pollute the Python * Try to use __pypackages__ * no use? * order? * argl * don't jump * Use the output * Try with cd * Use venv * Try using own Python * Use preferred PDM backend Co-authored-by: Frost Ming <[email protected]> --------- Co-authored-by: Frost Ming <[email protected]>
1 parent 87af9d9 commit 192f8cf

File tree

5 files changed

+42
-335
lines changed

5 files changed

+42
-335
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ repos:
99
- id: trailing-whitespace
1010
- id: end-of-file-fixer
1111
- id: check-yaml
12+
- id: check-toml

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
77

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

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

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

action.yml

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,36 @@ outputs:
1919
runs:
2020
using: composite
2121
steps:
22-
- uses: actions/setup-python@v4
23-
id: python-baipp
22+
- name: Resolve Lock Path
23+
shell: bash
24+
run: echo "PDM_CACHE=$(realpath ${{ github.action_path }}/pdm.lock)" >>$GITHUB_ENV
25+
26+
- uses: pdm-project/setup-pdm@v3
27+
id: setup-pdm
2428
with:
25-
python-version: "3.x"
26-
update-environment: false
27-
cache: pip
29+
python-version: 3.x
30+
update-python: false
31+
cache: true
32+
cache-dependency-path: ${{ env.PDM_CACHE }}
2833

2934
- name: Create venv for tools
30-
run: ${{ steps.python-baipp.outputs.python-path }} -Im venv /tmp/baipp
3135
shell: bash
36+
run: |
37+
cd ${{ github.action_path }}
3238
33-
- name: Install our tools
34-
run: >
35-
/tmp/baipp/bin/python
36-
-Im pip
37-
--disable-pip-version-check
38-
--no-python-version-warning
39-
install -r ${{ github.action_path }}/requirements/tools.txt
40-
shell: bash
39+
pdm venv create --name baipp ${{ steps.setup-pdm.outputs.python-path }}
40+
pdm use --venv baipp
41+
pdm sync
42+
pdm info --json
4143
4244
# Build SDist, then build wheel out of it.
4345
# Set 'SOURCE_DATE_EPOCH' based on the last commit for build
4446
# reproducibility.
45-
- run: >
47+
- run: |
48+
PROJECT=$(pwd)
4649
SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
47-
/tmp/baipp/bin/python -m build --outdir /tmp/baipp/dist
50+
51+
pdm run -p ${{ github.action_path }} build --outdir /tmp/baipp/dist "$PROJECT"
4852
shell: bash
4953
working-directory: ${{ inputs.path }}
5054
@@ -64,18 +68,14 @@ runs:
6468
name: Packages
6569
path: /tmp/baipp/dist/*
6670

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

7175
- name: Check PyPI README
7276
shell: bash
7377
working-directory: ${{ inputs.path }}
74-
run: >
75-
/tmp/baipp/bin/python
76-
-m twine check
77-
--strict
78-
/tmp/baipp/dist/*
78+
run: pdm run -p ${{ github.action_path }} check-readme /tmp/baipp/dist/*
7979

8080
- name: Show wheel & SDist contents hierarchically, including metadata.
8181
shell: bash
@@ -84,7 +84,8 @@ runs:
8484
cd /tmp/baipp/dist
8585
mkdir -p out/sdist
8686
mkdir -p out/wheels
87-
/tmp/baipp/bin/python -m wheel unpack --dest out/wheels *.whl
87+
88+
pdm run -p ${{ github.action_path }} wheel unpack --dest /tmp/baipp/dist/out/wheels /tmp/baipp/dist/*.whl
8889
tar xf *.tar.gz -C out/sdist
8990
9091
echo -e '\n<details><summary>SDist contents</summary>\n' >> $GITHUB_STEP_SUMMARY
@@ -111,7 +112,7 @@ runs:
111112
shell: bash
112113
working-directory: /tmp/baipp/dist/out/sdist/
113114
run: |
114-
cat */PKG-INFO | python -c '
115+
cat */PKG-INFO | ${{ steps.setup-pdm.outputs.python-path }} -c '
115116
import email.parser
116117
import sys
117118

pyproject.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
[build-system]
2+
requires = ["pdm-backend"]
3+
build-backend = "pdm.backend"
4+
5+
[tool.pdm.scripts]
6+
build = "python -Im build"
7+
check-wheel-contents = "python -Im check_wheel_contents"
8+
check-readme = "python -Im twine check --strict"
9+
wheel = "python -Im wheel"
10+
111
[project]
212
name = "build-and-inspect-python-package"
313
version = "0" # we're not an actual package.
@@ -9,5 +19,5 @@ dependencies = [
919
"twine>=4.0.2",
1020
"wheel>=0.38.4",
1121
]
12-
license = {text = "MIT"}
22+
license = { text = "MIT" }
1323
requires-python = ">=3.10"

0 commit comments

Comments
 (0)