Why Python Packages?


  • To make Python code installable, reusable and distributable via PyPI or TestPyPI, one must package the code.
  • The Package should have modules and init.py file.
  • The code must be versioned.
  • Project dependencies must be managed.
  • The project’s metadata must be clearly defined.

Why choose Pixi for Python Packaging ?


  • Choose a tool with good support and long term vision.
  • Choose a tool suitable for your project.
  • Focus on PEP specifications and recomendations.

Set up a project directory


  • Follow the appropriate folder structure.
  • Always include the __init__.py file in packages.
  • Sequence of Pixi commands: initaddrunlockinstallupdate.
  • Define / check [project], [dependencies] and [tasks] in your pyproject.toml file .

Metadata for Python packging


How to publish your Python project


  • Ensure all metadata is filled in and choose a unique project name.
  • Use build to generate distribution files
  • Create a TestPyPI account and generate an API token
  • Use twine upload to securely publish your package.
  • Test your package by installing it from TestPyPI via pip install.

Extra


  • Define tasks such as start in your pixi.toml or pyproject.toml.
  • Use pixi run <task-name> to execute those tasks.
  • pixi run start ensures consistency and reproducibility when launching a project.