pip packaging

PiP is a very good way of installing python nmodules - this is a quick guide for myself on how to do that.

Module army2

You develop a module - and test it....

class army2:
    def __init__(self,list_of_data):
        fields = list_of_data.split(",")
        self.id =fields[0]
        self.rank=fields[1]
        self.num=fields[2]

    def __repr__(self):
        return "We're in the Army2 Now"

def CheckF(x):
    #return str(x[0])+" "+type(x)
    return x[0]+" "+str(type(x))


if __name__ == "__main__":
        a=army2('1,"tim",345')
        print a

In order to a make it pipable you need to do

  • README.md
  • Setup.py
  • Manifest

Setup.py

import os

from setuptools import setup

def read(*paths):
    """Build a file path from *paths* and return the contents."""
    with open(os.path.join(*paths), 'r') as f:
        return f.read()

setup(
    name='army',
    version='0.1.0',
    description='Make a small army.',
    long_description=(read('README.md'),
    url='http://github.com/hynek/pem/',
    license='GNU',
    author='Tim Seed',
    author_email='tim@sy-edm.com',
    py_modules=['army2'],
    include_package_data=True,
    classifiers=[
        'Development Status :: 5 - Production/Stable',
        'Intended Audience :: Developers',
        'Natural Language :: English',
        'Operating System :: OS Independent',
        'Programming Language :: Python',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 2.6',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.3',
        'Topic :: Software Development :: Libraries :: Python Modules',
    ],
)