diff --git a/docs/usage/config.md b/docs/usage/config.md index 31bf5f504d..e7fecdbd13 100644 --- a/docs/usage/config.md +++ b/docs/usage/config.md @@ -300,6 +300,18 @@ Alternatively, if you have installed a copy of keyring globally, make sure the C export PATH=$PATH:path/to/keyring/bin ``` +### Password management with keyring for Azure Artifacts + +When trying to authenticate towards azure artifacts, this can be achieved by either using AD groups to authenticate: `pdm self add keyring artifacts-keyring` ensuring that artifacts-keyring will be used for authentication. + +And then adding the artifacts url to `pyproject.toml` + +``` +[[tool.pdm.source]] +name = "NameOfFeed" +url = "https://pkgs.dev.azure.com/[org name]/_packaging/[feed name]/pypi/simple/" +``` + ## Override the resolved package versions +++ 1.12.0 diff --git a/news/2851.bugfix.md b/news/2851.bugfix.md new file mode 100644 index 0000000000..bf5721a778 --- /dev/null +++ b/news/2851.bugfix.md @@ -0,0 +1 @@ +Fixed pdm venv activate, to also work for windows. And added documentation on how to authenticate to Azure Artifacts \ No newline at end of file diff --git a/src/pdm/cli/commands/venv/activate.py b/src/pdm/cli/commands/venv/activate.py index d827cababc..a8fe5a0161 100644 --- a/src/pdm/cli/commands/venv/activate.py +++ b/src/pdm/cli/commands/venv/activate.py @@ -1,4 +1,5 @@ import argparse +import platform import shlex from pathlib import Path @@ -55,9 +56,11 @@ def get_activate_command(self, venv: VirtualEnv) -> str: # pragma: no cover command, filename = "source", "activate" activate_script = venv.interpreter.with_name(filename) if activate_script.exists(): + if platform.system() == "Windows": + return f"{self.quote(str(activate_script), shell)}" return f"{command} {self.quote(str(activate_script), shell)}" # Conda backed virtualenvs don't have activate scripts - return f"conda activate {shlex.quote(str(venv.root))}" + return f"conda activate {self.quote(str(venv.root), shell)}" @staticmethod def quote(command: str, shell: str) -> str: diff --git a/tests/cli/test_venv.py b/tests/cli/test_venv.py index 8b04977aa1..a7d3fa876c 100644 --- a/tests/cli/test_venv.py +++ b/tests/cli/test_venv.py @@ -1,4 +1,5 @@ import os +import platform import re import shutil import sys @@ -133,7 +134,10 @@ def test_venv_activate(pdm, mocker, project): assert result.output.startswith("conda activate") else: assert result.output.strip("'\"\n").endswith("activate") - assert result.output.startswith("source") + if platform.system() == "Windows": + assert not result.output.startswith("source") + else: + assert result.output.startswith("source") @pytest.mark.usefixtures("venv_backends") @@ -186,7 +190,10 @@ def test_venv_activate_no_shell(pdm, mocker, project): assert result.output.startswith("conda activate") else: assert result.output.strip("'\"\n").endswith("activate") - assert result.output.startswith("source") + if platform.system() == "Windows": + assert not result.output.startswith("source") + else: + assert result.output.startswith("source") @pytest.mark.usefixtures("fake_create")