Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
d4d03d0e
Commit
d4d03d0e
authored
Nov 30, 2021
by
finswimmer
Committed by
Bjorn Neergaard
Jan 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add option `virtualenvs.prefer-shell-python`
parent
45b20eee
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
20 deletions
+43
-20
src/poetry/config/config.py
+2
-0
src/poetry/console/application.py
+33
-20
src/poetry/console/commands/config.py
+5
-0
tests/console/commands/test_config.py
+3
-0
No files found.
src/poetry/config/config.py
View file @
d4d03d0e
...
...
@@ -38,6 +38,7 @@ class Config:
"in-project"
:
None
,
"path"
:
os
.
path
.
join
(
"{cache-dir}"
,
"virtualenvs"
),
"options"
:
{
"always-copy"
:
False
,
"system-site-packages"
:
False
},
"prefer-shell-python"
:
False
,
},
"experimental"
:
{
"new-installer"
:
True
},
"installer"
:
{
"parallel"
:
True
,
"max-workers"
:
None
},
...
...
@@ -138,6 +139,7 @@ class Config:
"virtualenvs.in-project"
,
"virtualenvs.options.always-copy"
,
"virtualenvs.options.system-site-packages"
,
"virtualenvs.options.prefer-shell-python"
,
"experimental.new-installer"
,
"installer.parallel"
,
}:
...
...
src/poetry/console/application.py
View file @
d4d03d0e
import
contextlib
import
logging
import
re
import
subprocess
...
...
@@ -19,6 +18,7 @@ from cleo.events.event_dispatcher import EventDispatcher
from
cleo.exceptions
import
CleoException
from
cleo.formatters.style
import
Style
from
cleo.io.inputs.argv_input
import
ArgvInput
from
cleo.io.outputs.output
import
Verbosity
from
poetry.core.utils._compat
import
PY37
from
poetry.__version__
import
__version__
...
...
@@ -229,6 +229,30 @@ class Application(BaseApplication):
return
super
()
.
_configure_io
(
io
)
def
_detect_active_python
(
self
,
io
:
"IO"
)
->
str
:
executable
=
None
try
:
io
.
write_line
(
"Trying to detect current active python executable as specified in the config."
,
verbosity
=
Verbosity
.
VERBOSE
,
)
executable
=
decode
(
subprocess
.
check_output
(
list_to_shell_command
(
[
"python"
,
"-c"
,
'"import sys; print(sys.executable)"'
]
),
shell
=
True
,
)
.
strip
()
)
io
.
write_line
(
f
"Found: {executable}"
,
verbosity
=
Verbosity
.
VERBOSE
)
except
CalledProcessError
:
io
.
write_line
(
"Unable to detect the current active python executable. Falling back to default."
,
verbosity
=
Verbosity
.
VERBOSE
,
)
return
executable
def
register_command_loggers
(
self
,
event
:
"ConsoleCommandEvent"
,
event_name
:
str
,
_
:
Any
)
->
None
:
...
...
@@ -287,28 +311,17 @@ class Application(BaseApplication):
io
=
event
.
io
poetry
=
command
.
poetry
executable
=
None
find_compatible
=
None
# add on option to trigger this
with
contextlib
.
suppress
(
CalledProcessError
):
executable
=
decode
(
subprocess
.
check_output
(
list_to_shell_command
(
[
"python"
,
"-c"
,
'"import sys; print(sys.executable)"'
,
]
),
shell
=
True
,
)
.
strip
()
)
find_compatible
=
True
executable
=
(
self
.
_detect_active_python
(
io
)
if
poetry
.
config
.
get
(
"virtualenvs.prefer-shell-python"
)
else
None
)
env_manager
=
EnvManager
(
poetry
)
env
=
env_manager
.
create_venv
(
io
,
executable
=
executable
,
find_compatible
=
find_compatible
io
,
executable
=
executable
,
find_compatible
=
True
if
executable
else
None
,
)
if
env
.
is_venv
()
and
io
.
is_verbose
():
...
...
src/poetry/console/commands/config.py
View file @
d4d03d0e
...
...
@@ -78,6 +78,11 @@ To remove a repository (repo is a short alias for repositories):
lambda
val
:
str
(
Path
(
val
)),
str
(
Path
(
CACHE_DIR
)
/
"virtualenvs"
),
),
"virtualenvs.prefer-shell-python"
:
(
boolean_validator
,
boolean_normalizer
,
False
,
),
"experimental.new-installer"
:
(
boolean_validator
,
boolean_normalizer
,
...
...
tests/console/commands/test_config.py
View file @
d4d03d0e
...
...
@@ -56,6 +56,7 @@ virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = {venv_path} # {config_cache_dir / 'virtualenvs'}
virtualenvs.prefer-shell-python = false
"""
assert
expected
==
tester
.
io
.
fetch_output
()
...
...
@@ -79,6 +80,7 @@ virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = {venv_path} # {config_cache_dir / 'virtualenvs'}
virtualenvs.prefer-shell-python = false
"""
assert
config
.
set_config_source
.
call_count
==
0
...
...
@@ -126,6 +128,7 @@ virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = {venv_path} # {config_cache_dir / 'virtualenvs'}
virtualenvs.prefer-shell-python = false
"""
assert
config
.
set_config_source
.
call_count
==
1
...
...
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