Tested on:Raspberry Pi 2; Raspberry Pi B+; Python 2.7; Raspbian pre Jessie
Prerequisites:Raspberry Pi with Raspbian Jessie and internet connection (see steps 1-7 in the Introduction)
0

Creating own python packages with setup.py

Python modules are great for reusing and sharing code. Also, they’re good for structuring an application and increasing maintainability.

First, download the sample project onto your Raspberry Pi with

Create the Package
Now, you can build a tarball of the sample package. Open setup.py in the terminal with sudo nano setup.py and change the version number to '0.0.1' in the line

Then, type in the terminal

This creates a zipped tar.gz package from the project which is ready to be shared on the Python Package repository PyPi.
Typing ls dist shows you the new myproject-0.0.1.tar.gz tarball.

Install the Package

Test the installation
The package is installed system-wide now. Open Python, import and test it with

If all went well, this displays
Covered by test framework.

Find plenty of information on Python Packages in this great article from Tarek Ziadé.

Links
Test-driven project setup: http://www.knight-of-pi.org/python-project-setup-test-driven-development/
Tarek Ziadé - Python packages: http://zetcode.com/articles/packageinpython/

Knight of Pi

Johannes Bergs aka Knight of Pi. Diploma in Bioinformatics, some Webdesign and Python coding then. Living in the beautiful city of Vienna.

Comment

Time limit is exhausted. Please reload CAPTCHA.