Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
slapos.buildout
Commits
45519869
Commit
45519869
authored
May 31, 2024
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fixup] Fix leaked temporary pip $HOME on exit
Fixup "
711d8710
"
parent
94d51e5a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
53 deletions
+58
-53
src/zc/buildout/easy_install.py
src/zc/buildout/easy_install.py
+58
-53
No files found.
src/zc/buildout/easy_install.py
View file @
45519869
...
...
@@ -18,7 +18,6 @@ It doesn't install scripts. It uses setuptools and requires it to be
installed.
"""
import
atexit
import
copy
import
distutils.errors
import
distutils.sysconfig
...
...
@@ -1843,67 +1842,73 @@ try:
except
ImportError
:
PIP_HAS_PYTHON_VERSION_WARNING_OPTION
=
False
# Temporary HOME with .pydistutils.cfg to disable setup_requires
pip_pydistutils_home
=
tempfile
.
mkdtemp
(
'pip-pydistutils-home'
)
with
open
(
os
.
path
.
join
(
pip_pydistutils_home
,
'.pydistutils.cfg'
),
'w'
)
as
f
:
f
.
write
(
"[easy_install]
\
n
"
"index-url = file:///dev/null"
)
atexit
.
register
(
zc
.
buildout
.
rmtree
.
rmtree
,
pip_pydistutils_home
)
def
call_pip_command
(
command
,
operand
,
options
,
verbosity
=-
10
):
"""
Call `pip <command...> <operand...>` from a subprocess
with appropriate options and environment.
"""
env
=
os
.
environ
.
copy
()
pythonpath
=
pip_path
[:]
pythonpath
.
extend
(
env
.
get
(
k
)
for
k
in
(
'PYTHONPATH'
,
'PYTHONEXTRAPATH'
))
env
[
'PYTHONPATH'
]
=
os
.
pathsep
.
join
(
p
for
p
in
pythonpath
if
p
)
args
=
[
sys
.
executable
,
'-m'
,
'pip'
]
args
.
extend
(
command
)
args
.
append
(
'--no-deps'
)
log_level
=
logger
.
getEffectiveLevel
()
pip_level
=
log_level
-
verbosity
if
pip_level
>=
logging
.
WARNING
:
args
.
append
(
'-'
+
'q'
*
(
1
+
(
pip_level
>=
logging
.
ERROR
)))
# -q or -qq
elif
pip_level
<
logging
.
INFO
:
args
.
append
(
'-'
+
'v'
*
(
1
+
(
pip_level
<
logging
.
DEBUG
)))
# -v or -vv
# Note: more recent pip accepts even -vvv and -qqq.
if
not
options
.
_allow_picked_versions
:
# Prevent pip from installing build dependencies on the fly
# without respecting pinned versions. This only works for
# PEP 517 specifications using pyproject.toml and not for
# dependencies in setup_requires option in legacy setup.py
args
.
append
(
'--no-index'
)
args
.
append
(
'--no-build-isolation'
)
# Prevent setuptools from downloading and thus installing
# build dependencies specified in setup_requires option of
# legacy setup.py by providing a crafted .pydistutils.cfg.
# This is used in complement to --no-build-isolation.
env
[
'HOME'
]
=
pip_pydistutils_home
if
PIP_HAS_PYTHON_VERSION_WARNING_OPTION
:
# Let pip display Python warnings only on first run.
if
not
hasattr
(
call_pip_command
,
'displayed'
):
call_pip_command
.
displayed
=
True
else
:
args
.
append
(
'--no-python-version-warning'
)
cleanup
=
[]
try
:
env
=
os
.
environ
.
copy
()
pythonpath
=
pip_path
[:]
pythonpath
.
extend
(
env
.
get
(
k
)
for
k
in
(
'PYTHONPATH'
,
'PYTHONEXTRAPATH'
))
env
[
'PYTHONPATH'
]
=
os
.
pathsep
.
join
(
p
for
p
in
pythonpath
if
p
)
args
=
[
sys
.
executable
,
'-m'
,
'pip'
]
args
.
extend
(
command
)
args
.
append
(
'--no-deps'
)
log_level
=
logger
.
getEffectiveLevel
()
pip_level
=
log_level
-
verbosity
if
pip_level
>=
logging
.
WARNING
:
args
.
append
(
'-'
+
'q'
*
(
1
+
(
pip_level
>=
logging
.
ERROR
)))
elif
pip_level
<
logging
.
INFO
:
args
.
append
(
'-'
+
'v'
*
(
1
+
(
pip_level
<
logging
.
DEBUG
)))
# Note: more recent pip accepts even -vvv and -qqq.
if
not
options
.
_allow_picked_versions
:
# Prevent pip from installing build dependencies on the fly
# without respecting pinned versions. This only works for
# PEP 517 specifications using pyproject.toml and not for
# dependencies in setup_requires option in legacy setup.py
args
.
append
(
'--no-index'
)
args
.
append
(
'--no-build-isolation'
)
# Prevent setuptools from downloading and thus installing
# build dependencies specified in setup_requires option of
# legacy setup.py by providing a crafted .pydistutils.cfg.
# This is used in complement to --no-build-isolation.
pip_home
=
tempfile
.
mkdtemp
(
'pip-pydistutils-home'
)
cleanup
.
append
(
lambda
:
zc
.
buildout
.
rmtree
.
rmtree
(
pip_home
))
with
open
(
os
.
path
.
join
(
pip_home
,
'.pydistutils.cfg'
),
'w'
)
as
f
:
f
.
write
(
"[easy_install]
\
n
"
"index_url = file:///dev/null"
)
env
[
'HOME'
]
=
pip_home
if
PIP_HAS_PYTHON_VERSION_WARNING_OPTION
:
# Let pip display Python warnings only on first run.
if
not
hasattr
(
call_pip_command
,
'displayed'
):
call_pip_command
.
displayed
=
True
else
:
args
.
append
(
'--no-python-version-warning'
)
args
.
extend
(
operand
)
args
.
extend
(
operand
)
if
log_level
<
logging
.
DEBUG
:
# Log this only when buildout log level is quite low
logger
.
debug
(
'Running pip %s'
,
' '
.
join
(
command
[
0
:
1
]
+
operand
))
if
log_level
<
0
:
# Log this only when buildout log level is even lower
logger
.
debug
(
'%s
\
n
PYTHONPATH=%s
\
n
'
,
' '
.
join
(
args
),
env
[
'PYTHONPATH'
])
if
log_level
<
logging
.
DEBUG
:
# Log this only when buildout log level is quite low
logger
.
debug
(
'Running pip %s'
,
' '
.
join
(
command
[
0
:
1
]
+
operand
))
if
log_level
<
0
:
# Log this only when buildout log level is even lower
logger
.
debug
(
'%s
\
n
PYTHONPATH=%s
\
n
'
,
' '
.
join
(
args
),
env
[
'PYTHONPATH'
])
sys
.
stdout
.
flush
()
# We want any pending output first
subprocess
.
check_call
(
args
,
env
=
env
)
sys
.
stdout
.
flush
()
# We want any pending output first
subprocess
.
check_call
(
args
,
env
=
env
)
finally
:
for
f
in
cleanup
:
f
()
def
call_pip_editable
(
path
,
dest
,
options
,
verbosity
=-
10
):
...
...
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