-
Following #831, I'm taking a stab at implementing a
import argparse
import os
from pathlib import Path
from pdm.cli import actions
from pdm.cli.hooks import HookManager
from pdm.cli.commands.run import Command as RunCommand, Project
# TODO: just testing, will change
PYTHON_VERSIONS = os.getenv("PDM_MULTIRUN_VERSIONS", "").split()
PYTHON_VERSIONS = PYTHON_VERSIONS or [f"python3.{minor}" for minor in range(7, 12)]
class MultirunCommand(RunCommand):
"""Run a command under multiple Python versions."""
def handle(self, project: Project, options: argparse.Namespace) -> None:
for python_version in PYTHON_VERSIONS:
actions.do_use(
project,
python=python_version,
first=True,
ignore_remembered=False,
hooks=HookManager(project, skip=options.skip),
)
print(Path(".pdm.toml").read_text()) # debug
try:
super().handle(project, options)
except SystemExit as exit:
if exit.code:
raise
def multirun(core):
core.register_command(MultirunCommand, "multirun") However it seems that PDM reads % python -m pdm multirun python -V
Using the last selection, add '-i' to ignore it.
Using Python interpreter: /home/pawamoy/.basher-packages/pyenv/pyenv/shims/python3.7 (3.7)
Updating executable scripts...
[python]
path = "/home/pawamoy/.basher-packages/pyenv/pyenv/shims/python3.7"
Python 3.7.15
Using the last selection, add '-i' to ignore it.
Using Python interpreter: /home/pawamoy/.basher-packages/pyenv/pyenv/shims/python3.8 (3.8)
Updating executable scripts...
[python]
path = "/home/pawamoy/.basher-packages/pyenv/pyenv/shims/python3.8"
Python 3.7.15
Using the last selection, add '-i' to ignore it.
Using Python interpreter: /home/pawamoy/.basher-packages/pyenv/pyenv/shims/python3.9 (3.9)
Updating executable scripts...
[python]
path = "/home/pawamoy/.basher-packages/pyenv/pyenv/shims/python3.9"
Python 3.7.15
Using the last selection, add '-i' to ignore it.
Using Python interpreter: /home/pawamoy/.basher-packages/pyenv/pyenv/shims/python3.10 (3.10)
Updating executable scripts...
[python]
path = "/home/pawamoy/.basher-packages/pyenv/pyenv/shims/python3.10"
Python 3.7.15
Using the last selection, add '-i' to ignore it.
Using Python interpreter: /home/pawamoy/.basher-packages/pyenv/pyenv/shims/python3.11 (3.11)
Updating executable scripts...
[python]
path = "/home/pawamoy/.basher-packages/pyenv/pyenv/shims/python3.11"
Python 3.7.15 Is there a way to force-reload the configuration from Also, I would like to hide the output of |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
I'm able to discard the output with this: old_echo = project.core.ui.echo
project.core.ui.echo = lambda *args, **kwargs: None Though still no luck with getting the right Python version to run 😕 |
Beta Was this translation helpful? Give feedback.
-
The project.environment = None And it will work fine. |
Beta Was this translation helpful? Give feedback.
-
That's awesome ! |
Beta Was this translation helpful? Give feedback.
The
project.environment
is set and cached, you need to clear that value after switching:And it will work fine.