Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 413957 - python-distutils-ng: could let distutils compile bytecode?
Summary: python-distutils-ng: could let distutils compile bytecode?
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Krzysztof Pawlik (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-29 07:44 UTC by Michał Górny
Modified: 2012-05-04 08:32 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
python-distutils-ng.eclass-compilation.diff (python-distutils-ng.eclass-compilation.diff,2.57 KB, patch)
2012-05-02 22:46 UTC, Krzysztof Pawlik (RETIRED)
Details | Diff
xlrd-0.7.7-r256.ebuild (xlrd-0.7.7-r256.ebuild,816 bytes, text/plain)
2012-05-02 22:49 UTC, Krzysztof Pawlik (RETIRED)
Details
python-distutils-ng.eclass-compilation.diff (python-distutils-ng.eclass-compilation.diff,2.56 KB, patch)
2012-05-03 07:15 UTC, Krzysztof Pawlik (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-04-29 07:44:21 UTC
python-distutils-ng compiles bytecode in src_install(). That seems a little incorrect. Can't we just enable distutils bytecode compilation and let it do it in src_compile()?
Comment 1 Mike Gilbert gentoo-dev 2012-05-02 21:56:39 UTC
Actually, distutils does not generate the bytecode files until you run the "install" step.

For some unknown reason, we are passing --no-compile in src_install.

# @FUNCTION: _python-distutils-ng_default_distutils_install
# @DESCRIPTION:
# Default src_install for distutils-based packages.
_python-distutils-ng_default_distutils_install() {
    "${PYTHON}" setup.py install --no-compile --root="${D}/" || die
}

Why are we doing that?
Comment 2 Krzysztof Pawlik (RETIRED) gentoo-dev 2012-05-02 22:46:59 UTC
Created attachment 310643 [details, diff]
python-distutils-ng.eclass-compilation.diff

Main reason is quite simple: previous eclass had this split, so I've modeled exactly that behavior. Another good reason is that you need to vary arguments passed to setup.py depending on Python implementation (Jython doesn't do optimizations for example).

I'm attaching a patch that simplifies the eclass (yay!) by re-enabling module compilation in default src_install and removing (now) useless code.

Can anybody test this with Pypy? (I'll attach xlrd ebuild that I'm using for tests as next attachment).
Comment 3 Krzysztof Pawlik (RETIRED) gentoo-dev 2012-05-02 22:49:04 UTC
Created attachment 310645 [details]
xlrd-0.7.7-r256.ebuild
Comment 4 Mike Gilbert gentoo-dev 2012-05-03 00:18:29 UTC
Works for me with pypy-1.8.

pypy seems to silently ignore the -O2 flag. Do we actually need that case statement? Does jython throw an error or something?

Also, while we are modifying this piece of code, can we pass root as the following?

--root="${D%/}/"

This avoids passing duplicate trailing slashes, which is a pet-peeve of mine.
Comment 5 Mike Gilbert gentoo-dev 2012-05-03 00:34:30 UTC
(In reply to comment #4)
> pypy seems to silently ignore the -O2 flag. 

Actually, pypy ignores -OO, which is what distutils passes to it when you do setup.py install -O2.
Comment 6 Krzysztof Pawlik (RETIRED) gentoo-dev 2012-05-03 07:15:29 UTC
Created attachment 310661 [details, diff]
python-distutils-ng.eclass-compilation.diff

Thank you Mike for testing with Pypy. Yes, Jython shows ugly error message when it gets -OO, if Pypy just ignores it then it's ok and I've removed it from case statement. I've modified --root too. Please review and I'll commit the change.
Comment 7 Mike Gilbert gentoo-dev 2012-05-03 18:12:14 UTC
Looks good to me.
Comment 8 Krzysztof Pawlik (RETIRED) gentoo-dev 2012-05-04 08:32:20 UTC
(In reply to comment #7)
> Looks good to me.

Thank you for the review, committed.