A poetry python test projet
Project description
Poetry Test
In this proeject, I will be testing the poetry package manager for python.
Currently the project is capable of downloading a random image via running poetry_test or download_img
How to Poetry
--> https://python-poetry.org/docs/#installation
Installing Poetry
Install it via pipx install poetry.
pipx installs packages semi globally, very weird...
Setup a poetry project directory
- Make poetry create a
.venvdir for you in every project that uses poetry ->poetry config virtualenvs.in-project true(this is a global setting) - Run
poetry initin your project dir - Add dependencies with
poetry add <module_name>or during the init process - Run
poetry installto install your dependencies. - Change the python version of your venv to the same as your poetry project via:
->
poetry env use /path/to/python3.11 - Activate your new venv via
poetry shelland DO NOTsource .venv/bin/activate
Local Packaging
- Build the package via
poetry build - Install the wheel locally:
pip install dist/your_project.whl
To actually being able to run your python program, you must include this line in your pyproject.toml:
[tool.poetry.scripts]
your_command_name = "your_project_name.main:main"
Explanation:
- your_command_name = the command you will run to start your project. Should be same as project name if you only have one.
- your_project_name = the name of the dir in the src/ folder where your project code is
- .main = the name of the file you want to execute
- :main = the name of the function in the file you want to execute
- You can actually have multiple commands here
Publishing your package to pypi
- Run:
poetry config pypi-token.pypi <YOUR_PYPI_TOKEN>- This command stores the API token directly in Poetry's configuration.
I don't know where since I could not read it via
poetry config --list.
- This command stores the API token directly in Poetry's configuration.
I don't know where since I could not read it via
- Build and Publish via:
poetry publish --build
Publishing to a custom repo (untested):
- Run
poetry config pypi-token.<repository_name> <YOUR_REPOSITORY_TOKEN> - in your pyproject.toml add:
[tool.poetry.repositories.<repository_name>]
url = "https://example.com/my-private-repo"
- Build and Publish:
poetry publish --build -r my-private-repo
Example File Structure
simple poetry example file structure:
poetry-test/
├── pyproject.toml
├── README.md
├── src/
│ └── poetry_test/
│ ├── __init__.py
│ └── main.py
└── tests/
└── test_example.py
advanced poetry example file structure:
poetry-test/
├── pyproject.toml # Poetry configuration file
├── README.md # (Optional) Project description and instructions
├── src/ # Main source directory
│ ├── poetry_test/ # Main package directory ( match project name)
│ │ ├── __init__.py # Initializes the package
│ │ ├── main.py # Main module or core logic of the package
│ │ ├── utils/ # Utility funcs or helper modules for reusable code
│ │ │ └── helpers.py # Example helper function file
│ │ ├── config/ # Configuration files or settings for the project
│ │ │ └── settings.py # Example settings or configuration file
│ │ └── modules/ # Sub-packages, useful for organizing projects
│ │ ├── module_a.py # Example module for a specific feature or function
│ │ └── module_b.py # Another example module
│ ├── scripts/ # Standalone scripts
│ │ └── data_processor.py # Example standalone script for data processing
│ └── data/ # Data files used by the project
│ └── sample_data.csv # Example data file used by scripts or tests
└── tests/ # Directory for test files
└── test_example.py # Example test file for unit or integration tests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file poetry_test_project_for_me-0.3.0.tar.gz.
File metadata
- Download URL: poetry_test_project_for_me-0.3.0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.11.10 Linux/5.15.154+
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49b52dbb1b9f517707f0dc130c52b08a0dd48145d9517e50cbfb4a3527720b6f
|
|
| MD5 |
a4cdf346160a3f04e25a8999be5ebbaf
|
|
| BLAKE2b-256 |
9d48c64f3dc21987ae51c78643059eac9447cbb9f3798db4d90bd7e1eddd4e5e
|
File details
Details for the file poetry_test_project_for_me-0.3.0-py3-none-any.whl.
File metadata
- Download URL: poetry_test_project_for_me-0.3.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.11.10 Linux/5.15.154+
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84e6cec6e1a8207ad32c9a40759fb55f00c33f4af1e7947a6640b41fdd74326f
|
|
| MD5 |
88a901fd475153e9b26209ab78035057
|
|
| BLAKE2b-256 |
5f0631fb43a22d3e6207e29db017c83dd7d1ac16e17177b2c7fc94aa77f235ef
|