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

Conversation

Pluttodk
Copy link
Contributor

Pull Request Checklist

  • A news fragment is added in news/ describing what is new.
  • Test cases added for changed code.

Describe what you have changed in this PR.

Altered the pdm venv activate to not include "." on windows, since this causes an error. This also ensures, that for non Powershell users on windows, the outputted command can be directly pasted into shell.

Additionally added documentation as to how to add authentication to Azure Artifacts, since this seems to be a common question asked. Such as: #2760

@@ -55,6 +56,8 @@ 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"{shlex.quote(str(activate_script))}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look above several lines, we have a case for powershell. this will completely bypass it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works for powershell 7 and not 5.1. Neither does the old solution work for Batch.

I did not want to remove the previous check with powershell, since you can install powershell on linux (not sure why you would want that but you can) and that supports the dot command.

Output from powershell 5.1

> Invoke-Expression (pdm venv activate)
C:\Code\data_indhentning\.venv\Scripts\Activate.ps1 : Cannot dot-source this command because it was defined in a differ
ent language mode. To invoke this command without importing its contents, omit the '.' operator.
At line:1 char:1
+ . 'C:\Code\.venv\Scripts\Activate.ps1'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Activate.ps1], NotSupportedException
    + FullyQualifiedErrorId : DotSourceNotSupported,Activate.ps1

@frostming frostming linked an issue May 16, 2024 that may be closed by this pull request
@frostming frostming merged commit b88bd4f into pdm-project:main May 16, 2024
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fail to authenticate for Azure Artifacts
2 participants