Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix activate for windows and updated docs for Azure #2854

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/usage/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions news/2851.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed pdm venv activate, to also work for windows. And added documentation on how to authenticate to Azure Artifacts
5 changes: 4 additions & 1 deletion src/pdm/cli/commands/venv/activate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import platform
import shlex
from pathlib import Path

Expand Down Expand Up @@ -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:
Expand Down
11 changes: 9 additions & 2 deletions tests/cli/test_venv.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import platform
import re
import shutil
import sys
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down