@ -69,8 +69,7 @@ the package's runtime dependencies need to also be included as build requirement
@@ -69,8 +69,7 @@ the package's runtime dependencies need to also be included as build requirement
Hence, `%pyproject_buildrequires` also generates runtime dependencies by default.
For this to work, the project's build system must support the
@ -147,6 +212,7 @@ Then, use the `%tox` macro in `%check`:
@@ -147,6 +212,7 @@ Then, use the `%tox` macro in `%check`:
The macro:
- Sets environment variables via `%{py3_test_envvars}`, namely:
- Always prepends `$PATH` with `%{buildroot}%{_bindir}`
- If not defined, sets `$PYTHONPATH` to `%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}`
- If not defined, sets `$TOX_TESTENV_PASSENV` to `*`
@ -220,8 +286,14 @@ However, in Fedora packages, always list executables explicitly to avoid uninten
@@ -220,8 +286,14 @@ However, in Fedora packages, always list executables explicitly to avoid uninten
`%pyproject_save_files` can automatically mark license files with `%license` macro
and language (`*.mo`) files with `%lang` macro and appropriate language code.
Only license files declared via [PEP 639] `License-Field` field are detected.
Only license files declared via [PEP 639] `License-File` field are detected.
[PEP 639] is still a draft and can be changed in the future.
It is possible to use the `-l` flag to declare that a missing license should
terminate the build or `-L` (the default) to explicitly disable this check.
Packagers are encouraged to use the `-l` flag when the `%license` file is not manually listed in `%files`
to avoid accidentally losing the file in a future version.
When the `%license` file is manually listed in `%files`,
packagers can use the `-L` flag to ensure future compatibility in case the `-l` behavior eventually becomes a default.
Note that `%pyproject_save_files` uses data from the [RECORD file](https://www.python.org/dev/peps/pep-0627/).
If you wish to rename, remove or otherwise change the installed files of a package
@ -241,6 +313,7 @@ If `%pyproject_save_files` is not used, calling `%pyproject_check_import` will f
@@ -241,6 +313,7 @@ If `%pyproject_save_files` is not used, calling `%pyproject_check_import` will f
When `%pyproject_save_files` is invoked,
it creates a list of all valid and public (i.e. not starting with `_`)
importable module names found in the package.
Each top-level module name matches at least one of the globs provided as an argument to `%pyproject_save_files`.
This list is then usable by `%pyproject_check_import` which performs an import check for each listed module.
When a module fails to import, the build fails.
@ -275,6 +348,12 @@ The `%pyproject_check_import` macro also accepts positional arguments with
@@ -275,6 +348,12 @@ The `%pyproject_check_import` macro also accepts positional arguments with
additional qualified module names to check, useful for example if some modules are installed manually.
Note that filtering by `-t`/`-e` also applies to the positional arguments.
Another macro, `%_pyproject_check_import_allow_no_modules` allows to pass the import check,
even if no Python modules are detected in the package.
This may be a valid case for packages containing e.g. typing stubs.
Don't use this macro in Fedora packages.
It's only intended to be used in automated build environments such as Copr.
Generating Extras subpackages
-----------------------------
@ -306,73 +385,6 @@ These arguments are still required:
@@ -306,73 +385,6 @@ These arguments are still required:
Multiple subpackages are generated when multiple names are provided.
PROVISIONAL: Importing just-built (extension) modules in %build
@ -89,7 +89,7 @@ Bad character in version:
@@ -89,7 +89,7 @@ Bad character in version:
Single value version with unsupported compatible operator:
installed:
toml: 1
tomli: 1
pyproject.toml: |
[build-system]
requires = ["pkg ~= 42", "foo"]
@ -98,7 +98,7 @@ Single value version with unsupported compatible operator:
@@ -98,7 +98,7 @@ Single value version with unsupported compatible operator:
Asterisk in version with unsupported compatible operator:
installed:
toml: 1
tomli: 1
pyproject.toml: |
[build-system]
requires = ["pkg ~= 0.1.*", "foo"]
@ -107,7 +107,7 @@ Asterisk in version with unsupported compatible operator:
@@ -107,7 +107,7 @@ Asterisk in version with unsupported compatible operator:
Local path as requirement:
installed:
toml: 1
tomli: 1
pyproject.toml: |
[build-system]
requires = ["./pkg-1.2.3.tar.gz", "foo"]
@ -116,7 +116,7 @@ Local path as requirement:
@@ -116,7 +116,7 @@ Local path as requirement:
Pip's egg=pkgName requirement not in requirements file:
@ -137,7 +137,7 @@ Build system dependencies in pyproject.toml with extras:
@@ -137,7 +137,7 @@ Build system dependencies in pyproject.toml with extras:
installed:
setuptools: 50
wheel: 1
toml: 1
tomli: 1
pyproject.toml: |
[build-system]
requires = [
@ -186,7 +186,7 @@ Build system dependencies in pyproject.toml without extras:
@@ -186,7 +186,7 @@ Build system dependencies in pyproject.toml without extras:
installed:
setuptools: 50
wheel: 1
toml: 1
tomli: 1
pyproject.toml: |
[build-system]
requires = [
@ -268,6 +268,8 @@ Run dependencies with extras (not selected):
@@ -268,6 +268,8 @@ Run dependencies with extras (not selected):
def main():
setup(
name = "pytest",
version = "6.6.6",
setup_requires=["setuptools>=40.0"],
# fmt: off
extras_require={
@ -358,7 +360,38 @@ Run dependencies with multiple extras:
@@ -358,7 +360,38 @@ Run dependencies with multiple extras:
python3dist(dep1)
result: 0
Tox dependencies:
Run dependencies with extras and build wheel option:
installed:
setuptools: 50
wheel: 1
pyyaml: 1
pip: 20
include_runtime: true
build_wheel: true
extras:
- testing
setup.py: *pytest_setup_py
expected: |
python3dist(setuptools) >= 40.8
python3dist(wheel)
python3dist(wheel)
python3dist(setuptools) >= 40
python3dist(pip) >= 19
python3dist(py) >= 1.5
python3dist(six) >= 1.10
python3dist(setuptools)
python3dist(attrs) >= 17.4
python3dist(atomicwrites) >= 1
python3dist(pluggy) >= 0.11
python3dist(more-itertools) >= 4
python3dist(argcomplete)
python3dist(hypothesis) >= 3.56
python3dist(nose)
python3dist(requests)
result: 0
stderr_contains: "Reading metadata from {wheeldir}/pytest-6.6.6-py3-none-any.whl"
Default build system, unmet deps in requirements file:
@ -576,7 +693,7 @@ With pyproject.toml, requirements file and with -N option:
@@ -576,7 +693,7 @@ With pyproject.toml, requirements file and with -N option:
installed:
setuptools: 50
wheel: 1
toml: 1
tomli: 1
lxml: 3.9
ncclient: 1
cryptography: 2
@ -612,7 +729,7 @@ With pyproject.toml, requirements file and without -N option:
@@ -612,7 +729,7 @@ With pyproject.toml, requirements file and without -N option:
installed:
setuptools: 50
wheel: 1
toml: 1
tomli: 1
lxml: 3.9
ncclient: 1
cryptography: 2
@ -723,7 +840,7 @@ Pre-releases are accepted:
@@ -723,7 +840,7 @@ Pre-releases are accepted:
installed:
setuptools: 50
wheel: 1
toml: 1
tomli: 1
cffi: 1.15.0rc2
pyproject.toml: |
[build-system]
@ -740,3 +857,208 @@ Pre-releases are accepted:
@@ -740,3 +857,208 @@ Pre-releases are accepted:
python3dist(wheel)
stderr_contains: "Requirement satisfied: cffi"
result: 0
Stdout from wrapped subprocess does not appear in output:
installed:
setuptools: 50
wheel: 1
include_runtime: false
setup.py: |
import os
os.system('echo LEAK?')
from setuptools import setup
setup(name='test', version='0.1')
expected: |
python3dist(setuptools) >= 40.8
python3dist(wheel)
python3dist(wheel)
result: 0
pyproject.toml with runtime dependencies:
skipif: not SETUPTOOLS_60
installed:
setuptools: 50
wheel: 1
tomli: 1
pyproject.toml: |
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "my_package"
version = "0.1"
dependencies = [
"foo",
'importlib-metadata; python_version<"3.8"',
]
expected: |
python3dist(setuptools)
python3dist(wheel)
python3dist(foo)
result: 0
pyproject.toml with runtime dependencies and partially selected extras:
skipif: not SETUPTOOLS_60
installed:
setuptools: 50
wheel: 1
tomli: 1
extras:
- tests
pyproject.toml: |
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
[project]
name = "my_package"
version = "0.1"
dependencies = [
"foo",
'importlib-metadata; python_version<"3.8"',
]
[project.optional-dependencies]
tests = ["pytest>=5", "pytest-mock"]
docs = ["sphinx", "python-docs-theme"]
expected: |
python3dist(setuptools)
python3dist(wheel)
python3dist(foo)
python3dist(pytest) >= 5
python3dist(pytest-mock)
result: 0
Self-referencing extras (sooner):
installed:
setuptools: 50
wheel: 1
tomli: 1
extras:
- dev # this is deliberately sooner in the alphabet than the referenced ones
pyproject.toml: |
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
setup.cfg: |
[metadata]
name = my_package
version = 0.1
[options]
install_requires =
foo
importlib-metadata; python_version<"3.8"
[options.extras_require]
tests = pytest>=5; pytest-mock
docs = sphinx; python-docs-theme
dev = my_package[docs,tests]
expected: |
python3dist(setuptools)
python3dist(wheel)
python3dist(foo)
python3dist(sphinx)
python3dist(python-docs-theme)
python3dist(pytest) >= 5
python3dist(pytest-mock)
result: 0
Self-referencing extras (later):
installed:
setuptools: 50
wheel: 1
tomli: 1
extras:
- xdev # this is deliberately later in the alphabet than the referenced ones
@ -118,11 +183,117 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
@@ -118,11 +183,117 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856