Select Your Language

Infrastructure and Management

Cloud Computing

Storage

Runtimes

Integration and Automation

  • Comments
  • RHEL 8 RPM build with python file

    Posted on

    I migrate a build sever from RHEL 7 to 8. My rhel 7 rpm build spec installs a python file. On the RHEL 7 the rpm build will generate the pyc and pyo files and include them in the rpm package. But on rhel 8 it does not generate the .pyc and .pyo files.

    Here is the lines from the spec file.
    ####################
    %define iniDir /etc/init.d
    %install

    Install Binaries/Scripts

    install -m 755 fileManager.py $RPM_BUILD_ROOT%{iniDir}

    %files
    %attr(755, root, root) %{iniDir}/fileManager.py

    %{iniDir}/fileManager.pyc
    %{iniDir}/fileManager.pyo

    #

    On rhel 7 the rpm build prints out these lines
    + /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
    + /usr/lib/rpm/brp-python-bytecompile /usr/bin/python 1
    + /usr/lib/rpm/redhat/brp-python-hardlink

    On rhel 8 the rpm build prints out these lines.
    + /usr/lib/rpm/brp-strip-static-archive /usr/bin/strip
    + /usr/lib/rpm/brp-python-bytecompile '' 1
    + /usr/lib/rpm/brp-python-hardlink
    + PYTHON3=/usr/libexec/platform-python
    + /usr/lib/rpm/redhat/brp-mangle-shebangs

    I did tried one of these shebangs #!/usr/bin/python2.7 or #!/usr/bin/python3.6 on the fileManager.py but still don't see the rpm build generates and install the .pyc and pyo files.

    I can work around by calling the shell python command from jenkins file generate the pyc and pyo files and copy them to /etc/init.d before calling the rpm build . Then the rpm build will install the .py, pyc, pyo files.

    Does anyone knows how why the RHEL 8 rpm build does not generate the .pyc and .pyo ?

    Thanks for reading it.
    -Tom Pham

    by

    points

    Responses

    Red Hat LinkedIn YouTube Facebook X, formerly Twitter

    Quick Links

    Help

    Site Info

    Related Sites

    © 2026 Red Hat