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 <johndoe@gmail.com>"]
[tool.poetry.dependencies]
python = "^3.8"
pandas = "^1.3.4"
matplotlib = "^3.4.3"
beautifulsoup4 = "^4.10.0"
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.