Python Cheat Sheet

From EWIKI
Jump to navigation Jump to search

ref also Python wiki page.

Virtual Python Environment

Create virtual environment

virtualenv ~/folder/

Start virtual environment:

source bin/activate

Stop virtual environment:

deactivate

Python Packages

Run package test:

python setup.py test

Create Egg info:

python setup.py egg_info

Create a wheel

pip install wheel
python setup.py bdist_wheel

Check valid RST description

python setup.py --long-description | rst2html.py > output.html

Package download statistics (most time broken)

pip install vanity
vanity PACKAGENAME

Twine: secure package registration/upload

ref https://github.com/pypa/twine

pip install twine
twine register -u USER -p PWD dist/PACKAGE.tar.gz
twine register dist/* 
twine upload dist/*