Packaging and Sharing a Python Project
Turn your AI scripts into an installable package with clear dependencies, versions and a command line tool.
A taste of a lesson
My tool works in the repo, but after pip install it cannot find prompts/classify.txt.
Two things are probably happening. First, the prompt file may not be included in the built package at all; declare it as package data so the build copies it in. Second, your code likely opens it with a path relative to the current directory, which only works inside the repo. Read it through importlib.resources instead, which finds files inside the installed package wherever it lives. After both changes, build, install in a fresh environment and run the command. How does your code open the file now?
Written by the teacher as an example. In your lesson the tutor answers your own questions, and like any AI it can be wrong.
What you will be able to do
- Describe a project fully in pyproject.toml
- Declare dependencies correctly for libraries versus applications
- Build, install and develop a package with an editable install
- Add a command line entry point and bundled data files
- Version and share a package through git, a private index or the public index
Lesson plan
- 1 What a package is and when you need one Decide whether your code should be a package and what kind. Start
- 2 pyproject.toml section by section Write the build system and project sections and understand each field. Start
- 3 Build, install and develop Build a wheel, install it in a clean environment and develop with an editable install. Start
- 4 Commands and data files Expose a command line tool and ship prompt templates inside the package. Start
- 5 Dependencies and versions Choose dependency ranges and version numbers that others can rely on. Start
- 6 Sharing responsibly Publish to the right place after checking licences, secrets and names. Start
Try asking
About this tutor
For developers who want colleagues to install and run their AI tool without a page of setup instructions, or who want to reuse their own code across projects. You learn how a modern pyproject.toml describes a project, how dependencies should be declared differently for libraries and applications, how to build and install a package (including editable installs while developing), how to add a command line entry point, include data files such as prompt templates, and choose versions. The tutor keeps to concepts shared by current packaging tools and explains where those tools differ.
Reviews
Students can review a tutor after a paid lesson. Nobody has yet.
About the teacher
Numerical Python and code quality for data and AI projects that have outgrown a single notebook
9 tutors 374 lessons taught Sample
I work on the part of AI projects nobody photographs: the arrays, dataframes, tests and packaging that let a prototype survive contact with real data. I came to this through scientific computing and later backend work, so I care about two things at once, getting the numbers right and keeping the code readable for the next person. My lessons are...
See Felix's profile and tutorsMore like this
Other tutors on the same or nearby topics.