Minimal Python Package

Search for a command to run...

No comments yet. Be the first to comment.
I've slowly adding more and more lua functions into my neovim configuration, and recently I noticed a pattern for a class of functions that reach out to run shell commands that can be abstracted away. https://youtu.be/8m5ipBuopPU Telegraph.nvim Check...

Kedro can have a chatty logger. While this is super nice in production so see everything that happened during a pipeline run. This can be troublesome

In 2021 I changed the way I navigate between tmux sessions big time. Now I can create, kill, switch with ease, and generally keep work separated into
People who are quick to toss team members under a bus are not well trusted or highly thought of and it will lead to some toxic team dynamics. Building Steam While collaborating on any project there are going to be decisions made that aren't necessari...

I create this blog with one person in mind, me. There are others like me This is not completely selfish, as there are likely many others out there that think similarly to me. Everyone comes from different backgrounds and varying levels of experience...

cover: /static/minimal-python-package-xmas2020.png cover_image: https://waylonwalker.com//static/minimal-python-package.png published: true status: published tags:
What does it take to create an installable python package that can be hosted on pypi?
This post is somewhat inspired by the bottle framework, which is famously created as a single python module. Yes, a whole web framework is written in one file.
.
├── setup.py
└── my_pipeline.py
from setuptools import setup
setup(
name="",
version="0.1.0",
py_modules=["my_pipeline", ],
install_requires=["kedro"],
)
The name of the package can contain any letters, numbers, "_", or "-". Even if it's for internal/personal consumption only I usually check for discrepancy with pypi so that you don't run into conflicts.
Note that pypi treats "-" and "_" as the same thing, beware of name clashes
This is the version number of your package. Most packages follow
semver. At a high level its three numbers separated by a . that follow the format major.minor.patch. It's a common courtesy to only break APIs on major changes, new releases on minor, and fixes on patch. This can become much more blurry in practice so checkout semver.org.
Typically most packages use the packages argument combined with
find_packages, but for this minimal package, we are only creating one .py file.
from setuptools import setup, find_packages
setup(
name="",
version="0.1.0",
packages=find_packages(),
install_requires=["kedro"],
)
These are your external dependencies that come from pypi. They go in this list but are often pulled in from a file called requirements.txt. Other developers may look for this file and want to do a pip install -r
requirements.txt.
One thing to be careful of here is that everything sits at the top level API, when you users import your module and hit tab they are going to see a lot of stuff unless you hide all of your internal functions behind an _.
Can you create a python package with less than two files and less than 8 lines? Should you? I really like a minimal point to get started from for quick and simple prototypes. You can always pull a more complicated cookiecutter template later if the project is successful.