-
-
Notifications
You must be signed in to change notification settings - Fork 291
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
Support a --venv mode similar to --unzip mode. #1153
Conversation
b899f74
to
b5309a6
Compare
The new --venv execution mode builds a PEX file that includes pex.tools and extracts itself into a venv under PEX_ROOT upon 1st execution or any execution that might select a diffrent interpreter than the default. In order to speed up the local build and execute case, --seed mode is added to seed the PEX_ROOT caches that will be used at runtime. This is important for --venv mode since venv seeding depends on the selected interpreter and one is already selected during the PEX file build process.
b5309a6
to
d8df335
Compare
ce11a7e
to
1f40124
Compare
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.
Awesome
from __future__ import absolute_import | ||
|
||
|
||
class BinPath(object): |
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.
This looks similar to Enum
- once we drop Py2, would we want to switch this to that? If so, a TODO would be great.
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.
Yes, this should go to enum as should InheritPath. This just moved out of pex.tools.commands.venv so I'll leave as-is. There are alot of things that can change once we drop Python 2.7 including namedtuple -> dataclass and more. That will be a whole project.
fallback, # type: _P | ||
): | ||
# type: (...) -> _P | ||
"""Return the value of this property without the default value applied or else the fallback. |
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.
To confirm, this is without the default? That's not a typo?
If so, perhaps:
Return the value of this property, without the default value applied, and falling back to
fallback
.
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.
Confirmed. I do not see how the new words make things more clear.
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.
Thanks!
""".format( | ||
venv_python=venv_python, | ||
venv_bin_dir=venv_bin_dir, | ||
venv_dir=venv_dir, | ||
bin_path=bin_path, | ||
entry_point=pex_info.entry_point, | ||
exec_ast=( | ||
"exec ast in globals_map, locals_map" | ||
if venv.interpreter.version[0] == 2 | ||
else "exec(ast, globals_map, locals_map)" | ||
), |
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.
Maybe not worth it yet, but if all of the templated variables are strings, you might consider extracting this as a "real" Python file to allow for mypy/linting, and then loading the file as a resource to template it using a slightly heavier template syntax (something like mustache, but cheaper hopefully).
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.
Perhaps worth it down the line as with the venv __main__.py
and the PythonInterpreter
identification code, etc...
The new --venv execution mode builds a PEX file that includes pex.tools
and extracts itself into a venv under PEX_ROOT upon 1st execution or any
execution that might select a diffrent interpreter than the default.
In order to speed up the local build and execute case, --seed mode is
added to seed the PEX_ROOT caches that will be used at runtime. This is
important for --venv mode since venv seeding depends on the selected
interpreter and one is already selected during the PEX file build
process.
Fixes #962
Fixes #1097
Fixes #1115