Creating Python Packages


As an Individual developer or a member of team you we end up writing code which can be re-used. Packages are great way to share these functions and classes. Maintainability is another reason we need to use packages.


Following steps are laid out assuming you’re trying to create a`spam` package. To create a package you need to, create:

  1. containing package notes

  2. which contains package information

  3. package {E.g. spam} this is a package directory within project directory. Ensure
    1. Same name also appears for name field in

    2. file exists in spam directory {i.e. you package directory}

    3. Have all your python code within this package directory

  4. Create package using python sdist bdist_wheel, this will create
    1. sdist will create source distribution

    2. bdist_wheel will create binary distribution

  5. To install package you can use wheel file pip install ../spam/dist/spam-0.0.1-py3-none-any.whl

Once you do this, following is what your directory structure would look like:


Reference: From a python project to an open source package: an A to Z guide