On Wed, 2021-06-23 at 12:36 +0300, Mart Raudsepp wrote:
> 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.
> ---
>  eclass/python-utils-r1.eclass | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> Note that I haven't actually tested this on py3.9, as I'm skipping that 
> version.
> It appears to do what it's meant to with py3.10
> 
> diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
> index 3dbf221eac5..e2f05606993 100644
> --- a/eclass/python-utils-r1.eclass
> +++ b/eclass/python-utils-r1.eclass
> @@ -626,12 +626,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)

We don't really support < 3.8 anymore but I can update that while
merging, I guess.

>                                 # 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}"
>                                 ;;
> 
> 
> 

-- 
Best regards,
Michał Górny



Reply via email to