python / python/cpython

venv.EnvBuilder creates inconsistent venv depending on the name of the Python executable

Ouverte
#122,033 6 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

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

Description

Bug report

Bug description:

Given the below create-venv.py script and several Python 3 installed in the classpath:

import sys
import venv


if __name__ == "__main__":
    venv.EnvBuilder().create(sys.argv[1])

Let’s create various venvs:

for VERSION in 3.9 3.11 3.12; do
  python$VERSION create-venv.py $VERSION-venv
  for EXEC in python python3 python$VERSION; do
    $VERSION-venv/bin/$EXEC create-venv.py $VERSION-$EXEC-venv
  done
done

And now, let’s check them:

for PYTHON in *-venv/bin/python; do
  echo "$PYTHON: $($PYTHON --version)"
done

The above loop outputs:

3.11-python3.11-venv/bin/python: Python 3.11.7
3.11-python3-venv/bin/python: Python 3.9.14
3.11-python-venv/bin/python: Python 3.9.14
3.11-venv/bin/python: Python 3.11.7
3.12-python3.12-venv/bin/python: Python 3.12.1
3.12-python3-venv/bin/python: Python 3.9.14
3.12-python-venv/bin/python: Python 3.9.14
3.12-venv/bin/python: Python 3.12.1
3.9-python3.9-venv/bin/python: Python 3.9.14
3.9-python3-venv/bin/python: Python 3.9.14
3.9-python-venv/bin/python: Python 3.9.14
3.9-venv/bin/python: Python 3.9.14

As the reader can see, Python venv’s created by python or python3 executable of a Python venv will not use the Python of this venv, and instead will use the system’s default Python (3.9 in my case).

CPython versions tested on:

3.11, 3.12

Operating systems tested on:

Oracle Linux 9 and 10

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

Commencez par le script fourni create-venv.py et le point d’entrée venv.EnvBuilder, puis exécutez la boucle shell avec plusieurs noms d’exécutables Python afin de reproduire la sélection incohérente de l’interpréteur. Suivez la manière dont l’exécutable utilisé pour invoquer EnvBuilder est enregistré et utilisé lors de la création de chaque environnement ; le travail est terminé lorsque python, python3 et les exécutables versionnés à l’intérieur d’un venv créent systématiquement des environnements utilisant l’interpréteur de ce venv.

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

Évaluation

Stack technique
python
Domaine
tooling
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
48/100

Recevez les nouvelles issues par e-mail

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