如何正确更改用诗歌构建的包装名称?
我使用诗歌
软件包管理器构建了一个软件包,但我很遗憾地命名它,因为它听起来有点幼稚。
此外,由于诗歌
的默认行为是强制将项目的名称更改为较低的情况(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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更改
pyproject.toml
中的名称字段,运行诗歌更新
(不确定这是需要的,但以防万一?)并更改目录名称。请注意,计算机上虚拟环境的名称将保持不变,但这可能不是一个问题,因为它只是本地ting。
Change the name field in
pyproject.toml
, runpoetry 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.