-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-41011: venv -- add more variables to pyvenv.cfg (GH-30382) #30382
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
Changes from all commits
9857b28
34f7943
0c7643c
e4bb85e
f93cae0
fabe6eb
74bbfeb
abef4f4
1184ffb
19d825e
ac22946
c891cac
5afeb8a
727c515
0d44a7d
9f06b55
0e519ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ def __init__(self, system_site_packages=False, clear=False, | |
self.symlinks = symlinks | ||
self.upgrade = upgrade | ||
self.with_pip = with_pip | ||
self.orig_prompt = prompt | ||
vsajip marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if prompt == '.': # see bpo-38901 | ||
prompt = os.path.basename(os.getcwd()) | ||
self.prompt = prompt | ||
|
@@ -178,6 +179,29 @@ def create_configuration(self, context): | |
f.write('version = %d.%d.%d\n' % sys.version_info[:3]) | ||
if self.prompt is not None: | ||
f.write(f'prompt = {self.prompt!r}\n') | ||
f.write('executable = %s\n' % os.path.realpath(sys.executable)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I appreciate that this PR is long since merged, but just following-up on a surprising I'm not at all sure why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, it is a difference when you're not on Windows. But thinking about it, you could view the config as recording the actual interpreter used instead of the path that could change on you in the future (e.g., some symlink later gets changed to point to another interpreter). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for this perspective (I hadn't considered it)! I'm not sure that using a config file to log information about how a venv was created is a good idea, but can appreciate the idea. Since this is a machine readable file, I would be concerned that it eventually gets used for non-log/audit purposes. I've been digging into symlink issues with venv a lot recently, and think calling No follow-up needed here - just flagging it, and depending on the outcome of the linked issue, perhaps in the future I may request that this information become non realpath, or under a "history of how this venv was created" section of the config (perhaps in the form of a comment). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
args = [] | ||
nt = os.name == 'nt' | ||
if nt and self.symlinks: | ||
args.append('--symlinks') | ||
vsajip marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if not nt and not self.symlinks: | ||
args.append('--copies') | ||
if not self.with_pip: | ||
args.append('--without-pip') | ||
if self.system_site_packages: | ||
args.append('--system-site-packages') | ||
if self.clear: | ||
args.append('--clear') | ||
if self.upgrade: | ||
args.append('--upgrade') | ||
if self.upgrade_deps: | ||
args.append('--upgrade-deps') | ||
if self.orig_prompt is not None: | ||
args.append(f'--prompt="{self.orig_prompt}"') | ||
|
||
args.append(context.env_dir) | ||
args = ' '.join(args) | ||
f.write(f'command = {sys.executable} -m venv {args}\n') | ||
vsajip marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if os.name != 'nt': | ||
def symlink_or_copy(self, src, dst, relative_symlinks_ok=False): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Added two new variables to *pyvenv.cfg* which is generated by :mod:`venv` | ||
module: *executable* for the executable and *command* for the command line used | ||
to create the environment. |
Uh oh!
There was an error while loading. Please reload this page.