Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

My first PiP

Project description


Ignore this package ! It is simple showing progress of learning developing reusable python modules

Steps to create your own PIP Module

Each file extended by .py becomes a python module as follows:

def myMethod():
    msg = "Hello PiP"
    print ("MSG: {}".format(msg))
    return msg
myVariable = 123

If you want to use your file as a module you simple have to import it:

import myModule

Also possible:

from myModule import myMethod, myVariable
print ("myVariable: {}".format(myVariable))

#Share your PiP To share your module as a PIP Package everyone can install by pip install yourPackageNamerequires a bit more structure. After registering on (and the Test Space accont!) install an utility for publishing Python packages on PyPi:

pip install twine

Create a directory structure as follows and add plain files as shown:


Within the you can add python code to be executed while importing the module. The requires a fixed structure you can copy and past here for customizing your needs:

import setuptools
with open("", "r") as fh:
    long_description =
    author="Daniel Bunzendahl",
    description="My first PiP",
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",

Note: You have to create a new Git Repository here and copy the URL

To generate the wheel for native compilations and tar.gz for python module - just do:

cd myFirstPiPy
python sdist bdist_wheel



Testdrive and Upload

First we test how a submission would look like:

twine upload --skip-existing --repository-url dist/* 

If the result looks good for you it is time to run

twine upload dist/*

Which will publish your first PiP Package.

Note: If you like to change files on Pypi, you need to change the version in It is not possible to delete the project and reupload your local version (security reason!!)


Now we like to go more professional and add unittests. So we add a directory where to add tests in multiple files.


All this files are executed by the command python -m unittest discover -s ./tests -p "test_*"

Writing Tests

Tests are Classes which subclasses unittest.TestCase. Each Method named test* within such a class will be run. The following example shows how or could look like merged within one file.

import unittest
import myModule
class TestMyMethod(unittest.TestCase):
    def test_myMethod(self):
        self.assertEqual(myModule.myMethod(), "Hello PiP")
    def test_myVariable(self):
        self.assertIs(myModule.myVariable, 123)
if __name__ == '__main__':

#Continuous Integration (CI) A very interesting solution is Travis which runs tests on Github. To enable Travis CI you need a .travis.yml after generating a requirements.txtfrom your virtualenv. ##Virtual Environment First we need a virtual environment with only pip packages installed are realy neccessary. Based on this the generating of the requirements.txt is created.

cd .. # below ./myFirstPiP
virtualenv myFirstModuleDependencies
source myFirstModuleDependencies/bin/activate
cd myFirstPiP

Install required packages and generate the requirements.txt

pip freeze > requirements.txt

##Travis Now we can write the .travis.yml as follows:

language: python
  - "2.7"
  - "3.3"
  - "3.4"
  - "3.5"
  - "3.5-dev"  # 3.5 development branch
  - "3.6"
  - "3.6-dev"  # 3.6 development branch
  - "3.7-dev"  # 3.7 development branch
# command to install dependencies
  - pip install -r requirements.txt
# command to run tests
  - python -m unittest discover -s ./tests -p "test_*"


cd ..
git pull
git add .
git commit -m "Travis CI Testdrive"
git push origin master

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
myFirstPiPy-0.0.3-py3-none-any.whl (3.7 kB) Copy SHA256 hash SHA256 Wheel py3
myFirstPiPy-0.0.3.tar.gz (3.4 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page