Package: compileall2
compileall2 Python moduleCopy ofcompileallmodule from CPython source code with some new features, namely:compatibility with Python >= 3.4 & PyPy 3default recursion limit is now "unlimited" (actually limited bysys.getrecursionlimit())-sand-pcommand line options for manipulation of the path baked into
a compiled*.pycfile.the-ocommand line option can be specified multiple times to compile for
multiple optimization levels in one runthe-ecommand line option for ignoring symlinks pointing outside a specific directorythe--hardlink-dupescommand line option which creates hardlinks between.pycfiles with the same contentInstallationFromPyPIviapip install compileall2RPMs will be available inFedora COPRUsagecompileall2can be executed as a Python module or directly.Example usage:# Create some script (this one raises an exception to show tracebacks)$echo"1 / 0">test.py# Compile it$compileall2test.py
Compiling'test.py'...# Try to execute compiled version directly$python__pycache__/test.cpython-37.pycTraceback(mostrecentcalllast):File"test.py",line1,in<module>1/0ZeroDivisionError:divisionbyzero# Recompile it with changes path which will be visible in error message$compileall2-f-p/foo/bartest.py
Compiling'test.py'...
$python__pycache__/test.cpython-37.pyc
Traceback(mostrecentcalllast):File"/foo/bar/test.py",line1,in<module>
ZeroDivisionError:divisionbyzero# Same thing as above but executed as a Python module$python-mcompileall2-f-p/bar/baztest.py
Compiling'test.py'...
$python__pycache__/test.cpython-37.pyc
Traceback(mostrecentcalllast):File"/bar/baz/test.py",line1,in<module>
ZeroDivisionError:divisionbyzeroDone✓ Start project :)✓ Make upstream tests runningMakecompileall2compatible with CPythons:3.8 ✓3.7 ✓3.6 ✓3.5 ✓3.4 ✓✓ Makecompileall2compatible with PyPy 3✓ Remove maximum depth limit as described above✓ Add possibility to strip some part of a path to an original file from compiled one✓ Publish it to PyPI✓ Make it available in Fedora COPR✓ Test it with Python packages in COPRPush it to Fedora rawhide✓ %py_byte_compile RPM macro usescompileall2(done inpython-rpm-macros)✓ switch brp-python-bytecompile RPM script tocompileall2(done inredhat-rpm-config)✓ Test it in Fedora infrastructure with all Python packages (done in the mass rebuild for Fedora 31)✓ Prepare patches for upstream CPythonPull requestmerged and will be part of Python 3.9✓ Changes from upstream CPython backported back✓ Implemented important features for Fedora RPM build systemTestingYou can test it locally with tox or unittest directly:$python3-munittesttest_compileall2.py
..............sss....ss.......................sss....ss.....................ss.............................----------------------------------------------------------------------
Ran107testsin3.714s

OK(skipped=12)but running in a Docker container might be better because the superuser has privileges to write tosys.pathwhich lowers the number of skipped tests.You can just build the prepared one:$dockerbuild-tcompileall2.
SendingbuildcontexttoDockerdaemon177.2kB
Step1/3:FROMfrenzymadness/fedora-python-tox:latest--->00f92ad0e1d3
...etc...and run tests in it:$dockerrun--rm-it-eTOXENV=py37-v$PWD:/src:Z-w/srccompileall2
py37installed:atomicwrites==1.3.0,attrs==19.3.0,compileall2==0.5.0,coverage==4.5.4,importlib-metadata==0.23,more-itertools==7.2.0,packaging==19.2,pluggy==0.13.0,py==1.8.0,pyparsing==2.4.5,pytest==5.2.3,six==1.13.0,wcwidth==0.1.7,zipp==0.6.0
py37run-test-pre:PYTHONHASHSEED='1615314833'py37runtests:commands[0]|coveragerun--append-mpy.test====================================testsessionstarts=====================================platformlinux--Python3.7.5,pytest-5.2.3,py-1.8.0,pluggy-0.13.0
cachedir:.tox/py37/.pytest_cache
rootdir:/src
collected107items
test_compileall2.py............ss..................................................ss[61%]..............................ss.........[100%]===============================101passed,6skippedin7.40s===============================py37runtests:commands[1]|coveragereport-i'--omit=.tox/*'NameStmtsMissCover
-----------------------------------------
compileall2.py2324879%
test_compileall2.py621899%
-----------------------------------------
TOTAL8535693%
__________________________________________summary___________________________________________py37:commandssucceededcongratulations:)LicensePSF license v2