how to create a python module.
python modules are collections of functions, that live on a single .py file, and can be imported in other python scripts, using import.
your module should live on one .py file. i suggest using github to have a verson control system and online backup.
create a setup.py file, that includes:
to distribute, do on terminal
python setup.py sdist
twine upload dist/name-x.y.z.tar.gz
installing python modules
first, install pip and virtualenv globally on your machine.
when you want to use python on your software project, we will create a virtual environment where all the python dependencies will live. go to your terminal and create a virtualenv with the command-line-tool virtualenv.
in this example, we will call env our virtual environment
to make the python interpreter aware of this virtual environment, we have to activate it
your terminal should now say (env) at the beginning of each new line. this means that the environment is activated.
to install packages on this virtual environment, use pip install.
in this example we will be installing numpy
pip install numpy
when you want to quit the virtual environment, deactivate it
- functions and modules: notes by allison parrish.
- installing python libraries: notes by allison parrish.
- submitting packages to the package index: notes on how to submit packages to the python package index.
- packaging python libraries
- packaging and distributing projects