- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用Poetry用于 Python 依赖管理,以及 PyCrate用于 ASN.1 编码/解码。
PyCrate 是从 GitHub 拉取的依赖项,一旦从 GitHub 拉取,就通过在 PyCrate 目录中运行安装文件来安装。
python setup.py install
如果可能的话,我想将安装步骤集成到我的 pyproject.toml
中。我当前的 pyproject.toml 包含 PyCrate,如下所示:
…
[tool.poetry.dependencies]
pycrate = {git = "https://github.com/P1sec/pycrate.git"}
…
这将从 GitHub 存储库中提取 PyCrate,但将其放入 Poetry 创建的 virtualenv 中的 src
文件夹中。
有什么方法可以在执行poetry install
时自动运行安装脚本吗?我研究过使用 Poetry scripts ,但到目前为止还无法正确启动并运行。
我当前的设置涉及运行 poetry install
,然后手动运行 PyCrate 的 setup.py install
,但是我希望安装我的 poetry
执行完整的设置(如果可以的话)。
任何有关此问题的帮助将不胜感激。
最佳答案
当您运行 poetry install
时,Poetry 应该已经为您运行了 python setup.py install
。
Poetry 基本上只是运行 pip install package
,它会下载包,并且基本上只是在包上运行 python setup.py install
!
Under the hood, [pip] will run
python setup.py install
来源:https://stackoverflow.com/a/15732821/10149169
但是,poetry 仅在隔离的虚拟环境中安装软件包,以避免污染计算机的其余部分。
poetry run YOUR_COMMAND
为了在虚拟环境中运行脚本,您必须运行poetry shell
进入虚拟环境,或者poetry run YOUR_COMMAND
。例如。要运行 Python 脚本,您应该执行 poetry run python your_python_script.py
如果您有一个包含以下 pyproject.toml
文件的文件夹:
[tool.poetry]
name = "test"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
python = "^3.6"
pycrate = {git = "https://github.com/P1sec/pycrate.git"}
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
运行poetry install
后,您可以通过运行poetry run SCRIPT_NAME
来访问所有pyrcrate脚本:
# works because pycrate_showmedia.py was installed with poetry install
me@computer:~/example-project$ poetry run poetry run pycrate_showmedia.py
usage: pycrate_showmedia.py [-h] [-bl BL] [-wt] input
pycrate_showmedia.py: error: the following arguments are required: input
如果您有一个导入 pycrate 库的 Python 文件,则还需要使用 poetry run
运行它:
me@computer:~/example-project$ cat test.py
import pycrate_core
print(pycrate_core.__version__)
me@computer:~/example-project$ poetry run python test.py
关于python - 使用 Poetry 自动从 Git 安装 Python 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59067263/
Poetry 有一个非常好的版本求解器,有时太好了 :) 我试图在一个使用两个不兼容包的项目中使用诗歌。然而,它们仅通过声明不兼容,因为其中之一不再开发,否则它们一起工作就好了。 使用 pip 我可以
我的问题: Python工具Poetry如何知道一个项目的虚拟环境的路径? 说明: 当我在目录中运行 poetry init 时,会创建一个新项目。然后我运行 poetry install 并创建一个
使用 Poetry,我想找到可用于安装的特定软件包的所有版本。有可能实现吗? (类似于 Python and pip, list all versions of a package that's av
我最近安装了 Pyenv 和 Poetry,想创建一个新的 Python 3.8 项目。我已经设置了 global和 local python 版本到 3.8.1使用适当的 Pyenv 命令(例如 p
将 [tool.poetry.extras] 部分添加到 pyproject.toml 后,Poetry 会显示以下警告,例如在安装时: Warning: The lock file is not u
如何升级到最新版本? 规范: Windows 10, Visual Studio 代码, Ubuntu Bash。 当前版本: me@PF2DCSXD:/mnt/c/Users/user/Docume
vscode-screenshot 我很确定一切都井然有序,但它在运行服务器或刷新服务器(通过保存 python 文件)时不断显示这首诗。请帮忙,这很烦人。 最佳答案 Python 之禅打印为 by
有一个简单但令人困惑的问题:当我尝试在模块中使用它时,我用 poetry 添加的包无法导入。采取的步骤: 诗歌添加sendgrid 在模块中,import sendgrid 错误: 导入“sendgr
vscode-screenshot 我很确定一切都井然有序,但它在运行服务器或刷新服务器(通过保存 python 文件)时不断显示这首诗。请帮忙,这很烦人。 最佳答案 Python 之禅打印为 by
有一个简单但令人困惑的问题:当我尝试在模块中使用它时,我用 poetry 添加的包无法导入。采取的步骤: 诗歌添加sendgrid 在模块中,import sendgrid 错误: 导入“sendgr
Poetry项目是 Python 的依赖管理系统。它使用新的 pyproject.toml文件作为其配置文件。 Poetry 工具支持几种不同的方式来指定您的依赖项的允许版本。 Poetry 依赖项的
我正在尝试为我的 poetry 环境安装 Jupyter 内核,但该内核似乎获得了我的基础 conda 环境。这是我正在尝试的: poetry env list >ENV_NAME-HASH-py3.
每当我尝试在 git 存储库中的 powershell 上运行 poetry install 时,我总是收到这个奇怪的错误,我真的不知道那可能是什么。我正在使用 Windows 10 和 Python
我喜欢初始化一个诗歌生成的项目,而无需通过交互式 shell 获取版本和依赖项等。 但是,尝试摆弄命令行选项的几次尝试都失败了。 比如 poetry init --name my_proj --des
我在 VSCode 中使用 Poetry,但在运行时遇到错误 import apache_beam as beam from apache_beam.options.pipeline_options
如果我想开发一个仅适用于 Linux 和 macOS 的 Python 包。如何在 Python Poetry 中指定此限制? 最佳答案 Trove classifiers pyproject.tom
Post-install script with Python setuptools 正是这个问题,但是使用 Poetry 而没有 Setuptools。 我想跑 print('Installatio
macOS Mojave 10.14.6Python 3.7.2 我像文档中那样安装了 python poetry: curl -sSL https://raw.githubusercontent.c
我正在开发一个 python 项目,它使用 pythonnet 和几个 C# dll 作为依赖项。 由于我不想将 dll 推送到 git 存储库,因此我调整了 .gitignore 文件。但是,现在
到目前为止,我一直使用 conda 作为虚拟环境和依赖项管理。但是,将我的 environment.yml 文件从我的开发机器传输到生产服务器时,有些东西无法按预期工作。现在,我想研究替代方案。诗歌看
我是一名优秀的程序员,十分优秀!