Commit Graph

127 Commits

Author SHA1 Message Date
Lumir Balhar 3a211cc91b Use compileall from stdlib for Python >= 3.9 2020-06-16 13:57:38 +02:00
Miro Hrončok 985a80572f Allow to combine %pycached with other macros (e.g. %exclude or %ghost)
Previous implementation allowed for only one argument to be passed to
the %pycached macro, which made it impossible to combine it with other macros.

Current implementation allows to pass other macros as arguments to
%pycached.

Example:

    %pycached %exclude /path/to/foo.py

For macro expansion limitations, the opposite order is not possible.
That is to be documented in the guidelines:
https://pagure.io/packaging-committee/pull-request/986

Added some tests.

Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1838992

Co-authored-by: Marcel Plch <mplch@redhat.com>
2020-06-11 20:51:34 +02:00
Miro Hrončok bae52eafbe Require the exact same version-release of other subpackages of this package
To avoid mock using a local copy of python-srpm-macros from the buildroot cache
and having Python version defined to 3.8 until the cache expires.

Also, other surprises happened in the past, so we stop playing it cool and
actually follow the guidelines here.
2020-05-31 00:28:19 +02:00
Miro Hrončok 5919708f6c https://fedoraproject.org/wiki/Changes/Python3.9
Also switch to PEP 503 based %py_dist_name (see rhbz#1791530)
2020-05-21 17:39:01 +02:00
Miro Hrončok 72371929c5 Implement %pyX_shebang_fix
See https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/UGCMDDG3S32U7JJK36OEZNHLUVQQRG3M/
2020-05-18 18:58:39 +02:00
Miro Hrončok 4569c61d8d Strip tildes from %version in %pypi_source by default, add tests 2020-05-12 11:05:30 +02:00
Miro Hrončok 0d3f1e6b74 Implement %pytest
See https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/XLPDSH362PJKMJCAYOXNJNV53Y66EF6B/
2020-05-11 19:04:28 +02:00
Miro Hrončok 5f3e4d6300 Change %__default_python3_pkgversion from 38 to 3.8
See https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/message/VIUS7WMQMDX6H2WEIH7TVTMBB6SUHY7E/
2020-05-07 21:47:38 +02:00
Miro Hrončok 76aecd9ad7 Require recent enough SRPM macros from RPM macros, to prevent missing Lua files
%pyhon_provide in python-rpm-macros uses new Lua functions from python-srpm-macros

People have python-srpm-macros pre-installed, and it is not autoupdated,
hence they can have older versions installed and it blows up.
2020-05-06 01:31:46 +02:00
Miro Hrončok 8fea79b1ec Implement %py_provides 2020-05-05 13:54:26 +02:00
Miro Hrončok a5778bf4f2 Reorganize the spec 2020-05-05 13:53:46 +02:00
Miro Hrončok b314efc5a7 Add common Lua functions, use a Lua function in %python_provide 2020-05-05 13:53:46 +02:00
Tomas Hrnciar daf7d32612 remove direct_url.json file and sed it out from RECORD
With PEP 610 there is created new file direct_url.json since is not
useful for us, it will be removed using py3_install_wheel macro.

See: https://discuss.python.org/t/pep-610-usage-guidelines-for-linux-distributions/4012
2020-05-05 09:18:16 +02:00
Miro Hrončok fed99a0478 Make pythonX-rpm-macros depend on python-rpm-macros
%pyX_(build|install) uses %py_setup from python-rpm-macros

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1827811
2020-04-27 10:40:14 +02:00
Lumir Balhar 15e32a3005 Update of bundled compileall2 module to 0.7.1 (bugfix release) 2020-03-31 14:24:09 +02:00
Miro Hrončok 1b3e731dc6 Brand as "3.8", rework %python_provide
- Hardcode the default Python 3 version in the SRPM macros
- Provide python38-foo for python3-foo and the other way around (future RHEL compatibility)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1812087

    $ rpm --eval '%python_provide python38-setuptools'
    Provides: python-setuptools = %{version}-%{release}
    Provides: python3-setuptools = %{version}-%{release}
    Obsoletes: python-setuptools < %{version}-%{release}

    $ rpm --eval '%python_provide python3-setuptools'
    Provides: python-setuptools = %{version}-%{release}
    Provides: python38-setuptools = %{version}-%{release}
    Obsoletes: python-setuptools < %{version}-%{release}

    $ rpm --eval '%python_provide python39-setuptools'

    $ rpm --define 'python3_pkgversion 39' --eval '%python_provide python%{python3_pkgversion}-setuptools'

To make the implementation of %python_provide easier,
any names starting with "python" or "pypy" are recognized as valid arguments.

Previously, this was an ERROR:

    $ rpm --eval '%python_provide pythonista'
    %python_provide: ERROR: pythonista not recognized.

Now it is a no-op. The behavior was never documented and the change is
backwards compatible for working spec files.
2020-03-25 17:27:06 +01:00
Miro Hrončok 456f3ecffb Update of bundled compileall2 module to 0.7.0
Adds the optional --hardlink-dupes flag for compileall2 for pyc deduplication

This is explained in https://discuss.python.org/t/3014
                 and https://github.com/fedora-python/compileall2/issues/16

This option is not yet used anywhere. That allows us to backport this to all
Fedoras but only use --hardlink-dupes on rawhide first.
2020-02-10 23:58:33 +01:00
Miro Hrončok e9f07b72aa Define %py(2|3)?_shbang_opts_nodash to be used with pathfix.py -a 2020-02-06 10:26:04 +01:00
Fedora Release Engineering 82f62228c9 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-01-30 15:05:59 +00:00
Anna Khaitovich 2314fd928a Remove stray __pycache__ directory from /usr/bin when running %py_install, %py_install_wheel and %py_install_egg macros
Solves bz#1739848
2019-12-28 19:16:16 +01:00
Miro Hrončok 6c63a5b7f4 Add the %pycached macro
Usage:

  %files
  ...
  %pycached %{python3_sitelib}/foo.py

This will list:

  /usr/lib/python3.8/site-packages/foo.py
  /usr/lib/python3.8/site-packages/__pycache__/foo.cpython-38{,.opt-?}.pyc

Assuming the Python 3 version is 3.8.
The bytecode files are globbed, their presence is not checked.

This will fail:

  %pycached %{python3_sitelib}/foo

error: %pycached can only be used with paths explicitly ending with .py

And so will any of this:

  %pycached %{python3_sitelib}/*
  %pycached %{python3_sitelib}/foo.*
  %pycached %{python3_sitelib}/foo.p?
  %pycached %{python3_sitelib}/foo.?y
  %pycached %{python3_sitelib}/foo.??

But this will work:

  %pycached %{python3_sitelib}/foo*.py

And it will generate the following globs:

  /usr/lib/python3.8/site-packages/foo*.py
  /usr/lib/python3.8/site-packages/__pycache__/foo*.cpython-38{,.opt-?}.pyc

When used with paths that include Python 3 version, it globs with the version:

  %pycached /opt/python3.10/foo.py

Generates:

  /opt/python3.10/foo.py
  /opt/python3.10/__pycache__/foo.cpython-310{,.opt-?}.pyc

While paths without version have less strict globs:

  %pycached /custom/foo.py
  /custom/foo.py
  /custom/__pycache__/foo.cpython-3*{,.opt-?}.pyc

This will generate a warning in RPM build:

warning: File listed twice: /custom/__pycache__/foo.cpython-38.opt-1.pyc

However it ensures the optimized bytecode is there.
2019-12-28 19:12:37 +01:00
Miro Hrončok f0be0a2983 Define %python, but make it work only if %__python is redefined 2019-12-28 19:10:09 +01:00
Lumir Balhar bebf85d28b Bundled compileall2 module update to 0.6.0 2019-11-26 14:22:54 +01:00
Miro Hrončok af35bb0ac9 Define %python2 and %python3
See https://pagure.io/packaging-committee/issue/907

Redefine %__pythonX to change the behavior of %pythonX, %pythonX_version, etc.
Use %pythonX in spec.
2019-09-27 10:02:49 +02:00
Miro Hrončok f09ccd21f5 Drop --strip-file-prefix option from %pyX_install_wheel macros, it is not needed
A custom pip patch was needed for this option, but the RECORD files are
relative, so no stripping is needed. We will eventually drop the patch.
2019-08-26 15:33:41 +00:00
Fedora Release Engineering 2cbca3f95e - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-07-26 16:06:16 +00:00
Lumir Balhar 76681ad58e Use a new module compileall2 for Python byte-compilation 2019-07-15 14:26:49 +02:00
Miro Hrončok 64119cef2c Switch %python_provide behavior between Python 2 <--> 3
https://fedoraproject.org/wiki/Changes/Python_means_Python3

Welcome to the future.
2019-07-15 13:22:03 +02:00
Miro Hrončok b67b47d5b0 %python_provide: Don't try to obsolete %_isa provides
Based on recent changes in 04769fa014,
packagers might want to use:

    %{?python_provide:%python_provide python2-foo%{?_isa}}

...for backwards compatibility. However the macro adds obsoletes and
since RPM 4.15, obsoletes with %{?_isa} are not possible:

    Only package names are allowed in Obsoletes: Obsoletes: python-foo(x86-64) < ...

To allow such usage, %python_provide now only obsoletes if the argument
does not end with ")".
2019-07-09 13:45:18 +02:00
Miro Hrončok cf8051e7f5 Make %__python /usr/bin/python once again until we are ready
See https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/22#comment-26552
and further.
2019-06-17 16:29:44 +02:00
Miro Hrončok 04769fa014 Remove the arched provide from %python_provide macro
The way it fetched the information abut archfulness was not reliable
and will stop working entirely.

See https://bugzilla.redhat.com/show_bug.cgi?id=1705656
2019-06-17 09:34:06 +02:00
Miro Hrončok d38048d54d Define %python_sitelib, %python_sitearch, %python_version, %python_version_nodots
In rpm 4.15 those are no longer defined.

The meaning of "python" is derived from %__python - and that errors by default
unless user defined.

Example usage:

    %global __python /usr/bin/pypy3

    ...

    %files
    %{python_sitelib}/foo/
2019-06-10 15:40:53 +02:00
Fedora Release Engineering 813a86fcc6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-02-02 09:09:45 +00:00
Igor Gnatenko 9b8fac037d
Add %python_disable_dependency_generator
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-12-20 14:35:02 +01:00
Miro Hrončok 4b3c23b233 Workaround leaking buildroot PATH in %py_byte_compile (#1647212) 2018-12-14 10:20:40 +01:00
Petr Viktorin c8932dcbef Move "sleep 1" workaround from py3_build to py2_build
https://bugzilla.redhat.com/show_bug.cgi?id=1644923
2018-11-01 11:06:22 +01:00
Tomas Orsava beaa2eec4f Move the __python2/3 macros to the python-srpm-macros subpackage
This facilitates using the %%{__python2/3} in Build/Requires
2018-09-20 13:36:47 +02:00
Miro Hrončok 8f067ff385 Make %py_byte_compile terminate build on SyntaxErrors (#1616219)
Also, make it simpler again
2018-08-22 11:48:27 +02:00
Miro Hrončok 25b297c006 Bump for 90b0bf7 2018-08-15 11:56:37 +02:00
Igor Gnatenko d3d040818d
Change way how enabling-depgen works internally
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-07-28 14:26:10 +02:00
Tomas Orsava 05333eb586 macros.pybytecompile: Detect Python version through sys.version_info
...instead of guessing from the executable name.

This should make it work on EPEL7 as well where we ship 3.4 and 3.6

https://bugzilla.redhat.com/show_bug.cgi?id=1599809
2018-07-19 11:52:36 +02:00
Fedora Release Engineering 967bb3c12e - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2018-07-14 01:58:10 +00:00
Tomas Orsava f961fbbc29 Fix %%py_byte_compile macro
When invoked with a Python 2 binary it also mistakenly ran py3_byte_compile.
2018-07-10 15:14:23 +02:00
Miro Hrončok 1ea9947b6f Add %python3_platform useful for PYTHONPATH on arched builds
This is mostly used when building Sphinx docs on arched build.

Previously:

  PLATFORM=$(python3 -c "import sysconfig; print(sysconfig.get_platform())")
  export PYTHONPATH=../build/lib.${PLATFORM}-%{python3_version}
  make man

Or:

  PYTHONPATH=`realpath ../build/lib.linux*` make

Or:

  PYTHONPATH=$(echo $PWD/build/lib.linux-*) make html

Now:

  PYTHONPATH=../build/lib.%{python3_platform}-%{python3_version}
2018-07-03 14:21:49 +02:00
Jason Tibbitts 37a004eed8 Add %pypi_source macro.
Adds the %pypi_source macro, as well as %__pypi_url and
%__pypi_default_extension.  This should make references to sources in
PyPI much simpler for nearly all Python packages.
2018-06-18 12:54:12 -05:00
Miro Hrončok 3c79d6a899 Move macros.pybytecompile from python3-devel
- https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation
 - No conflicts need to be added the file is renamed
 - If both files are present, there is no harm, so we'll just remove it from 3.7
2018-04-18 18:36:19 +02:00
Tomas Orsava 6cc8000e14 Fix the %py_dist_name macro
..to not convert dots (".") into dashes, so that submodules can be
addressed as well

Resolves: rhbz#1564095
2018-04-06 11:48:08 +02:00
Jan Pokorný 4904408b2f macros.python*: make LDFLAGS propagated whenever CFLAGS are
This is to ensure the right linker flags get propagated into binaries
accompanying python packages whenever distutils (or similar, env.
variables provided build flags aware) module is delegated to build them
(e.g. https://bugzilla.redhat.com/show_bug.cgi?id=1541106).  Instead of
using "%{__global_ldflags}" as the seed for the respective env. variable
one-off application, which would be a direct parallel to "%{optflags}"
seeding CFLAGS, use rather "${RPM_LD_FLAGS}" and "${RPM_OPT_FLAGS}",
as these are not directly bound to macros out of rpm proper (like
it would have been, e.g., on redhat-rpm-config package otherwise).

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2018-03-23 13:33:48 +01:00
Fedora Release Engineering 9f912209e5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2018-02-09 10:39:49 +00:00
Igor Gnatenko ec476c84cc
add macros to enable dependency generator
References: https://fedoraproject.org/wiki/Changes/EnablingPythonGenerators
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2018-01-19 15:52:58 +01:00
Tomas Orsava 69b720ea4f Revert "Add platform-python macros"
This reverts commit cb52c18aa9.
2017-11-28 11:51:43 +01:00
Ville Skyttä 8d3d1dde64 macros.python*: Use -Es/-I to invoke macro scriptlets
To avoid environment and user dir influence.

https://bugzilla.redhat.com/show_bug.cgi?id=1506355
2017-10-26 13:31:35 +03:00
Iryna Shcherbina cb52c18aa9 Add platform-python macros 2017-08-14 14:54:13 +02:00
Fedora Release Engineering b58450b1f3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild 2017-07-27 11:44:18 +00:00
Michal Cyprian a59818afd0 Revert "Switch %%__python3 to /usr/libexec/system-python"
- The Fedora Change https://fedoraproject.org/wiki/Changes/Making_sudo_pip_safe
  was postponed
- This reverts commit d019d2fd4d
2017-03-03 13:52:35 +01:00
Michal Cyprian d019d2fd4d Switch %%__python3 to /usr/libexec/system-python 2017-02-20 13:41:26 +01:00
Fedora Release Engineering 063c3984a9 - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild 2017-02-11 10:23:28 +00:00
Michal Cyprian d0fdb0d759 Add --no-deps option to py_install_wheel macros 2017-01-23 18:52:17 +01:00
Tomas Orsava 123ad4b49f Added macros for Build/Requires tags using Python dist tags
https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
2017-01-17 10:28:13 +01:00
Orion Poplawski 516c55eed7 Fix typo in changelog 2016-11-24 07:59:27 -07:00
Orion Poplawski 5ca1f525e5 Make expaned macros start on the same line as the macro 2016-11-24 07:53:47 -07:00
Orion Poplawski a73eb24716 Fix %py3_install_wheel (bug #1395953) 2016-11-16 21:32:46 -07:00
Orion Poplawski e7af332922 Add missing sleeps to other build macros
- Fix build_egg macros
- Add %py_build_wheel and %py_install_wheel macros
2016-11-16 16:28:31 -07:00
Orion Poplawski bad56e0efe Bump release and add %changelog entry 2016-11-15 16:26:40 -07:00
Orion Poplawski 59b1647971 Use %rpmmacrodir 2016-08-24 16:47:08 -06:00
Orion Poplawski 81fee785df Do not generate useless Obsoletes with %{?_isa} 2016-07-12 11:14:21 -06:00
Orion Poplawski c30072e570 Make python-rpm-macros require python-srpm-macros (bug #1335860) 2016-05-13 14:20:24 -06:00
Jason Tibbitts af37c22835 Add single-second sleeps to work around setuptools bug. 2016-05-12 13:28:05 -05:00
Fedora Release Engineering c09d56c2fc - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild 2016-02-04 20:51:34 +00:00
Orion Poplawski 2b90e4a07b Fix typo in %python_provide 2016-01-14 20:50:53 -07:00
Orion Poplawski 49ccad99b2 Revert "Move srpm macros to macros.0python-srpm to be defined before other macros"
This reverts commit 1a6f8f12f8.
2016-01-14 20:49:29 -07:00
Orion Poplawski 1a6f8f12f8 Move srpm macros to macros.0python-srpm to be defined before other macros 2016-01-14 20:40:15 -07:00
Orion Poplawski f16464f0b6 Handle noarch python sub-packages (bug #1290900) 2016-01-14 16:17:51 -07:00
Orion Poplawski b3d3b56869 Fix python2/3-rpm-macros package names 2016-01-13 10:54:20 -07:00
Orion Poplawski 18473ee340 Fix date in %changelog 2016-01-13 08:59:38 -07:00
Orion Poplawski 9a282dffb2 Fix date in %changelog 2016-01-13 08:59:03 -07:00
Orion Poplawski ec28c775cd Initial import 2016-01-12 16:52:28 -07:00