Skip to content

Commit e24c0aa

Browse files
committed
switch to python -m build
1 parent 375ea62 commit e24c0aa

4 files changed

Lines changed: 13 additions & 26 deletions

File tree

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ my-python-project/
135135
├── pyproject.toml
136136
├── README.dev.md
137137
├── README.md
138-
├── setup.cfg
139-
├── setup.py
140138
├── sonar-project.properties
141139
└── tests
142140
├── __init__.py

{{cookiecutter.directory_name}}/.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Run unit tests
3737
run: python -m pytest -v
3838
- name: Verify that we can build the package
39-
run: python setup.py sdist bdist_wheel
39+
run: python -m build
4040

4141
lint:
4242
name: Linting build

{{cookiecutter.directory_name}}/README.dev.md

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -138,35 +138,23 @@ This section describes how to make a release in 3 parts:
138138

139139
### (2/3) PyPI
140140

141-
In a new terminal, without an activated virtual environment or an env directory:
141+
In a new terminal:
142142

143143
```shell
144-
# prepare a new directory
144+
# OPTIONAL: prepare a new directory with fresh git clone to ensure the release
145+
# has the state of origin/main branch
145146
cd $(mktemp -d {{ cookiecutter.package_name }}.XXXXXX)
146-
147-
# fresh git clone ensures the release has the state of origin/main branch
148147
git clone {{ cookiecutter.repository }} .
149148

150-
# prepare a clean virtual environment and activate it
151-
python -m venv env
152-
source env/bin/activate
153-
154-
# make sure to have a recent version of pip and setuptools
155-
python -m pip install --upgrade pip setuptools
156-
157-
# install runtime dependencies and publishing dependencies
158-
python -m pip install --no-cache-dir .
159-
python -m pip install --no-cache-dir .[publishing]
160-
161-
# clean up any previously generated artefacts
162-
rm -rf {{ cookiecutter.package_name }}.egg-info
163-
rm -rf dist
149+
# make sure to have a recent version of pip and the publishing dependencies
150+
python -m pip install --upgrade pip
151+
python -m pip install .[publishing]
164152

165153
# create the source distribution and the wheel
166-
python setup.py sdist bdist_wheel
154+
python -m build
167155

168156
# upload to test pypi instance (requires credentials)
169-
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
157+
python -m twine upload --repository testpypi dist/*
170158
```
171159

172160
Visit
@@ -183,7 +171,7 @@ python -m venv env
183171
source env/bin/activate
184172

185173
# make sure to have a recent version of pip and setuptools
186-
python -m pip install --upgrade pip setuptools
174+
python -m pip install --upgrade pip
187175

188176
# install from test pypi instance:
189177
python -m pip -v install --no-cache-dir \
@@ -198,7 +186,7 @@ Then upload to pypi.org with:
198186
```shell
199187
# Back to the first terminal,
200188
# FINAL STEP: upload to PyPI (requires credentials)
201-
twine upload dist/*
189+
python -m twine upload dist/*
202190
```
203191

204192
### (3/3) GitHub

{{cookiecutter.directory_name}}/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ version = "{{ cookiecutter.version }}"
4343

4444
[project.optional-dependencies]
4545
dev = [
46-
"build",
46+
"build", # build is not only used in publishing (below), but also in the template's test suite
4747
"bump2version",
4848
"coverage [toml]",
4949
"pytest",
@@ -56,6 +56,7 @@ dev = [
5656
"myst_parser",
5757
]
5858
publishing = [
59+
"build",
5960
"twine",
6061
"wheel",
6162
]

0 commit comments

Comments
 (0)