I am not very familiar with python, I only done automation with so I am a new with packages and everything.
I am creating an API with Flask, Gunicorn and Poetry.
I noticed that there is a version number inside the pyproject.toml and I would like to create a route /version which returns the version of my app.
My app structure look like this atm:
├── README.md
├── __init__.py
├── poetry.lock
├── pyproject.toml
├── tests
│ └── __init__.py
└── wsgi.py
Where wsgi.py
is my main file which run the app.
I saw peoples using importlib but I didn't find how to make it work as it is used with:
__version__ = importlib.metadata.version("__package__")
But I have no clue what this package mean.
__package__
there are suspicious things in your question. -- You should not have a__init__.py
right next topyproject.toml
, typically you would want to put all Python code in a sub-directory named after what you want your top-level import package to be. – Colombessrc
-layout, but you do not have to. It's best if you letpoetry
create the project template withpoetry new --src name-of-your-new-project
. – Colombes