Skip to content
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

Support pyproject.toml #91

Merged
merged 31 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b51bf9d
First cut of pyproject.toml support
twm Jul 1, 2024
d383fce
Add newsfragment
twm Jul 1, 2024
690ae46
Reorganize tests
twm Jul 2, 2024
01bf22b
Make tomli more optional
twm Jul 2, 2024
74acefb
Clean up MyPy issues
twm Jul 2, 2024
8dea8f6
Runtime dep too
twm Jul 2, 2024
3a8d26d
What version of setuptools?
twm Jul 2, 2024
66ecb82
Remove some unreachable code
twm Jul 2, 2024
28a1446
Backfill some unit tests
twm Jul 2, 2024
1074d55
Move packaging metadata to pyproject.toml
twm Jul 2, 2024
8e1ae1d
Fix readme syntax
twm Jul 2, 2024
e1682eb
A new approach
twm Jul 3, 2024
b2d4d8e
Bump setuptools dep
twm Jul 3, 2024
d08ff9d
Fix docstring syntax
twm Jul 3, 2024
54380ca
Update readme
twm Jul 3, 2024
895a9a9
Fix type annotation
twm Jul 3, 2024
4d5a6f8
Re-enable build isolation
twm Jul 3, 2024
59f0f38
Use coverage-p
twm Jul 7, 2024
fe3f0d3
Actually fix type annotation
twm Jul 7, 2024
690994e
Omit redundant license text
twm Jul 7, 2024
799b7f1
Fix coverage capture
twm Jul 7, 2024
a7e100e
Fix more MyPy noise
twm Jul 7, 2024
81bfd06
Skip the remaining coverage holes
twm Jul 7, 2024
6f17f0e
Remove unnecessary build deps
twm Jul 7, 2024
6e6e4ee
Write all coverage to {toxinidir}
twm Jul 7, 2024
bd4d87b
A fresh new setuptools hack
twm Jul 7, 2024
6cce917
Reduce diff size
twm Jul 7, 2024
bb8a918
Add Framework :: Setuptools Plugin classifier
twm Jul 7, 2024
9ddfbc9
Minor docstring tweaks
twm Jul 7, 2024
2a50e4c
Fix actions reference
twm Jul 7, 2024
e12b04a
Fix up MANIFEST.in
twm Jul 7, 2024
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
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ source_pkgs = incremental
# List of directory names.
source = tests
branch = True
parallel = True
# This must be an absolute path because the example tests
# run Python processes with alternative working directories.
data_file = ${TOX_INI_DIR-.}/.coverage
glyph marked this conversation as resolved.
Show resolved Hide resolved

[paths]
source =
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ jobs:
run: |
# Assign the coverage file a name unique to this job so that the
# uploads don't collide.
mv .coverage ".coverage-job-${{ matrix.python-version }}-${{ matrix.job-name }}"
mv .coverage ".coverage-job-${{ matrix.python-version }}-${{ matrix.tox-env }}"

- name: Store coverage file
if: ${{ !cancelled() && !matrix.skip-coverage }}
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.python-version }}-${{ matrix.job-name }}
name: coverage-${{ matrix.python-version }}-${{ matrix.tox-env }}
path: .coverage-job-*

coverage-report:
Expand Down
53 changes: 41 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,75 @@ Incremental

Incremental is a small library that versions your Python projects.

API documentation can be found `here <https://twisted.github.io/incremental/docs/>`_.
API documentation can be found `here <https://twisted.org/incremental/docs/>`_.


Quick Start
-----------

Add this to your ``setup.py``\ 's ``setup()`` call, removing any other versioning arguments:
In your ``pyproject.toml``, add Incremental to your build requirements:

.. code::
.. code-block:: toml

setup(
use_incremental=True,
setup_requires=['incremental'],
install_requires=['incremental'], # along with any other install dependencies
...
}
[build-system]
requires = ["setuptools", "incremental>=NEXT"]
build-backend = "setuptools.build_meta"

Specify the project's version as dynamic:

.. code-block:: toml

[project]
name = "<projectname>"
dynamic = ["version"]

Remove any ``version`` line and any ``[tool.setuptools.dynamic] version = `` entry.

Add this empty block to activate Incremental's setuptools plugin:

.. code-block:: toml

[tool.incremental]

Install Incremental to your local environment with ``pip install incremental[scripts]``.
Then run ``python -m incremental.update <projectname> --create``.
It will create a file in your package named ``_version.py`` and look like this:

.. code::
.. code:: python

from incremental import Version

__version__ = Version("widgetbox", 17, 1, 0)
__version__ = Version("<projectname>", 24, 1, 0)
__all__ = ["__version__"]


Then, so users of your project can find your version, in your root package's ``__init__.py`` add:

.. code::
.. code:: python

from ._version import __version__


Subsequent installations of your project will then use Incremental for versioning.


Using ``setup.py``
~~~~~~~~~~~~~~~~~~

Incremental may be used from ``setup.py`` instead of ``pyproject.toml``.
Add this to your ``setup()`` call, removing any other versioning arguments:

.. code:: python

setup(
use_incremental=True,
setup_requires=['incremental'],
install_requires=['incremental'], # along with any other install dependencies
...
}

Then proceed with the ``incremental.update`` command above.

Incremental Versions
--------------------

Expand Down
18 changes: 18 additions & 0 deletions _build_meta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
Comply with PEP 517's restictions on in-tree backends.
glyph marked this conversation as resolved.
Show resolved Hide resolved

We use setuptools to package Incremental and want to activate
the in-tree Incremental plugin to manage its own version. To do
this we specify ``backend-path`` in our ``pyproject.toml``,
but PEP 517 requires that when ``backend-path`` is specified:

> The backend code MUST be loaded from one of the directories
> specified in backend-path (i.e., it is not permitted to
> specify backend-path and not have in-tree backend code).

We comply by re-publishing setuptools' ``build_meta``.
"""

from setuptools import build_meta

__all__ = ["build_meta"]
55 changes: 52 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,57 @@
[build-system]
requires = [
"setuptools >= 44.1.1",
"wheel >= 0.36.2",
# Keep this aligned with the project dependencies.
"setuptools >= 61.0",
"tomli; python_version < '3.11'",
]
build-backend = "setuptools.build_meta"
backend-path = [".", "./src"] # See _build_meta.py
build-backend = "_build_meta:build_meta"

[project]
name = "incremental"
dynamic = ["version"]
maintainers = [
{name = "Amber Brown", email = "[email protected]"},
]
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Framework :: Setuptools Plugin",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
requires-python = ">=3.8"
description = "A small library that versions your Python projects."
readme = "README.rst"
dependencies = [
"setuptools >= 61.0",
"tomli; python_version < '3.11'",
]

[project.optional-dependencies]
scripts = [
"click>=6.0",
]
mypy = [
"mypy==0.812",
]

[project.urls]
Homepage = "https://github.com/twisted/incremental"
Documentation = "https://twisted.org/incremental/docs/"
Issues = "https://github.com/twisted/incremental/issues"
Changelog = "https://github.com/twisted/incremental/blob/trunk/NEWS.rst"

[project.entry-points."distutils.setup_keywords"]
use_incremental = "incremental:_get_distutils_version"
[project.entry-points."setuptools.finalize_distribution_options"]
incremental = "incremental:_get_setuptools_version"

[tool.incremental]

[tool.black]
target-version = ['py36', 'py37', 'py38']
Expand All @@ -12,3 +60,4 @@ target-version = ['py36', 'py37', 'py38']
filename = "NEWS.rst"
package_dir = "src/"
package = "incremental"
issue_format = "`#{issue} <https://github.com/twisted/incremental/issues/{issue}>`__"
45 changes: 0 additions & 45 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,48 +1,3 @@
[metadata]
name = incremental
version = attr: incremental._setuptools_version
maintainer = Amber Brown
maintainer_email = [email protected]
url = https://github.com/twisted/incremental
classifiers =
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Programming Language :: Python :: 3
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
license = MIT
description = "A small library that versions your Python projects."
long_description = file: README.rst
install_requires =
setuptools

[options]
packages = find:
package_dir = =src
zip_safe = False

[options.packages.find]
where = src
exclude = exampleproj

[options.package_data]
incremental = py.typed

[options.entry_points]
distutils.setup_keywords =
use_incremental = incremental:_get_version

[options.extras_require]
scripts =
click>=6.0
twisted>=16.4.0
mypy =
%(scripts)s
mypy==0.812

[flake8]
max-line-length = 88
extend-ignore =
Expand Down
3 changes: 0 additions & 3 deletions setup.py

This file was deleted.

8 changes: 0 additions & 8 deletions src/exampleproj/_version.py

This file was deleted.

Loading