python / python/cpython

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

オープン
#100,281 コメント 3 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

stdlib topic-venv type-feature
主要言語
Python
スター
77.2k
フォーク
36k
PR マージ指標
PR 指標を取得中

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

ファイルやテストは指定されていません。venv の作成とそのコマンドラインオプションの処理を追跡し、続いて Ubuntu と Windows PowerShell で提案されたユーザー指定のアクティベーターパスを、シンボリックリンクまたはコピーの動作を含めて検証します。完了とは、既存のプラットフォーム固有の場所を変更せずにオプションが機能することです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
cli, devtools
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。