When you use the poetry new command, Poetry creates a new Python package with a specific directory structure and naming conventions. The command poetry new oka-semantic creates a new package named oka-semantic but with a few important conventions:
-
Kebab-case to Snake-case Conversion:
- Poetry converts the kebab-case (
oka-semantic) to snake-case (oka_semantic) for the package name within the created directory. This is because Python package names typically use snake_case.
-
Directory Structure:
- The directory
oka-semantic will contain the package oka_semantic (in snake_case) along with other files like pyproject.toml, README.rst, and a tests directory.
Here’s a breakdown of what happens when you run poetry new oka-semantic:
Directory Structure
oka-semantic/ # Directory created by Poetry
├── oka_semantic/ # Package directory (note the snake_case)
│ ├── __init__.py
└── tests/ # Tests directory
├── pyproject.toml # Poetry configuration file
├── README.rst # README file
└── ...
Why This Happens
Example
poetry new oka-semantic
This will create:
oka-semantic/
├── oka_semantic/
│ ├── __init__.py
├── tests/
├── pyproject.toml
├── README.rst
└── ...
Navigating the Created Structure
Summary
oka-semantic: This is the directory name created by Poetry.
oka_semantic: This is the actual Python package name inside that directory, following Python’s naming conventions.
This design allows Poetry to bridge the gap between different naming conventions while ensuring that the resulting package adheres to Python standards.