问题标签 [python-poetry]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
382 浏览

python - Cython 在诗歌 sdist tar.gz 中生成 c/cpp 文件,用于无 cython 安装

我使用 Poetry 来构建 tar.gz。和我的包裹的.whl。Cython 文档建议将 cython 生成的 c 文件与 pyx 文件一起分发。http://docs.cython.org/en/latest/src/userguide/source_files_and_compilation.html#distributing-cython-modules

我应该通过调用和添加什么build.pypyproject.toml生成 c/cpp 文件?poetry buildpoetry build -f sdist

我试过这个(来自Create package with cython so users can install it without cython already installed):

构建.py:

不适合我。

0 投票
2 回答
619 浏览

python - 诗歌 + Cython + 测试(Nosetests)

我使用 Poetry 来构建我的带有 cython 扩展的包。现在我想为它写测试(最好用nosetest)。问题是我需要预编译通常使用的二进制文件setup.py build_clib build_ext --inplace

对我来说最好的解决方案是运行测试而不像我已经拥有的那样在目录中创建额外的.py或文件。在虚拟环境中安装包后可以运行测试,就像在 readthedocs 服务器上实现一样。.shbuild.py

我也很熟悉taskipy,所以我的一些 bash 命令pyproject.toml也可以。欢迎使用任何其他软件包pyproject.toml

也许 Poetry 有任何钩子,因为它在创建.whl分发文件时 cythonizes 和 comiles。

对此的任何帮助将不胜感激。

UPD Tox 看起来像是合适的工具,但它pyproject.toml在目录中时看不到。非常欢迎在包或教程中链接到带有 tox 和 cython 的 repos。

0 投票
1 回答
1226 浏览

python - 如何使用系统安装包?

我正在尝试编写脚本,它应该使用 Portage API。但是 Portage python 包在 PyPi 中不可用,但即使它可用也没有任何意义,因为它应该从一些带有包数据库和配置的配置系统中使用。

我试图编写以下丑陋的代码:

但它不起作用。Poetry 不将路径目录中的代码视为 python 包。

有没有办法做到这一点并将系统用作运行测试的虚拟环境(我知道在主机系统中运行测试不是一个好主意,但是有一个安装了 Portage 的 docker 映像)?

0 投票
1 回答
4515 浏览

python - Poetry - force install when versions are incompatible?

Poetry has a very good version solver, too good sometimes :) I'm trying to use poetry in a project that uses two incompatible packages. However they are incompatible only by declaration as one of them is no longer developed, but otherwise they work together just fine.

With pip I'm able to install these in one environment (with an error printed) and it works. Poetry will declare that the dependencies versions can't be resolved and refuse to install anything.

Is there a way to force poetry to install these incompatible dependencies? Thank you!

0 投票
10 回答
54615 浏览

python - 诗歌将python版本更改为3.x

根据poetry的文档,设置新项目的正确方法是 with poetry new poetry-demo,但是这会通过创建以下 toml 文件来创建一个基于现已弃用的 python2.7 的项目:

如何将其更新到 3.7?运行时只需更改python = "^2.7"python = "^3.7"会导致以下错误poetry install

0 投票
4 回答
7584 浏览

python - 诗歌虚拟环境已激活

运行以下

返回以下错误

我怎样才能克服这个错误?为什么这个命令不起作用?

0 投票
1 回答
993 浏览

python - 使用 azure 管道和诗歌,有没有办法避免在每个脚本中采购 ~/.poetry/env?

我目前使用下面的脚本来构建我的包并将其发布到私有 Azure Artifacts 源。在每个脚本中,我都必须运行该行source $HOME/.poetry/env,否则它找不到诗歌命令。

有没有办法消除这种重复?

完整脚本:

0 投票
1 回答
752 浏览

python - 启动用诗歌开发的 Python 脚本

我已经使用 virtualenv 开发了很多实用程序,这些实用程序已经成为自己的包。但诗歌是热门的新事物,所以我想我会试一试。

创建一个新环境poetry new很容易,安装它的依赖项poetry install也很容易。

但是尝试从项目目录以外的目录实际启动我的脚本已被证明是一项挑战。我已将该[tools.poetry.scripts]部分添加到其 pyproject.toml 文件中,因此我可以通过调用从项目目录中启动它poetry run [args]。不过,这对于让其他人尝试我花哨的新脚本来说并不是太棒了。如果您想(或需要)从其他目录中运行,它是一个非首发。

那么,秘诀是什么?

0 投票
1 回答
501 浏览

python - 即使我安装了也没有名为 seaborn 的模块

我遇到了seaborn的问题。当我运行诗歌时,外壳说没有名为“seaborn”的模块,即使我通过 pip install seaborn 安装它:

当我检查导入作为这个问题时:如何在 Python 中导入 seaborn?(by python -c "import seaborn"),shell 运行大约 8 - 10 秒,但接下来什么也没有出现。

问题是什么?我应该怎么做才能修复它的错误?我是否正确安装 seaborn?我正在使用 Windows、git bash 作为 shell 和 Python 3.8.2。

在此处输入图像描述

0 投票
1 回答
3754 浏览

python - 使用 Python 包管理器 Poetry 时,我应该将哪些文件/目录添加到 .gitignore?

我正在使用一个名为Poetry的非常新的 Python 包管理器。

它会在创建新项目(环境)时创建多个文件/目录,但我不确定应该添加哪个以.gitignore获得最佳实践。

假设我通过这样做创建了一个新的诗歌项目:

有:

我通常添加tests/,foo_project/和因为它们似乎依赖于创建项目的机器poetry.lockREADME.rst此外,我似乎只能重现环境,pyproject.toml这是我忽略所有其他文件/目录的另一个原因。

然而,这只是我的直觉,不幸的是,我找不到任何官方指南,我真正应该.gitignore在官方文档中添加什么。

我不知道自己在做什么,这让我很烦恼。我应该添加哪些.gitignore