gpt4 book ai didi

python - 将 git 克隆到虚拟 Python 环境的推荐工作流程

转载 作者:行者123 更新时间:2023-12-01 08:13:34 26 4
gpt4 key购买 nike

如果我想将 git 存储库 pull 入虚拟 Python 环境,推荐的工作流程是什么?我认为最简单的是:

  1. 创建一个空目录
  2. 进入它并 git clone <repo> ,因为这仅适用于空目录
  3. 在同一目录的子目录中创建虚拟环境
  4. 启动 VE 并安装 <repo> 中的requirements.txt .
  5. 将子目录(以及其他仅供我引用的内容)添加到 .gitignore
  6. 按预期开展项目
  7. 也许要求将有值(value)/可共享的结果推送到原始存储库。

或者有更好的方法吗?

免责声明:我对 git 非常精通,请耐心等待。我很清楚已经有多个类似的答案,但是我找不到令人信服的 TL;DR。也许我错过了。

最佳答案

这就是我喜欢做的事情:

git clone <repo> <repodir>
cd <repodir>
virtualenv .venv
. .venv/bin/activate
pip install -e .

就是这样。现在,我所做的任何编辑都将在虚拟环境中“实时”进行。我有一个包含 .venv 的全局 .gitignore 文件 (git config --global core.excludesfile ~/.gitignore),所以我不不需要更新各个存储库中的 .gitignore

请注意,您不需要在空目录中运行 git clone。因为它创建了一个目录,所以它不关心当前目录是否为空。

更新

看,我们位于一个非空目录中:

bash-4.4$ ls
file1 file2 file3

我们可以在这里运行git clone:

bash-4.4$ git clone https://github.com/git/git
Cloning into 'git'...
remote: Enumerating objects: 264438, done.
remote: Total 264438 (delta 0), reused 0 (delta 0), pack-reused 264438
Receiving objects: 100% (264438/264438), 112.69 MiB | 9.84 MiB/s, done.
Resolving deltas: 100% (196057/196057), done.

它运行没有问题并创建一个新目录:

bash-4.4$ ls
file1 file2 file3 git

关于python - 将 git 克隆到虚拟 Python 环境的推荐工作流程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55087632/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com