Skip to content

Commit

Permalink
python-utils-r1.eclass: Enable hardlinking of identical pyc files for…
Browse files Browse the repository at this point in the history
… py3.9+

Python 3.9 includes a new feature for compileall to automatically hardlink
different optimization level cache files if they are identical. Make use of it
for python_optimize for some space savings.
This however does not cover distutils use cases and python itself.

Signed-off-by: Mart Raudsepp <[email protected]>
Signed-off-by: Michał Górny <[email protected]>
  • Loading branch information
leio authored and mgorny committed Aug 12, 2021
1 parent bd906f5 commit 7a9b4f5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion eclass/python-utils-r1.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -601,12 +601,15 @@ python_optimize() {
"${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
"${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
;;
python*|pypy3)
python3.[5678]|pypy3)
# both levels of optimization are separate since 3.5
"${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
"${PYTHON}" -O -m compileall -q -f -d "${instpath}" "${d}"
"${PYTHON}" -OO -m compileall -q -f -d "${instpath}" "${d}"
;;
python*)
"${PYTHON}" -m compileall -o 0 -o 1 -o 2 --hardlink-dupes -q -f -d "${instpath}" "${d}"
;;
*)
"${PYTHON}" -m compileall -q -f -d "${instpath}" "${d}"
;;
Expand Down

0 comments on commit 7a9b4f5

Please sign in to comment.