Skip to content

Update build process to current standards #84

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

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
pip install -r .github/requirements.txt
- name: Test with pytest
run: |
python setup.py test
python -m pytest
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
__pycache__/
/.env
/MANIFEST
/_meta.py
/build/
/dist/
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ build:
post_checkout:
- git fetch --unshallow
post_install:
- python setup.py build
- python -m pip install -e .

sphinx:
configuration: doc/src/conf.py
Expand Down
2 changes: 2 additions & 0 deletions .rtd-require
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
git-props
pytest >=3.7.0
setuptools
build
pip
sphinx-copybutton
sphinx_rtd_theme
15 changes: 7 additions & 8 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
include CHANGES.rst
include LICENSE.txt
include MANIFEST.in
include README.rst
include _meta.py
recursive-exclude .github *
exclude .gitignore
exclude .readthedocs.yaml
exclude .rtd-require
recursive-exclude doc *
include doc/examples/*.py
include tests/conftest.py
include tests/pytest.ini
include tests/test_*.py
exclude Makefile
exclude python-pytest-dependency.spec
12 changes: 4 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ BUILDLIB = $(CURDIR)/build/lib


build:
$(PYTHON) setup.py build
$(PYTHON) -m build

test:
$(PYTHON) setup.py test
$(PYTHON) -m pytest

sdist:
$(PYTHON) setup.py sdist
$(PYTHON) -m build --sdist

doc-html: build
$(MAKE) -C doc html PYTHONPATH=$(BUILDLIB)
Expand All @@ -19,13 +19,9 @@ clean:
rm -rf __pycache__

distclean: clean
rm -f MANIFEST _meta.py
rm -rf dist
rm -rf tests/.pytest_cache
$(MAKE) -C doc distclean

meta:
$(PYTHON) setup.py meta


.PHONY: build test sdist doc-html clean distclean meta
.PHONY: build test sdist doc-html clean distclean
10 changes: 6 additions & 4 deletions doc/src/conf.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config

from importlib.metadata import version, PackageNotFoundError
from pathlib import Path
import sys

Expand All @@ -19,11 +18,14 @@
# -- Project information -----------------------------------------------------

project = 'pytest-dependency'
copyright = '2016–2023, Rolf Krahl'
copyright = '2016–2025, Rolf Krahl'
author = 'Rolf Krahl'

# The full version, including alpha/beta/rc tags
release = pytest_dependency.__version__
try:
release = version(project)
except PackageNotFoundError:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will discover the version of the currently installed version. Not the version of the package that the current document build is running from.

Copy link
Contributor Author

@DimitriPapadopoulos DimitriPapadopoulos Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can write to pytest_dependency.__version__, no problem, but need to make sure pytest_dependency.__version__ is written before building the documentation.

release = '0.0.0'
# The short X.Y version
version = ".".join(release.split(".")[0:2])

Expand Down
34 changes: 34 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[build-system]
requires = ["setuptools>=64", "setuptools-scm"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing a plain Python package is such a trivial task that I don't like to to add extra requirements just for this. setuptools (without version constraint) is an exception that I'm willing to take, but I prefer not to go beyond that.

Copy link
Contributor Author

@DimitriPapadopoulos DimitriPapadopoulos Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requiring a (not so much) recent setuptools at build time is not a strong requirement. Besides, even at installation time, setuptools needs to be current. From the Python Packaging User Guide:

Ensure pip, setuptools, and wheel are up to date

While pip alone is sufficient to install from pre-built binary archives, up to date copies of the setuptools and wheel projects are useful to ensure you can also install from source archives:

I can understand why you want to remove setuptools_scm.

All Python packages are moving to recent versions of setuptools, that's the direction taken by the whole community. I don't understand arguments such as "I prefer not to".

build-backend = "setuptools.build_meta"

[project]
name = "pytest-dependency"
description = "Manage dependencies of tests"
authors = [{name = "Rolf Krahl", email = "[email protected]"}]
readme = "README.rst"
requires-python = ">=3.4"
dependencies = [
"pytest>=3.7.0",
]
dynamic = ["version"]
classifiers = [
"Development Status :: 4 - Beta",
"Framework :: Pytest",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to explicitly list the Python version the respective release supports. It makes it easier when you browse PyPI and to answer questions like "what was the last release that did support Python X.Y?"

And, before you ask: yes before making any release I do test with all officially supported Python versions. I'm not relying on the GitHub workflow alone for that.

Copy link
Contributor Author

@DimitriPapadopoulos DimitriPapadopoulos Aug 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what requires-python = ">=3.4" is for. It does appear in PyPI. Why duplicate the information?

"Topic :: Software Development :: Testing",
]

[project.urls]
Homepage = "https://github.com/RKrahl/pytest-dependency"
Documentation = "https://pytest-dependency.readthedocs.io"
Source = "https://github.com/RKrahl/pytest-dependency.git"
Download = "https://github.com/RKrahl/pytest-dependency/releases/"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current setup.py sets the Download URL to "https://github.com/RKrahl/pytest-dependency/releases/%s/" % release for a very good reason: as you can see see on the PyPI package page for release 0.6.0, it directly points to https://github.com/RKrahl/pytest-dependency/releases/0.6.0/, not to https://github.com/RKrahl/pytest-dependency/releases/ or https://github.com/RKrahl/pytest-dependency/releases/tag/latest/

This has the advantage that this link always matches the version you are looking at and remains valid also if I publish new releases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it requires to execute code at installation time, which is to be avoided.

Changelog = "https://pytest-dependency.readthedocs.io/en/latest/changelog.html"

[project.entry-points.pytest11]
dependency = "pytest_dependency"
169 changes: 0 additions & 169 deletions setup.py

This file was deleted.

2 changes: 0 additions & 2 deletions src/pytest_dependency.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""$DOC"""

__version__ = "$VERSION"

import logging
import pytest

Expand Down
Loading