Skip to content

Commit c03e9c7

Browse files
committed
add flag --use-env to env commands (build, install, run, show) to specify the python executable to use
1 parent 925429f commit c03e9c7

File tree

6 files changed

+11
-5
lines changed

6 files changed

+11
-5
lines changed

Diff for: poetry/console/application.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def configure_env(
265265
poetry = command.poetry
266266

267267
env_manager = EnvManager(poetry)
268-
env = env_manager.create_venv(io)
268+
env = env_manager.create_venv(io, executable=event.io.input.option("use-env"))
269269

270270
if env.is_venv() and io.is_verbose():
271271
io.write_line(f"Using virtualenv: <comment>{env.path}</>")

Diff for: poetry/console/commands/build.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class BuildCommand(EnvCommand):
88
name = "build"
99
description = "Builds a package, as a tarball and a wheel by default."
1010

11-
options = [
11+
options = EnvCommand.options + [
1212
option("format", "f", "Limit the format to either sdist or wheel.", flag=False)
1313
]
1414

Diff for: poetry/console/commands/env_command.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from typing import TYPE_CHECKING
22

3+
from cleo.helpers import option
4+
35
from .command import Command
46

57

@@ -8,6 +10,10 @@
810

911

1012
class EnvCommand(Command):
13+
options = [
14+
option("use-env", None, "The python executable to use.", flag=False),
15+
]
16+
1117
def __init__(self) -> None:
1218
self._env = None
1319

Diff for: poetry/console/commands/install.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class InstallCommand(InstallerCommand):
88
name = "install"
99
description = "Installs the project dependencies."
1010

11-
options = [
11+
options = InstallerCommand.options + [
1212
option("no-dev", None, "Do not install the development dependencies."),
1313
option("dev-only", None, "Only install the development dependencies."),
1414
option(

Diff for: poetry/console/commands/run.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class RunCommand(EnvCommand):
1616
name = "run"
1717
description = "Runs a command in the appropriate environment."
1818

19-
arguments = [
19+
arguments = EnvCommand.options + [
2020
argument("args", "The command and arguments/options to run.", multiple=True)
2121
]
2222

Diff for: poetry/console/commands/show.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ShowCommand(EnvCommand):
2424
description = "Shows information about packages."
2525

2626
arguments = [argument("package", "The package to inspect", optional=True)]
27-
options = [
27+
options = EnvCommand.options + [
2828
option("no-dev", None, "Do not list the development dependencies."),
2929
option("tree", "t", "List the dependencies as a tree."),
3030
option("latest", "l", "Show the latest version."),

0 commit comments

Comments
 (0)