Skip to content

Fix #364: Improve pyproject.toml #361

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

Merged
merged 1 commit into from
Oct 4, 2022
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
8 changes: 5 additions & 3 deletions .github/workflows/python-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: 3.7
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade pip setuptools setuptools-scm
pip install tox tox-gh-actions
- name: Check
run: |
Expand All @@ -49,7 +49,9 @@ jobs:
strategy:
max-parallel: 5
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11.0-rc.2",
# "3.12"
]

steps:
- uses: actions/checkout@v1
Expand Down
59 changes: 59 additions & 0 deletions BUILDING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
.. _build-semver:

Building semver
===============

.. _PEP 517: https://www.python.org/dev/peps/pep-0517/
.. _PEP 621: https://www.python.org/dev/peps/pep-0621/
.. _A Practical Guide to Setuptools and Pyproject.toml: https://godatadriven.com/blog/a-practical-guide-to-setuptools-and-pyproject-toml/
.. _Declarative config: https://setuptools.rtfd.io/en/latest/userguide/declarative_config.html


This project changed slightly its way how it is built. The reason for this
was to still support the "traditional" way with :command:`setup.py`,
but at the same time try out the newer way with :file:`pyproject.toml`.
Over time, once Python 3.6 gets deprecated, we will support only the newer way.


Background information
----------------------

Skip this section and head over to :ref:`build-pyproject-build` if you just
want to know how to build semver.
This section gives some background information how this project is set up.

The traditional way with :command:`setup.py` in this project uses a
`Declarative config`_. With this approach, the :command:`setup.py` is
stripped down to its bare minimum and all the metadata is stored in
:file:`setup.cfg`.

The new :file:`pyproject.toml` contains only information about the build backend, currently setuptools.build_meta. The idea is taken from
`A Practical Guide to Setuptools and Pyproject.toml`_.
Setuptools-specific configuration keys as defined in `PEP 621`_ are currently
not used.


.. _build-pyproject-build:

Building with pyproject-build
-----------------------------

To build semver you need:

* The :mod:`build` module which implements the `PEP 517`_ build
frontend.
Install it with::

pip install build

Some Linux distributions has already packaged it. If you prefer
to use the module with your package manager, search for
:file:`python-build` or :file:`python3-build` and install it.

* The command :command:`pyproject-build` from the :mod:`build` module.

To build semver, run::

pyproject-build

After the command is finished, you can find two files in the :file:`dist` folder: a ``.tar.gz`` and a ``.whl`` file.
3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
include *.rst
include *.txt
include test_*.py
include tests/test_*.py

exclude .travis.yml
prune docs/_build
recursive-exclude .github *

Expand Down
3 changes: 3 additions & 0 deletions changelog.d/364.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhance :file:`pyproject.toml` to make it possible to use the
:command:`pyproject-build` command from the build module.
For more information, see :ref:`build-semver`.
1 change: 1 addition & 0 deletions docs/build.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. include:: ../BUILDING.rst
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Semver |version| -- Semantic Versioning
:caption: Contents
:hidden:

build
install
usage/index
migration/index
Expand Down
14 changes: 12 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
#
#
# See also https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
#
# General idea taken from
# https://godatadriven.com/blog/a-practical-guide-to-setuptools-and-pyproject-toml/

[build-system]
requires = [
# sync with setup.py until we discard non-pep-517/518
"setuptools>=40.0",
"setuptools",
"setuptools-scm",
"wheel",
"build",
]
build-backend = "setuptools.build_meta"



[tool.black]
line-length = 88
target-version = ['py36', 'py37', 'py38', 'py39', 'py310']
Expand All @@ -22,7 +32,7 @@ include = '''

[tool.towncrier]
package = "semver"
# package_dir = "src"
package_dir = "src"
filename = "CHANGELOG.rst"
directory = "changelog.d/"
title_format = "Version {version}"
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ classifiers =
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Topic :: Software Development :: Libraries :: Python Modules
license = BSD

Expand All @@ -56,6 +57,7 @@ norecursedirs = .git build .env/ env/ .pyenv/ .tmp/ .eggs/ venv/
testpaths = tests docs
filterwarnings =
ignore:Function 'semver.*:DeprecationWarning
# ' <- This apostroph is just to fix syntax highlighting
addopts =
--no-cov-on-fail
--cov=semver
Expand Down
16 changes: 13 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
[tox]
envlist =
checks
py{36,37,38,39,310}
py3{6,7,8,9,10,11,12}
isolated_build = True
skip_missing_interpreters = True

[gh-actions]
python =
3.6: py36
3.7: py37
# setuptools >=62 needs Python >=3.7
3.7: py37,check
3.8: py38
3.9: py39
3.10: py310
3.11: py311
3.12: py312


[testenv]
description = Run test suite for {basepython}
description =
py36: Run a slightly different test suite for {basepython}
!py36: Run test suite for {basepython}
allowlist_externals = make
commands = pytest {posargs:}
deps =
pytest
pytest-cov
# py36: dataclasses
!py36: setuptools>=62.0
!py36: setuptools-scm
setenv =
PIP_DISABLE_PIP_VERSION_CHECK = 1


[testenv:black]
description = Check for formatting changes
basepython = python3
Expand Down