如何正确更改用诗歌构建的包装名称?

发布于 2025-02-01 03:12:22 字数 1425 浏览 5 评论 0原文

我使用诗歌软件包管理器构建了一个软件包,但我很遗憾地命名它,因为它听起来有点幼稚。

此外,由于诗歌的默认行为是强制将项目的名称更改为较低的情况(superpackage - > superpackage),这是很难在软件包的主目录内部/外部导入软件包。

这是一个示例目录结构:

SuperPackage/
    - superpackage/
    - mysubpackage/
        - __init__.py
        - utils.py
        - foo.py
    - tests/
        - __init__.py
        - test_superpackage.py
    - poetry.lock
    - pyproject.toml
    - README.md
    - README.rst
    - .gitignore

由于此结构,

from SuperPackage.mysubpackage import utils # Works outside SuperPackage/ directory. Doesn't work inside SuperPackage/.
from superpackage.mysubpackage import utils # Works inside SuperPackage/. Doesn't work outside SuperPackage/ directory.

现在,我想将superpakage更改为nicepackage

我该如何实现?我无法谷歌搜索它,也许是因为它很少见,或者太明显了。我应该只更改“ name” pyproject.toml文件中的字段?

但是,我不确定是否可以直接更改“ name”字段。

[tool.poetry]
name = "SuperPackage"
version = "0.1.0"
description = ""
authors = ["John-Doe <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.8"
pandas = "^1.3.4"
matplotlib = "^3.4.3"
beautifulsoup4 = "^4.10.0"

I built a package using poetry package manager but I regret naming it because it sounds a bit childish.

Besides, because poetry's default behavior is to force change the project's name to lower case (SuperPackage --> superpackage), it is difficult to import the package inside/outside the package's main directory.

Here's an example directory structure:

SuperPackage/
    - superpackage/
    - mysubpackage/
        - __init__.py
        - utils.py
        - foo.py
    - tests/
        - __init__.py
        - test_superpackage.py
    - poetry.lock
    - pyproject.toml
    - README.md
    - README.rst
    - .gitignore

Because of this structure,

from SuperPackage.mysubpackage import utils # Works outside SuperPackage/ directory. Doesn't work inside SuperPackage/.
from superpackage.mysubpackage import utils # Works inside SuperPackage/. Doesn't work outside SuperPackage/ directory.

Now, I want to change SuperPackage to nicepackage.

How do I achieve this? I can't google it maybe because it's very uncommon or it's too obvious. Should I just change "name" field in pyproject.toml file?

However, I'm not sure if it's okay (and recommended) to change "name" field directly.

[tool.poetry]
name = "SuperPackage"
version = "0.1.0"
description = ""
authors = ["John-Doe <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.8"
pandas = "^1.3.4"
matplotlib = "^3.4.3"
beautifulsoup4 = "^4.10.0"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生生漫 2025-02-08 03:12:22

更改pyproject.toml中的名称字段,运行诗歌更新(不确定这是需要的,但以防万一?)并更改目录名称。

请注意,计算机上虚拟环境的名称将保持不变,但这可能不是一个问题,因为它只是本地ting。

Change the name field in pyproject.toml, run poetry update (not sure that's needed but do it just in case?) and change the directories names.

Note that the name of the virtual environment on your computer will stay the same, but that probably isn't a problem as it only is a local ting.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文