Python/pip

pip
pip - installs packages. Python packages. An easy_install replacement

pip 1.1 : Python Package Index - http://pypi.python.org/pypi/pip

Usage: pip help pip install [package]  # Example: 'pip install test' pip -v --upgrade install [package]  # force upgrade pip uninstall [package] pip search [package] pip freeze             # list all currently installed pip packages pip list               # also list all packages pip show [installed_package]     # minimal info about installed package

PIP Source Code: http://pypi.python.org/packages/source/p/pip/

Package Destination: /usr/lib/python2.4/site-packages/

Test package example:
 * Package Page: http://pypi.python.org/pypi/test
 * Package Source Code: http://pypi.python.org/packages/source/t/test/test-2.3.4.5.tar.gz
 * Package Destination: /usr/lib/python2.4/site-packages/test-2.3.4.5-py2.4.egg-info/

Installation
Installing the Package Tools — The Hitchhiker's Guide to Packaging v1.0 documentation - http://guide.python-distribute.org/installation.html
 * Pip Installs Python (Pip)
 * Pip is an installer for Python packages written by Ian Bicking. It can install packages, list installed packages, upgrade packages and uninstall packages. The pip application is a replacement for easy_install. It uses mostly the same techniques for finding packages, so packages that were made easy_installable should be pip-installable as well.

Dependency Installation: VER=2.0 mkdir -p ~/.src ; cd ~/.src wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-$VER.tar.gz tar -zvxf setuptools-$VER.tar.gz cd setuptools-$VER sudo python setup.py install
 * 1) dependency setuptools
 * 2) Python Package Index : setuptools 0.6c11 - http://pypi.python.org/pypi/setuptools
 * 3) source code: http://pypi.python.org/packages/source/s/setuptools/
 * 4) VER=1.1.6

yum install python-setuptools
 * 1) yum method, if available

Easy Install: sudo easy_install pip

Windows: C:\python27\scripts\easy_install.exe pip

Apt: sudo apt-get install python-setuptools sudo easy_install pip

Manual Installation: PIP_VER=1.4.1 mkdir -p ~/.src ; cd ~/.src wget http://pypi.python.org/packages/source/p/pip/pip-$PIP_VER.tar.gz tar -zvxf pip-$PIP_VER.tar.gz cd pip-$PIP_VER sudo python setup.py install
 * 1) Python Package Index : pip 1.0.1 - http://pypi.python.org/pypi/pip#downloads

sudo sed -i 's%#!/usr/bin/python%#!/usr/bin/env python%' /opt/python26/bin/pip
 * 1) fix pip:

NOTE: Most packages failed during installation. The simple 'test' package installed though.

Packages are generally installed into: /usr/local/lib/python2.7/dist-packages/

Create PIP Package
setup.py: from distutils.core import setup

setup(   name='kentest',    version='0.1.0',    author='Kenneth Burgener',    author_email='kenneth@oeey.com',    packages=['kentest'],    url='http://pypi.python.org/pypi/kentest/',    license='LICENSE.txt',    description='kentest.',    long_description=open('README.txt').read, )

Create distribution package: python setup.py sdist
 * 1) output to: dist/[PROJECT]-[VERSION].tar.gz

Test install: sudo pip install dist/[PROJECT]-[VERSION].tar.gz

Remove Test install: sudo pip uninstall [PROJECT]

Configure PyPI settings: python setup.py register
 * 1) ~/.pypirc

Upload project: python setup.py sdist upload

Install project: pip install kentest

---

Sections:

Scripts: scripts=['bin/mytool']

Data files: ("*" doesn't appear to work) data_files=[('bitmaps', ['bm/b1.gif', 'bm/b2.gif']), ('config', ['cfg/data.cfg']), ('/etc/init.d', ['init-script'])]

Package files: packages=['mypkg'], package_dir={'mypkg': 'src/mypkg'}, package_data={'mypkg': ['data/*.dat']},

References:
 * The Python Package Index (PyPI) — Python documentation - https://docs.python.org/2/distutils/packageindex.html
 * Writing the Setup Script — Python documentation - https://docs.python.org/2/distutils/setupscript.html
 * Creating a Package — The Hitchhiker's Guide to Packaging 1.0 documentation - http://guide.python-distribute.org/creation.html

---

reStructuredText

PyPI uses reStructuredText instead of Markdown (shame!)

Install pypandoc: yum install pandoc pip install pypandoc

To have setup.py auto convert it, install pandoc and add the following: from setuptools import setup try: from pypandoc import convert read_md = lambda f: convert(f, 'rst') except ImportError: print("warning: pypandoc module not found, could not convert Markdown to RST") read_md = lambda f: open(f, 'r').read

setup(   # name, version, ...    long_description=read_md('README.md'),    install_requires=[] )


 * This will automatically convert README.md to RST for the long description using on PyPi. When pypandoc is not available, then it just reads README.md without the conversion – to not force others to install pypandoc when they wanna just build the module, not upload to PyPi.


 * So you can write in Markdown as usual and don’t care about RST mess anymore. :-)

rst test tool: http://rst.ninjs.org/

References:
 * http://stackoverflow.com/questions/10718767/have-the-same-readme-both-in-markdown-and-restructuredtext