Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7601d780
Commit
7601d780
authored
Feb 02, 2017
by
Vinay Sajip
Browse files
Options
Browse Files
Download
Plain Diff
Closes #24875: Merged fix from 3.6.
parents
e1af6964
993f535a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
8 deletions
+23
-8
Lib/test/test_venv.py
Lib/test/test_venv.py
+14
-8
Lib/venv/__init__.py
Lib/venv/__init__.py
+9
-0
No files found.
Lib/test/test_venv.py
View file @
7601d780
...
@@ -330,12 +330,7 @@ class EnsurePipTest(BaseTest):
...
@@ -330,12 +330,7 @@ class EnsurePipTest(BaseTest):
else
:
else
:
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
devnull
))
self
.
assertTrue
(
os
.
path
.
exists
(
os
.
devnull
))
def
do_test_with_pip
(
self
,
system_site_packages
):
@
unittest
.
skipUnless
(
threading
,
'some dependencies of pip import threading'
' module unconditionally'
)
# Issue #26610: pip/pep425tags.py requires ctypes
@
unittest
.
skipUnless
(
ctypes
,
'pip requires ctypes'
)
def
test_with_pip
(
self
):
rmtree
(
self
.
env_dir
)
rmtree
(
self
.
env_dir
)
with
EnvironmentVarGuard
()
as
envvars
:
with
EnvironmentVarGuard
()
as
envvars
:
# pip's cross-version compatibility may trigger deprecation
# pip's cross-version compatibility may trigger deprecation
...
@@ -369,6 +364,7 @@ class EnsurePipTest(BaseTest):
...
@@ -369,6 +364,7 @@ class EnsurePipTest(BaseTest):
# config in place to ensure we ignore it
# config in place to ensure we ignore it
try
:
try
:
self
.
run_with_capture
(
venv
.
create
,
self
.
env_dir
,
self
.
run_with_capture
(
venv
.
create
,
self
.
env_dir
,
system_site_packages
=
system_site_packages
,
with_pip
=
True
)
with_pip
=
True
)
except
subprocess
.
CalledProcessError
as
exc
:
except
subprocess
.
CalledProcessError
as
exc
:
# The output this produces can be a little hard to read,
# The output this produces can be a little hard to read,
...
@@ -418,9 +414,19 @@ class EnsurePipTest(BaseTest):
...
@@ -418,9 +414,19 @@ class EnsurePipTest(BaseTest):
out
=
out
.
decode
(
"latin-1"
)
# Force to text, prevent decoding errors
out
=
out
.
decode
(
"latin-1"
)
# Force to text, prevent decoding errors
self
.
assertIn
(
"Successfully uninstalled pip"
,
out
)
self
.
assertIn
(
"Successfully uninstalled pip"
,
out
)
self
.
assertIn
(
"Successfully uninstalled setuptools"
,
out
)
self
.
assertIn
(
"Successfully uninstalled setuptools"
,
out
)
# Check pip is now gone from the virtual environment
# Check pip is now gone from the virtual environment. This only
# applies in the system_site_packages=False case, because in the
# other case, pip may still be available in the system site-packages
if
not
system_site_packages
:
self
.
assert_pip_not_installed
()
self
.
assert_pip_not_installed
()
@
unittest
.
skipUnless
(
threading
,
'some dependencies of pip import threading'
' module unconditionally'
)
# Issue #26610: pip/pep425tags.py requires ctypes
@
unittest
.
skipUnless
(
ctypes
,
'pip requires ctypes'
)
def
test_with_pip
(
self
):
self
.
do_test_with_pip
(
False
)
self
.
do_test_with_pip
(
True
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
unittest
.
main
()
unittest
.
main
()
Lib/venv/__init__.py
View file @
7601d780
...
@@ -57,6 +57,10 @@ class EnvBuilder:
...
@@ -57,6 +57,10 @@ class EnvBuilder:
"""
"""
env_dir
=
os
.
path
.
abspath
(
env_dir
)
env_dir
=
os
.
path
.
abspath
(
env_dir
)
context
=
self
.
ensure_directories
(
env_dir
)
context
=
self
.
ensure_directories
(
env_dir
)
# See issue 24875. We need system_site_packages to be False
# until after pip is installed.
true_system_site_packages
=
self
.
system_site_packages
self
.
system_site_packages
=
False
self
.
create_configuration
(
context
)
self
.
create_configuration
(
context
)
self
.
setup_python
(
context
)
self
.
setup_python
(
context
)
if
self
.
with_pip
:
if
self
.
with_pip
:
...
@@ -64,6 +68,11 @@ class EnvBuilder:
...
@@ -64,6 +68,11 @@ class EnvBuilder:
if
not
self
.
upgrade
:
if
not
self
.
upgrade
:
self
.
setup_scripts
(
context
)
self
.
setup_scripts
(
context
)
self
.
post_setup
(
context
)
self
.
post_setup
(
context
)
if
true_system_site_packages
:
# We had set it to False before, now
# restore it and rewrite the configuration
self
.
system_site_packages
=
True
self
.
create_configuration
(
context
)
def
clear_directory
(
self
,
path
):
def
clear_directory
(
self
,
path
):
for
fn
in
os
.
listdir
(
path
):
for
fn
in
os
.
listdir
(
path
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment