python / python/cpython

venv: optional activate link/copy to solve ci/portability headaches

Ouverte
#100,281 3 commentaires 1 réaction 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

stdlib topic-venv type-feature
Langage dominant
Python
Étoiles
77.2k
Forks
36k
Métriques de merge des PR
Métriques de PR en attente

Description

Problem

activate location is platform dependent.

Background

15+ years ago PyPY made a decision that has often been a headache for portability; putting activate in Scripts for Windows and bin for everyone else.

This is sometimes misreported as a bug (https://github.com/python/cpython/issues/97586), core issue (https://bugs.python.org/issue35003), discussion (https://github.com/python/cpython/pull/18083) and recurrent threads on the pypy issues list (https://github.com/pypa/virtualenv/issues/2404, https://github.com/pypa/virtualenv/issues/1418#issuecomment-910044412)

It's an exceptional pain point because 1/ you chose python to ease portability, -2->/ you use venv as an extra layer of abstraction, -3->/ surprise! your abstraction requires you to take two different routes based on platform!

Proposal

Introduce an option that causes the creation of a symlink or second copy of the activator at a user specified path.

Ubuntu|Pwsh> venv -p python 3.10 --activator-copy=/opt/ci/activate /opt/ci
Windows|Pwsh> venv -p python 3.10 --activator-copy=o:/ci/activate o:/ci

Arguments

(Per the original change) "Scripts is the correct location for activate on Windows"

  • This doesn't move it, so everything that already supports the split will work as before,
  • Python itself now violates the Scripts rule, which is an attractor to people who wanted to hide platform specifics,

It's not a big deal, just if .. then else

CI and building today is complex with many moving parts, having an intermediate level abstraction suddenly require you to think about platforms is always a headache. If you're using something like gitlab, you end up with a huge hitch in complexity to achieve this for the scope it's in under the current system.

Windows doesn't support symlinks

Whether it is a file or a symlink is irrelevant, and anyone who is actively working to support a version of Windows old enough to not support symlinks already has enough of their hair on fire that they'll gladly accept it falling back to creating a file instead of junction.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Aucun fichier ni test n'est nommé. Suivez la création de venv et la gestion de ses options de ligne de commande, puis vérifiez le chemin d'activation spécifié par l'utilisateur sur Ubuntu et Windows PowerShell, y compris le comportement de lien symbolique ou de copie ; le travail est considéré comme terminé lorsque l'option fonctionne sans modifier les emplacements spécifiques aux plateformes existants.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
cli, devtools
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.