Skip to content
Greg Flynn edited this page Nov 7, 2019 · 12 revisions

Setup.py

This is a basic setup.py file for making a package pip installable

from setuptools import setup

setup(
    name="PackageName",
    version="1.2.3a1",
    description="What is the package",
    author="Greg Flynn",
    author_email="gregf36665@gmail.com",
    packages=['Directory']
)

Specify git repos as a requirement (And call out version)

setup(
    ...
    install_requires = ['LogHandlerUtilities @ git+ssh://git@github.com/Lakenheath/LogHandlerUtilities.git@2.0.1']
)

Note this uses ssh. See SSH for tips and tricks to make life easier

script vs package

In a setup.py file both packages and scripts can be specified

setup(
    packages=['foo', 'bar'],
    scripts=['spam.py']
)

If a script is selected then it can be run from the command line or treated as a package

Optional build methods

If there are packages that only want to be installed in the case of certain images being used then use the following:

# mypackage/setup.py
extras = {
   'with_simplejson': ['simplejson>=3.5.3']
}
setup(
    ...
    extras_require=extras,
    ...)

To install the 2 different modes

pip install mypackage
pip install mypackage[with_simplejson]

look into python setup.py build python setup.py install

Requirements.txt

todo

Clone this wiki locally