#34 Remove stray __pycache__ directory from /usr/bin when running %py_install, %py_install_wheel and %py_install_egg macros
Merged 2 months ago by churchyard. Opened 3 months ago by akhaitov.
rpms/ akhaitov/python-rpm-macros master  into  master

file modified
+3

@@ -31,15 +31,18 @@ 

  %py_install() %{expand:\\\

    CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\

    %{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}

+   rm -rfv %{buildroot}%{_bindir}/__pycache__

  }

  

  %py_install_egg() %{expand:\\\

    mkdir -p %{buildroot}%{python_sitelib}

    easy_install -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python_version}.egg %{?*}

+   rm -rfv %{buildroot}%{_bindir}/__pycache__

  }

  

  %py_install_wheel() %{expand:\\\

    pip install -I dist/%{1} --root %{buildroot} --strip-file-prefix %{buildroot} --no-deps

+   rm -rfv %{buildroot}%{_bindir}/__pycache__

  }

  

  %python_provide() %{lua:

file modified
+3

@@ -33,13 +33,16 @@ 

  %py2_install() %{expand:\\\

    CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\

    %{__python2} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}

+   rm -rfv %{buildroot}%{_bindir}/__pycache__

  }

  

  %py2_install_egg() %{expand:\\\

    mkdir -p %{buildroot}%{python2_sitelib}

    easy_install-%{python2_version} -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python2_version}.egg %{?*}

+   rm -rfv %{buildroot}%{_bindir}/__pycache__

  }

  

  %py2_install_wheel() %{expand:\\\

    pip%{python2_version} install -I dist/%{1} --root %{buildroot} --no-deps

+   rm -rfv %{buildroot}%{_bindir}/__pycache__

  }

file modified
+3

@@ -27,15 +27,18 @@ 

  %py3_install() %{expand:\\\

    CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}"\\\

    %{__python3} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot} %{?*}

+    rm -rfv %{buildroot}%{_bindir}/__pycache__

  }

  

  %py3_install_egg() %{expand:\\\

    mkdir -p %{buildroot}%{python3_sitelib}

    easy_install-%{python3_version} -m --prefix %{buildroot}%{_prefix} -Z dist/*-py%{python3_version}.egg %{?*}

+   rm -rfv %{buildroot}%{_bindir}/__pycache__

  }

  

  %py3_install_wheel() %{expand:\\\

    pip%{python3_version} install -I dist/%{1} --root %{buildroot} --no-deps

+   rm -rfv %{buildroot}%{_bindir}/__pycache__

  }

  

  # This only supports Python 3.5+ and will never work with Python 2.

file modified
+2

@@ -81,6 +81,8 @@ 

  * Sat Dec 28 2019 Miro Hrončok <mhroncok@redhat.com> - 3-51

  - Define %%python, but make it work only if %%__python is redefined

  - Add the %%pycached macro

+ - Remove stray __pycache__ directory from /usr/bin when running %%py_install,

+   %%py_install_wheel and %%py_build_wheel macros

  

  * Tue Nov 26 2019 Lumír Balhar <lbalhar@redhat.com> - 3-50

  - Update of bundled compileall2 module

Simple workaround for this pip issue - https://github.com/pypa/pip/issues/6906
Solves bz#1739848

rebased onto 975a906

3 months ago

rebased onto 87fedee

3 months ago

rebased onto 890d58f

3 months ago

This have slipped from my radar. Will test, but looks reasonable codewise.

rebased onto 7838c6f

2 months ago

Rebased. Still hasn't find a time to test. Sorry about that :(

Why was it added to %py_build_wheel?

rebased onto c388bd6

2 months ago

Why was it added to %py_build_wheel?

Probably by my mistake. Should be removed now

rebased onto a42936a

2 months ago

The changelog needs to be changed as well.

Arguably, this should be added to %py_install_egg as well. Later, we should probably deprecate and remove that macro.

rebased onto 9e97b8f

2 months ago

The changelog needs to be changed as well.

Changed the changelog and bumped the version to 3-51

Arguably, this should be added to %py_install_egg as well. Later, we should probably deprecate and remove that macro.

Added the removal of pycache also to %py_install_egg

py_build_wheel -> py_install_egg

bumped the version to 3-51

good catch, mea culpa when rebasing.

rebased onto b576cf5

2 months ago

py_build_wheel -> py_install_egg

Fixed

rebased onto 2314fd9

2 months ago

Pull-Request has been merged by churchyard

2 months ago

This broke http://koschei.fedoraproject.org/package/python-enchant?collection=f32

It has:

%py3_install \
    --single-version-externally-managed

I will try to unbreak it.

Dropping --single-version-externally-managed got the job done, but we should be alerted that people use %py3_install like that.

Also https://bugzilla.redhat.com/show_bug.cgi?id=1792050

It's passing the backslash as an argument to the macro :/