Commit Graph

238 Commits

Author SHA1 Message Date
Miro Hrončok
a613e176e3 Handle Python Extras in %pyproject_buildrequires on Fedora 33+
There is a slight problem when reporting that a dependency with extra is satisfied.
In fact, we only check the "base" dependency.
This can lead to a problem when a dependency is wrongly assumed as present
and the script proceeds to the "next stage" without restarting --
if the next stage tries to use (import) the missing dependency,
the script would crash.

However, that might be a very unlikely set of events and if such case ever happens,
we'll workaround it or fix it.
2020-08-20 15:30:49 +02:00
Petr Viktorin
91acc88e2d Make %{_pyproject_wheeldir} an implementation detail 2020-08-20 12:02:34 +02:00
Petr Viktorin
fb4066b150 Update README
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1868346

- Explain what "provisional" means
- Say what kinds of projects the macros handle
- Tell people to BuidRequire python*-devel
- Say %pyproject_buildrequires is needed for the other macros
- Note that %pyproject_buildrequires generates `exit 11` messages
- Note that most buildsystems have prepare-metadata-for-build-wheel
2020-08-20 12:00:28 +02:00
Petr Viktorin
09be4c117d Typo fix 2020-08-20 11:48:14 +02:00
Miro Hrončok
6a8d86ed70 Allow multiple, comma-separated extras in %pyproject_buildrequires -x 2020-08-11 15:54:42 +02:00
Lumir Balhar
59bc07b713 Release bump and changelog for universal macros 2020-08-10 12:05:45 +02:00
Lumir Balhar
cb8e334272 Use python -m tox instead of just tox
This way, macros can use whatever Python has tox module available
instead of only the main one which owns /usr/bin/tox.
2020-08-10 12:04:22 +02:00
Lumir Balhar
5561755a00 Make %pyproject_buildrequires more universal
so it can work with any non-main Python version and generate
proper dependencies.
2020-08-10 12:04:22 +02:00
Lumir Balhar
64e45518ef Use versioned pathfixX.Y.py script
so pyproject-rpm-macros can depend on any pythonX.Y-devel package
2020-08-10 12:04:22 +02:00
Miro Hrončok
99d9596d7c Make sure to put * in '' in %pyproject_save_files
Otherwise, it may be expanded by Shell in random cases.
2020-08-06 20:19:40 +02:00
Tomas Hrnciar
bd0f6049de Update test yaml with newly added specs 2020-08-06 15:26:37 +02:00
Tomas Hrnciar
1fc1c18fd9 Removes bindir parameter from script
This parameter is not necessary anymore with +auto argument replacing +bindir.
2020-08-06 15:26:37 +02:00
Tomas Hrnciar
c1249414d6 Add definition for DATADIR 2020-08-06 15:26:37 +02:00
Tomas Hrnciar
5809bbc77e Replace +bindir with +auto in README and spec files 2020-08-06 15:26:37 +02:00
Tomas Hrnciar
d0d4060cec Add test for +auto argument to include .pth files in other files 2020-08-06 15:26:37 +02:00
Tomas Hrnciar
0db4e67f03 Add test for +auto argument to include data files in other files 2020-08-06 15:26:37 +02:00
Tomas Hrnciar
0259b46867 Remove todo comment about .pth files
WRT to addition of +auto argument, all .pth files should be classified
as other files.
2020-08-06 15:26:37 +02:00
Tomas Hrnciar
91c8c27c63 Remove unused "executables" section from script and test data 2020-08-06 15:26:37 +02:00
Tomas Hrnciar
e2c64e79a0 Modify tests to accept all unclassified files in others. 2020-08-06 15:26:37 +02:00
Tomas Hrnciar
79678f7e72 Replace +bindir argument with +auto to include all unclassified files to
filelist.
2020-08-06 15:26:37 +02:00
Miro Hrončok
7e5adc9c02 Fix a copy paste error in %pyproject_extras_subpkg definition
Also, add a comment for unreadable RPM expression.

This is a fixup of cb4e43c670
2020-08-04 15:17:16 +02:00
Miro Hrončok
cb4e43c670 Implement %pyproject_extras_subpkg 2020-07-29 17:40:37 +02:00
Fedora Release Engineering
26607dc0db - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-07-28 23:22:27 +00:00
Miro Hrončok
262f6d3bc3 %pyproject_buildrequires -x now implies -r
The usage without -r errored anyway, this way instead of forcing the user to add it,
we do it ourselves.

Machines stealing human's labor, yet again.
2020-07-16 13:38:50 +02:00
Miro Hrončok
37216e779e Set HOSTNAME to prevent tox 3.17+ from a DNS query
Tox calls socket.getfqdn() and that call does a DNS query.
In mock with disabled networking, it takes a minute until that times out.
When a spec file uses %pyproject_buildrequires -t and %tox, it is a 3 minute delay.

Since 3.17, tox does not call socket.getfqdn() when HOSTNAME variable is set to a value:

https://github.com/tox-dev/tox/pull/1616

The value is only used in result log, so setting it to "rpmbuild"
actually makes the logs more reproducible as well.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1856356
when tox is used in %pyproject_buildrequires -t or %tox.
2020-07-15 13:24:40 +02:00
Miro Hrončok
a723865460 Remove Fedora 30 remnants 2020-06-23 11:09:03 +00:00
Miro Hrončok
ed5dd772f3 Switch from upstream deprecated pytoml to toml 2020-06-23 11:09:03 +00:00
Petr Viktorin
9789724e07 Update python-ldap.spec to fix build failure
Use release 0 to not conflict with Fedora.
2020-06-23 11:04:38 +00:00
Petr Viktorin
82a7579530 Document how to test the macros 2020-06-23 11:48:59 +02:00
Tomas Hrnciar
19f84b1f4c Adapt pyproject_install macro to PEP 610
With changes in PEP 610 there is new file direct_url.json created, since it is not useful
for us we prevent it's creation. This commit changes %pyproject_install macro to install wheel using
name instead of path.

This commit also includes new test to check if file direct_url.json wasn't created.

https://discuss.python.org/t/pep-610-usage-guidelines-for-linux-distributions/4012
2020-05-07 13:08:22 +02:00
Miro Hrončok
95ba8376f5 Handle extracting debuginfo from extension modules
Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1806625

Upstream issue for a proper fix https://github.com/pypa/pip/issues/7555

Co-Authored-By: Petr Viktorin <pviktori@redhat.com>
2020-04-16 15:45:48 +02:00
Patrik Kopkan
2800b49530 Add %pyproject_save_files macro
This macro save generates file section to %pyproject_files. It should
simplify %files section and allow to build by some automatic machinery

Supposed use case in Fedora:
    %install
    %pyproject_install
    %pyproject_save_files requests _requests

    %files -n python3-requests -f %{pyproject_files}
    %doc README.rst
    %license LICENSE

Automatic build of arbitrary packages (e.g. in Copr):
    %install
    %pyproject_install
    %pyproject_save_files * +bindir // save all modules with executables

    %files -n python3-requests -f %{pyproject_files}

Co-Authored-By: Miro Hrončok <miro@hroncok.cz>
2020-04-15 16:45:10 +02:00
Miro Hrončok
fe3aa8f6e9 Fedora CI: Add support for Zuul based CI 2020-03-06 15:05:24 +01:00
Miro Hrončok
430517ec46 Allow runnign the Fedora CI script from different packages 2020-03-06 12:43:09 +01:00
Miro Hrončok
99d952cd6c Tox dependency generator: Handle deps read in from a text file
Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1808601

tox docs: https://tox.readthedocs.io/en/latest/example/basic.html#depending-on-requirements-txt-or-defining-constraints

Relevant tox-current-env issue: https://github.com/fedora-python/tox-current-env/issues/22
2020-03-05 13:44:54 +01:00
Miro Hrončok
9bb7de7385 Fedora CI: Update the mock config to support mock 2.0
See https://github.com/rpm-software-management/mock/wiki/Release-Notes-2.0
2020-02-12 15:29:11 +01:00
Miro Hrončok
dbb90f5dc1 Preserve existing flags in shebangs of Python files in /usr/bin
Use pathfix.py with -k and -a flags

Solves problems like https://bugzilla.redhat.com/show_bug.cgi?id=1335203
2020-02-07 18:35:06 +01:00
Miro Hrončok
6210f94e46 Handle backends with colon, fallback to setuptools.build_meta:__legacy__
Falling back to setuptools.build_meta:__legacy__ is the standard behavior,
not setuptools.build_meta. See PEP 517:

https://www.python.org/dev/peps/pep-0517/

> If the pyproject.toml file is absent, or the build-backend key is missing,
> the source tree is not using this specification, and tools should revert
> to the legacy behaviour of running setup.py (either directly, or by
> implicitly invoking the setuptools.build_meta:__legacy__ backend).

Falling back to setuptools.build_meta had very similar results so far.,
but the behavior might change in the feature.

While working on this, I have uncovered a problem in our code.
It was not able to handle backends with ":". Looking at PEP 517 again:

> build-backend is a string naming a Python object that will be used to
> perform the build. This is formatted following the same module:object syntax
> as a setuptools entry point. For instance, if the string is "flit.api:main",
> this object would be looked up by executing the equivalent of:
>
>    import flit.api
>    backend = flit.api.main
>
> It's also legal to leave out the :object part, e.g.
>
>    build-backend = "flit.api"
>
> which acts like:
>
>    import flit.api
>    backend = flit.api

We now handle such cases properly. Witch the change of the default backend,
we also test a backend with colon in our tests.
2020-02-05 13:31:45 +01:00
Fedora Release Engineering
52b92ea408 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-01-30 10:14:51 +00:00
Miro Hrončok
f50ab5f517 Tests: Simplify tldr.spec
- drop stuff that we don't need to test this
- use macros where possible
- use explicit test command when testing stuff
- make sure dist-info is a directory
2019-11-22 13:56:05 +01:00
Patrik Kopkan
49a323e46e create directory in $PWD for built wheel
It is little bit more explicit than installing wheels from $PWD.
2019-11-21 13:12:18 +01:00
Anna Khaitovich
f2dfb52b9f Add tldr.spec to the tests 2019-11-14 19:27:36 +01:00
Anna Khaitovich
8cce1fad47 Remove stray __pycache__ directory from /usr/bin when running %pyproject_install
Solves bz#1739848
2019-11-14 11:40:28 +01:00
Miro Hrončok
50464a4b19 Satisfy the flake8 linter, unify quotation marks 2019-10-25 17:07:29 +02:00
Miro Hrončok
d5c3fb3c5a When tox fails, print tox output before failing
Previously, it wasn't possible to see why tox failed:

...
Requirement satisfied: tox-current-env >= 0.0.2
   (installed: tox-current-env 0.0.2)
Traceback (most recent call last):
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 269, in main
    generate_requires(
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 221, in generate_requires
    generate_tox_requirements(toxenv, requirements)
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 184, in generate_tox_requirements
    r = subprocess.run(
  File "/usr/lib64/python3.8/subprocess.py", line 512, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['tox', '--print-deps-to-file', '/tmp/tmp96smu4rv', '-qre', 'py38']' returned non-zero exit status 1.

Now it is:

...
Requirement satisfied: tox-current-env >= 0.0.2
   (installed: tox-current-env 0.0.2)
ERROR: tox config file (either pyproject.toml, tox.ini, setup.cfg) not found
Traceback (most recent call last):
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 270, in main
    generate_requires(
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 222, in generate_requires
    generate_tox_requirements(toxenv, requirements)
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 193, in generate_tox_requirements
    r.check_returncode()
  File "/usr/lib64/python3.8/subprocess.py", line 444, in check_returncode
    raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command '['tox', '--print-deps-to-file', '/tmp/tmpwp8sffv1', '-qre', 'py38']' returned non-zero exit status 1.

Inspired by https://src.fedoraproject.org/rpms/python-chaospy/pull-request/1#comment-32750
2019-10-25 16:57:01 +02:00
Miro Hrončok
2262ba2ff5 Fedra CI: Adapt to mock-core-configs >= 31.4 2019-10-08 13:40:26 +02:00
Miro Hrončok
102626373e Move a verbose line of %pyproject_buildrequires from stdout to stderr
The `rm -v` command prints the output to stderr, polluting the generated buildrequires

  $ rm -rfv pytest_harvest.dist-info/
  removed 'pytest_harvest.dist-info/METADATA'
  removed 'pytest_harvest.dist-info/LICENSE'
  removed 'pytest_harvest.dist-info/top_level.txt'
  removed 'pytest_harvest.dist-info/entry_points.txt'
  removed directory 'pytest_harvest.dist-info/'

This can lead to RPM errors:

  error: Dependency tokens must begin with alpha-numeric, '_' or '/': 'pytest_harvest.dist-info/METADATA'

Or bogus dependencies -- the SRPM requires "removed" and "directory".

See https://github.com/rpm-software-management/rpm/pull/889
2019-10-08 13:01:08 +02:00
Miro Hrončok
2a3b101709 Fedora CI: Run mock on the current Fedora version (or 31 if less than 31) 2019-09-23 15:34:26 +02:00
Petr Viktorin
137aa316c4 Bump release 2019-09-20 10:18:12 +02:00
Miro Hrončok
97d785b58d Don't use --strip-file-prefix with pip, the custom option is gone 2019-09-20 01:32:33 +02:00