-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Enable --[no-]compile which will compile or not compile pyc files #1335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
""" | ||
del script.environ["PYTHONDONTWRITEBYTECODE"] | ||
script.pip("install", "--compile", "--no-use-wheel", "INITools==0.2") | ||
assert os.path.exists(script.site_packages_path/"INITools/__init__.pyc") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use imp.cache_from_source
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm doing this instead..
# There are many locations for the __init__.pyc file so attempt to find
# any of them
exists = [
os.path.exists(script.site_packages_path/"INITools/__init__.pyc"),
]
exists += glob.glob(
script.site_packages_path/"INITools/__pycache__/__init__*.pyc"
)
assert any(exists)
Since imp.cache_from_source
isn't available on every Python and some OSs package differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, the uninstall code checks if backwardcompat.uses_pycache
== True, then uses imp.cache_from_source
* Enables compilation for Wheel files * Adds an easy command line for distutils/setuptools compilation options
All tests passed except for PyPy which is known to be broken with 2.2. |
Enable --[no-]compile which will compile or not compile pyc files
This does not seem to put the pyc files into RECORD, so they will not be removed on uninstall. This is bad as it will leave clutter around and could potentially mean that uninstalled modules are still importable (from the pyc files). I've not tested the details - I only saw this after it was merged. Did anyone check this? I see no test that does so. At a minimum, if the RECORD handling cannot be fixed easily (does the compile step even say what pyc files are created?) then --no-compile should be the default until a resolution can be found. |
This is the RECORD for twine installed from Wheel
and the pip uninstall output
The compilation step happens before the RECORD step so it should pick it up as part of that. |
Apologies, you are correct. I misunderstood the code - didn't read it in enough detail. I have confirmed that this works on Python 3.3. Blame it on checking emails before my first caffeine hit, plus having had trouble with this stuff in the past when using wininst installers :-) |
It only works in py3 because of PR #646 I added a year ago. |
It should work in Py3 regardless because the compilation happens prior to the RECORD being generated.
|
ok, you're just talking about wheels (and I see now how the cache files are being added indirectly) |
most of
|
This fixes #1324