通过 sh 脚本自动创建 pyenv

Automate creation of a pyenv through sh scripts

我正在 运行ning 一个项目,该项目使用 pip 和 requirements.txt 文件来安装和跟踪一些依赖项。我想为 运行 编写一些 sh ​​脚本,构建并测试应用程序。对于初学者,我想要一种方法来检查当前文件夹是否在 pyenv 中,如果不在,则创建一个来封装应用程序而不是混淆其他人的依赖项。另外,如果 requirements.txt 是一个好方法,并且如果有一种方法可以像节点包那样跟踪已安装的版本,我想知道跟踪这种依赖关系的最佳方法。

使用Pipenv。这是一种比 requirements.txt 更好的跟踪依赖项的方法,它使用 Pyenv 自动安装项目所需的 Python 版本。

来自网站:

The problems that Pipenv seeks to solve are multi-faceted:

  • You no longer need to use pip and virtualenv separately. They work together.
  • Managing a requirements.txt file can be problematic, so Pipenv uses Pipfile and Pipfile.lock to separate abstract dependency declarations from the last tested combination.
  • Hashes are used everywhere, always. Security. Automatically expose security vulnerabilities.
  • Strongly encourage the use of the latest versions of dependencies to minimize security risks arising from outdated components.
  • Give you insight into your dependency graph (e.g. $ pipenv graph).
  • Streamline development workflow by loading .env files.

[...]

Pipenv Features

  • Enables truly deterministic builds, while easily specifying only what you want.
  • Generates and checks file hashes for locked dependencies.
  • Automatically install required Pythons, if pyenv is available.
  • Automatically finds your project home, recursively, by looking for a Pipfile.
  • Automatically generates a Pipfile, if one doesn’t exist.
  • Automatically creates a virtualenv in a standard location.
  • Automatically adds/removes packages to a Pipfile when they are installed or uninstalled.
  • Automatically loads .env files, if they exist.