Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pack and distribute python program (.py source code) so that other developers can easily install all required dependencies?

I'm developing a Python application built with some packages I've installed with pip such as Flask, requests, PIL.

So how can I distribute my program so that other people can easily install every required dependency/package and simply make it work on every computer? Is setup.py what I'm looking for or not at all? If so, could you please explain what it does and provide an example setup.py that does what I'm trying to do?

PS: I've also got this little question: do I need to provide a __init__.py in the top level folder of my program or just in subdirectories?

like image 971
Elia Perantoni Avatar asked Apr 23 '26 04:04

Elia Perantoni


1 Answers

In the not so old days I used this guide to learn how to package and distribute my python code, then some good people created flit which allows me to do the whole process in three steps.

$pip install flit

Create my metadata file:

[metadata]
author=Some guy
[email protected]
home-page=https://github.com/someuser/somepackage
requires=requests
requires-python= >=3
description-file=README.rst
classifiers=Intended Audience :: Developers
    License :: OSI Approved :: BSD License
    Programming Language :: Python :: 3
    Topic :: Software Development :: Libraries :: Python Modules

Publish my package:

$pip flit publish

And done!!!

like image 164
yorodm Avatar answered Apr 25 '26 17:04

yorodm