Skip to content

Commit c83c562

Browse files
authored
Merge pull request #361 from tomschr/feature/pyproject.toml
Fix #365: Improve pyproject.toml
2 parents b5317af + 3eae18c commit c83c562

File tree

9 files changed

+97
-10
lines changed

9 files changed

+97
-10
lines changed

.github/workflows/python-testing.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ jobs:
3434
- name: Set up Python ${{ matrix.python-version }}
3535
uses: actions/setup-python@v2
3636
with:
37-
python-version: 3.6
37+
python-version: 3.7
3838
- name: Install dependencies
3939
run: |
40-
python3 -m pip install --upgrade pip
40+
python3 -m pip install --upgrade pip setuptools setuptools-scm
4141
pip install tox tox-gh-actions
4242
- name: Check
4343
run: |
@@ -49,7 +49,9 @@ jobs:
4949
strategy:
5050
max-parallel: 5
5151
matrix:
52-
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
52+
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11.0-rc.2",
53+
# "3.12"
54+
]
5355

5456
steps:
5557
- uses: actions/checkout@v1

BUILDING.rst

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
.. _build-semver:
2+
3+
Building semver
4+
===============
5+
6+
.. _PEP 517: https://www.python.org/dev/peps/pep-0517/
7+
.. _PEP 621: https://www.python.org/dev/peps/pep-0621/
8+
.. _A Practical Guide to Setuptools and Pyproject.toml: https://godatadriven.com/blog/a-practical-guide-to-setuptools-and-pyproject-toml/
9+
.. _Declarative config: https://setuptools.rtfd.io/en/latest/userguide/declarative_config.html
10+
11+
12+
This project changed slightly its way how it is built. The reason for this
13+
was to still support the "traditional" way with :command:`setup.py`,
14+
but at the same time try out the newer way with :file:`pyproject.toml`.
15+
Over time, once Python 3.6 gets deprecated, we will support only the newer way.
16+
17+
18+
Background information
19+
----------------------
20+
21+
Skip this section and head over to :ref:`build-pyproject-build` if you just
22+
want to know how to build semver.
23+
This section gives some background information how this project is set up.
24+
25+
The traditional way with :command:`setup.py` in this project uses a
26+
`Declarative config`_. With this approach, the :command:`setup.py` is
27+
stripped down to its bare minimum and all the metadata is stored in
28+
:file:`setup.cfg`.
29+
30+
The new :file:`pyproject.toml` contains only information about the build backend, currently setuptools.build_meta. The idea is taken from
31+
`A Practical Guide to Setuptools and Pyproject.toml`_.
32+
Setuptools-specific configuration keys as defined in `PEP 621`_ are currently
33+
not used.
34+
35+
36+
.. _build-pyproject-build:
37+
38+
Building with pyproject-build
39+
-----------------------------
40+
41+
To build semver you need:
42+
43+
* The :mod:`build` module which implements the `PEP 517`_ build
44+
frontend.
45+
Install it with::
46+
47+
pip install build
48+
49+
Some Linux distributions has already packaged it. If you prefer
50+
to use the module with your package manager, search for
51+
:file:`python-build` or :file:`python3-build` and install it.
52+
53+
* The command :command:`pyproject-build` from the :mod:`build` module.
54+
55+
To build semver, run::
56+
57+
pyproject-build
58+
59+
After the command is finished, you can find two files in the :file:`dist` folder: a ``.tar.gz`` and a ``.whl`` file.

MANIFEST.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
include *.rst
22
include *.txt
3-
include test_*.py
3+
include tests/test_*.py
44

5-
exclude .travis.yml
65
prune docs/_build
76
recursive-exclude .github *
87

changelog.d/364.feature.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Enhance :file:`pyproject.toml` to make it possible to use the
2+
:command:`pyproject-build` command from the build module.
3+
For more information, see :ref:`build-semver`.

docs/build.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. include:: ../BUILDING.rst

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Semver |version| -- Semantic Versioning
99
:caption: Contents
1010
:hidden:
1111

12+
build
1213
install
1314
usage/index
1415
migration/index

pyproject.toml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1+
#
2+
#
3+
# See also https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
4+
#
5+
# General idea taken from
6+
# https://godatadriven.com/blog/a-practical-guide-to-setuptools-and-pyproject-toml/
7+
18
[build-system]
29
requires = [
310
# sync with setup.py until we discard non-pep-517/518
4-
"setuptools>=40.0",
11+
"setuptools",
512
"setuptools-scm",
613
"wheel",
14+
"build",
715
]
816
build-backend = "setuptools.build_meta"
917

18+
19+
1020
[tool.black]
1121
line-length = 88
1222
target-version = ['py36', 'py37', 'py38', 'py39', 'py310']
@@ -22,7 +32,7 @@ include = '''
2232

2333
[tool.towncrier]
2434
package = "semver"
25-
# package_dir = "src"
35+
package_dir = "src"
2636
filename = "CHANGELOG.rst"
2737
directory = "changelog.d/"
2838
title_format = "Version {version}"

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ classifiers =
3131
Programming Language :: Python :: 3.8
3232
Programming Language :: Python :: 3.9
3333
Programming Language :: Python :: 3.10
34+
Programming Language :: Python :: 3.11
3435
Topic :: Software Development :: Libraries :: Python Modules
3536
license = BSD
3637

@@ -56,6 +57,7 @@ norecursedirs = .git build .env/ env/ .pyenv/ .tmp/ .eggs/ venv/
5657
testpaths = tests docs
5758
filterwarnings =
5859
ignore:Function 'semver.*:DeprecationWarning
60+
# ' <- This apostroph is just to fix syntax highlighting
5961
addopts =
6062
--no-cov-on-fail
6163
--cov=semver

tox.ini

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,38 @@
11
[tox]
22
envlist =
33
checks
4-
py{36,37,38,39,310}
4+
py3{6,7,8,9,10,11,12}
55
isolated_build = True
6+
skip_missing_interpreters = True
67

78
[gh-actions]
89
python =
910
3.6: py36
10-
3.7: py37
11+
# setuptools >=62 needs Python >=3.7
12+
3.7: py37,check
1113
3.8: py38
1214
3.9: py39
1315
3.10: py310
16+
3.11: py311
17+
3.12: py312
1418

1519

1620
[testenv]
17-
description = Run test suite for {basepython}
21+
description =
22+
py36: Run a slightly different test suite for {basepython}
23+
!py36: Run test suite for {basepython}
1824
allowlist_externals = make
1925
commands = pytest {posargs:}
2026
deps =
2127
pytest
2228
pytest-cov
29+
# py36: dataclasses
30+
!py36: setuptools>=62.0
31+
!py36: setuptools-scm
2332
setenv =
2433
PIP_DISABLE_PIP_VERSION_CHECK = 1
2534

35+
2636
[testenv:black]
2737
description = Check for formatting changes
2838
basepython = python3

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy