Go to file
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
.gitignore Initial setup of the repo 2016-01-12 23:33:17 +00:00
compileall2.py Bundled compileall2 module update to 0.6.0 2019-11-26 14:22:54 +01:00
macros.pybytecompile Do not allow passing arguments to Python during byte-compilation 2019-07-15 14:26:49 +02:00
macros.python Switch %python_provide behavior between Python 2 <--> 3 2019-07-15 13:22:03 +02:00
macros.python-srpm Define %python, but make it work only if %__python is redefined 2019-12-28 19:10:09 +01:00
macros.python2 Drop --strip-file-prefix option from %pyX_install_wheel macros, it is not needed 2019-08-26 15:33:41 +00:00
macros.python3 Add the %pycached macro 2019-12-28 19:12:37 +01:00
python-rpm-macros.spec Add the %pycached macro 2019-12-28 19:12:37 +01:00
sources Initial setup of the repo 2016-01-12 23:33:17 +00:00