Commit Graph

89 Commits

Author SHA1 Message Date
Miro Hrončok a1861889d3 Add %python3_platform_triplet and %python3_ext_suffix
Also add %python_platform_triplet, %python_ext_suffix and %python_platform.

The CI tests are limited to x86_64 for now.

https://fedoraproject.org/wiki/Changes/Python_Upstream_Architecture_Names
2020-09-25 09:49:36 +02:00
Miro Hrončok 6186b94b6e 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-15 12:13:38 +02:00
Miro Hrončok 8b79a441ad Implement %pyX_shebang_fix
See https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/UGCMDDG3S32U7JJK36OEZNHLUVQQRG3M/
2020-05-25 10:47:10 +02:00
Miro Hrončok c3cafa3dd7 Strip tildes from %version in %pypi_source by default, add tests 2020-05-25 10:47:10 +02:00
Miro Hrončok 70fa6a9627 Implement %pytest
See https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/XLPDSH362PJKMJCAYOXNJNV53Y66EF6B/
2020-05-25 10:47:10 +02:00
Miro Hrončok ead8ec025b Backport simplified %py_provides
This is a smallest possible backport of https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/52

Notable simplifications:

- there is no Lua library
- %python_provide remains untouched and the logic is not shared with %py_provides
- there are no pythonXY-foo provides on Fedora < 33
2020-05-25 10:47:08 +02:00
Miro Hrončok 18667277d5 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-28 14:18:47 +02:00
Lumir Balhar 3f331a6ad1 Update of bundled compileall2 module to 0.7.1 (bugfix release) 2020-03-31 14:25:45 +02:00
Miro Hrončok 5914a75181 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:58 +01:00
Miro Hrončok f43227fac0 Define %py(2|3)?_shbang_opts_nodash to be used with pathfix.py -a 2020-02-07 18:07:36 +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
Miro Hrončok 84ed1ab69d Fix %python3_version macros for Python 3.10
No need to bump the release, 3.10 is far from now.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1745601
2019-08-26 15:24:23 +02: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 eb3274394c Do not allow passing arguments to Python during byte-compilation 2019-07-15 14:26:49 +02:00
Lumir Balhar 4493789fb8 Use `-s` to not add user site directory to sys.path for byte-compilation 2019-07-15 14:26:49 +02: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 536b2efe4e Move %__python definition to the srpm macros, so it is always present 2019-06-12 11:34:53 +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
Pavel Raiskup 90b0bf7480 macros.python: drop last %__python2 occurrence
This is needed so people can do things like:

    %if %{with python3}
    %global __python %__python3
    %else
    %global __python %__python2
    %else

And than just use %__python, %py_build, %py_install,
%python_sitelib, ...
2018-08-03 17:08:55 +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
Miro Hrončok 21ac2a9653 Make the pybytecompile version agnostic again
It is no longer bound to a specific pythonX package
2018-04-10 11:58:45 +02:00
Miro Hrončok 438faf7c86 Fix the py_byte_compile macro to work on Python 2
See https://bugzilla.redhat.com/show_bug.cgi?id=1484993

Inspired by Terje Røsten's workaround from that bugzilla
2018-04-10 11:58:45 +02:00
Tomas Orsava 2e3d372310 Fix syntax error in %py_byte_compile macro (rhbz#1433569) 2018-04-10 11:58:45 +02:00
Charalampos Stratakis 5208f057c1 Update macros.pybytecompile to 3.6
Rename the macros.pybytecompile3.5 file to macros.pybytecompile3.6
2018-04-10 11:58:45 +02:00
Charalampos Stratakis 3af7df6454 Update %py_byte_compile macro 2018-04-10 11:58:45 +02:00
Robert Kuska 99ca83f054 Rename macros to 3.5 2018-04-10 11:58:45 +02:00
Matej Stuchlik bcfeb6a0b1 Update macros.pybytecompile to 3.4 2018-04-10 11:58:45 +02:00
dmalcolm 739136717f Introduce macros.pybytecompile 2018-04-10 11:58:45 +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