Open
Bug 1198153
Opened 9 years ago
Updated 2 years ago
Moving python files can lead to stray .pyc files that break other python tools (e.g. test harnesses)
Categories
(Firefox Build System :: Mach Core, enhancement)
Firefox Build System
Mach Core
Tracking
(Not tracked)
NEW
People
(Reporter: jgraham, Unassigned)
References
Details
Occasionally moving files around in the source tree will leave an old .pyc file in a location further up the import path list than the new .py file. This means that code expecting to import the new module may get the old version instead, leading to difficult to understand and reproduce bugs. We should have some mechanism to clobber the .pyc files after a change that moves them around, and a hg hook to enforce that the relevant action is taken when a change is committed to inbound that actually moves a python file. I imagine that such a clobber mechanism might have to live in mach. (this is the non-build-specific version of bug 685957).
Comment 1•9 years ago
|
||
If you use the python virtualenv, bug 1188224 should have fixed this.
Reporter | ||
Comment 2•9 years ago
|
||
So you need to do self.activate_virtualenv() in the command? Can we make that declarative and possibly opt-out i.e. @Command("foo", virtualenv=False) def foo(): pass
Comment 3•9 years ago
|
||
Also bug 1184696 implemented the clobber mechanism already: $ mach clobber python I guess if you wanted to leave this open for implementing a hook, you could.
Comment 4•9 years ago
|
||
The custom import hook from bug 1188224 is installed when running `mach` or any Python command that executes in the build system's virtualenv. That means .pyc files with unattached .py files should be ignored in most circumstances. I'm kinda surprised you are still seeing this after bug 1188224? We paved over the problem with the import hook. Not writing .pyc files in the source directory is something we should do. But it is a PITA, as you need to replace the built-in import mechanism. This is very difficult in Python 2.7 and slightly easier in Python 3, as Python 3.3 made import code fully implemented in Python and thus modifiable. Regarding comment #2, mach hacks up sys.path. See build/mach_bootstrap.py. In addition, the virtualenv has a supetset of those packages/paths. self.activate_virtualenv() from a mach command will pull in those additional packages - and allow you to install additional packages from pip. It's all very convoluted and sub-optimal :/
Updated•6 years ago
|
Product: Core → Firefox Build System
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•