Skip to content

Commit

Permalink
add flag --use-env to env commands (build, install, run, show) to s…
Browse files Browse the repository at this point in the history
…pecify the python executable to use
  • Loading branch information
finswimmer committed Jun 14, 2021
1 parent 925429f commit c03e9c7
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion poetry/console/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def configure_env(
poetry = command.poetry

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

if env.is_venv() and io.is_verbose():
io.write_line(f"Using virtualenv: <comment>{env.path}</>")
Expand Down
2 changes: 1 addition & 1 deletion poetry/console/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class BuildCommand(EnvCommand):
name = "build"
description = "Builds a package, as a tarball and a wheel by default."

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

Expand Down
6 changes: 6 additions & 0 deletions poetry/console/commands/env_command.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import TYPE_CHECKING

from cleo.helpers import option

from .command import Command


Expand All @@ -8,6 +10,10 @@


class EnvCommand(Command):
options = [
option("use-env", None, "The python executable to use.", flag=False),
]

def __init__(self) -> None:
self._env = None

Expand Down
2 changes: 1 addition & 1 deletion poetry/console/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class InstallCommand(InstallerCommand):
name = "install"
description = "Installs the project dependencies."

options = [
options = InstallerCommand.options + [
option("no-dev", None, "Do not install the development dependencies."),
option("dev-only", None, "Only install the development dependencies."),
option(
Expand Down
2 changes: 1 addition & 1 deletion poetry/console/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class RunCommand(EnvCommand):
name = "run"
description = "Runs a command in the appropriate environment."

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

Expand Down
2 changes: 1 addition & 1 deletion poetry/console/commands/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ShowCommand(EnvCommand):
description = "Shows information about packages."

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

0 comments on commit c03e9c7

Please sign in to comment.