Skip to content

Commit

Permalink
switch to python -m build
Browse files Browse the repository at this point in the history
  • Loading branch information
egpbos committed Oct 20, 2023
1 parent ad1ebf0 commit 8362b36
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 26 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ my-python-project/
├── pyproject.toml
├── README.dev.md
├── README.md
├── setup.cfg
├── setup.py
├── sonar-project.properties
└── tests
├── __init__.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Run unit tests
run: python -m pytest -v
- name: Verify that we can build the package
run: python setup.py sdist bdist_wheel
run: python -m build

lint:
name: Linting build
Expand Down
32 changes: 10 additions & 22 deletions {{cookiecutter.directory_name}}/README.dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,35 +138,23 @@ This section describes how to make a release in 3 parts:

### (2/3) PyPI

In a new terminal, without an activated virtual environment or an env directory:
In a new terminal:

```shell
# prepare a new directory
# OPTIONAL: prepare a new directory with fresh git clone to ensure the release
# has the state of origin/main branch
cd $(mktemp -d {{ cookiecutter.package_name }}.XXXXXX)

# fresh git clone ensures the release has the state of origin/main branch
git clone {{ cookiecutter.repository }} .

# prepare a clean virtual environment and activate it
python -m venv env
source env/bin/activate

# make sure to have a recent version of pip and setuptools
python -m pip install --upgrade pip setuptools

# install runtime dependencies and publishing dependencies
python -m pip install --no-cache-dir .
python -m pip install --no-cache-dir .[publishing]

# clean up any previously generated artefacts
rm -rf {{ cookiecutter.package_name }}.egg-info
rm -rf dist
# make sure to have a recent version of pip and the publishing dependencies
python -m pip install --upgrade pip
python -m pip install .[publishing]

# create the source distribution and the wheel
python setup.py sdist bdist_wheel
python -m build

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

Visit
Expand All @@ -183,7 +171,7 @@ python -m venv env
source env/bin/activate

# make sure to have a recent version of pip and setuptools
python -m pip install --upgrade pip setuptools
python -m pip install --upgrade pip

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

### (3/3) GitHub
Expand Down
3 changes: 2 additions & 1 deletion {{cookiecutter.directory_name}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ version = "{{ cookiecutter.version }}"

[project.optional-dependencies]
dev = [
"build",
"build", # build is not only used in publishing (below), but also in the template's test suite
"bump2version",
"coverage [toml]",
"pytest",
Expand All @@ -56,6 +56,7 @@ dev = [
"myst_parser",
]
publishing = [
"build",
"twine",
"wheel",
]
Expand Down

0 comments on commit 8362b36

Please sign in to comment.