Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
6256fcbc
Kaydet (Commit)
6256fcbc
authored
Ara 23, 2013
tarafından
Nick Coghlan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Close #19734: ignore pip env vars in ensurepip
üst
3f122d6f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
9 deletions
+27
-9
ensurepip.rst
Doc/library/ensurepip.rst
+6
-0
__init__.py
Lib/ensurepip/__init__.py
+8
-0
test_ensurepip.py
Lib/test/test_ensurepip.py
+8
-0
test_venv.py
Lib/test/test_venv.py
+5
-9
No files found.
Doc/library/ensurepip.rst
Dosyayı görüntüle @
6256fcbc
...
...
@@ -117,6 +117,12 @@ Module API
*verbosity* controls the level of output to :data:`sys.stdout` from the
bootstrapping operation.
.. note::
The bootstrapping process has side effects on both ``sys.path`` and
``os.environ``. Invoking the command line interface in a subprocess
instead allows these side effects to be avoided.
.. note::
The bootstrapping process may install additional modules required by
...
...
Lib/ensurepip/__init__.py
Dosyayı görüntüle @
6256fcbc
...
...
@@ -43,10 +43,18 @@ def bootstrap(*, root=None, upgrade=False, user=False,
"""
Bootstrap pip into the current Python installation (or the given root
directory).
Note that calling this function will alter both sys.path and os.environ.
"""
if
altinstall
and
default_pip
:
raise
ValueError
(
"Cannot use altinstall and default_pip together"
)
# We deliberately ignore all pip environment variables
# See http://bugs.python.org/issue19734 for details
keys_to_remove
=
[
k
for
k
in
os
.
environ
if
k
.
startswith
(
"PIP_"
)]
for
k
in
keys_to_remove
:
del
os
.
environ
[
k
]
# By default, installing pip and setuptools installs all of the
# following scripts (X.Y == running Python version):
#
...
...
Lib/test/test_ensurepip.py
Dosyayı görüntüle @
6256fcbc
...
...
@@ -126,6 +126,14 @@ class TestBootstrap(unittest.TestCase):
ensurepip
.
bootstrap
(
altinstall
=
True
,
default_pip
=
True
)
self
.
run_pip
.
assert_not_called
()
def
test_pip_environment_variables_removed
(
self
):
# ensurepip deliberately ignores all pip environment variables
# See http://bugs.python.org/issue19734 for details
self
.
os_environ
[
"PIP_THIS_SHOULD_GO_AWAY"
]
=
"test fodder"
ensurepip
.
bootstrap
()
self
.
assertNotIn
(
"PIP_THIS_SHOULD_GO_AWAY"
,
self
.
os_environ
)
@contextlib.contextmanager
def
fake_pip
(
version
=
ensurepip
.
_PIP_VERSION
):
if
version
is
None
:
...
...
Lib/test/test_venv.py
Dosyayı görüntüle @
6256fcbc
...
...
@@ -294,11 +294,12 @@ class EnsurePipTest(BaseTest):
# warnings in current versions of Python. Ensure related
# environment settings don't cause venv to fail.
envvars
[
"PYTHONWARNINGS"
]
=
"e"
# pip doesn't ignore environment variables when running in
# isolated mode, and we don't have an active virtualenv here,
# we're relying on the native venv support in 3.3+
# ensurepip is different enough from a normal pip invocation
# that we want to ensure it ignores the normal pip environment
# variable settings. We set PIP_NO_INSTALL here specifically
# to check that ensurepip (and hence venv) ignores it.
# See http://bugs.python.org/issue19734 for details
del
envvars
[
"PIP_REQUIRE_VIRTUALENV"
]
envvars
[
"PIP_NO_INSTALL"
]
=
"1"
try
:
self
.
run_with_capture
(
venv
.
create
,
self
.
env_dir
,
with_pip
=
True
)
except
subprocess
.
CalledProcessError
as
exc
:
...
...
@@ -328,11 +329,6 @@ class EnsurePipTest(BaseTest):
# installers works (at least in a virtual environment)
cmd
=
[
envpy
,
'-Im'
,
'ensurepip._uninstall'
]
with
EnvironmentVarGuard
()
as
envvars
:
# pip doesn't ignore environment variables when running in
# isolated mode, and we don't have an active virtualenv here,
# we're relying on the native venv support in 3.3+
# See http://bugs.python.org/issue19734 for details
del
envvars
[
"PIP_REQUIRE_VIRTUALENV"
]
p
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
p
.
communicate
()
...
...
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