Closed Bug 951736 Opened 11 years ago Closed 11 years ago

pymake only updates sys.path from PYCOMMANDPATH at import time

Categories

(Firefox Build System :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla29

People

(Reporter: gps, Assigned: gps)

References

Details

Attachments

(1 file)

In bug 949875, we were hitting weird build failures on pymake when switching some imports to function scope so they could be delay loaded. I tracked down the issue to how pymake munges sys.path when executing native commands.

The logic for executing native pymake commands live at:

https://hg.mozilla.org/users/bsmedberg_mozilla.com/pymake/file/42627616700c/pymake/process.py#l378

Of interest is the sys.path munging that occurs in load_module_recursive:

https://hg.mozilla.org/users/bsmedberg_mozilla.com/pymake/file/42627616700c/pymake/process.py#l349

Essentially, the current behavior munges sys.path, imports the requested module, then unmunges sys.path before executing the command. This, of course, means sys.path is not adjusted during execution of the native command, which breaks lazy imports.

I'm surprised this has worked for as long as it has.

I'm planning to rewrite the sys.path munging. I plan to always have sys.path convey PYTHONCOMMANDPATH while the command is executing and restore it afterwards. I will also not make things conditional on whether the requested module is already in sys.path.
In hindsight that looks pretty silly. I don't know why I implemented it that way. PythonJob.run already has a try/finally for tweaking os.environ, it seems like a good place to munge sys.path as well.
Patch with test.
Attachment #8349516 - Flags: review?(ted)
Assignee: nobody → gps
Status: NEW → ASSIGNED
Attachment #8349516 - Flags: review?(ted) → review+
https://hg.mozilla.org/mozilla-central/rev/0f982fab4b85
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: