Pip - Gregf36665/sys_setup GitHub Wiki
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="[email protected]",
packages=['Directory']
)
Specify git repos as a requirement (And call out version)
setup(
...
install_requires = ['SomeRepo @ git+ssh://[email protected]/gregf36665/[email protected]',
'AnotherRepo @ git+ssh://Server:port/home/gregf/[email protected]',
'ThirdRepo @ git+ssh://server/home/path/[email protected]'
]
)
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(
name="myPackage"
...
extras_require=extras,
...)
Be careful with the spelling of extras_require. Pip and setuptools will not report any issue if the wrong word is plural.
To install the 2 different modes
pip install mypackage
pip install mypackage[with_simplejson]
pip install git+ssh://github.com/gregf36665/[email protected]#egg=myPackage[with_simplejson]
To have a package that requires an extra use the following:
# This isn't working yet
setup(
...
install_requires=[
'myPackage @ git+ssh://github.com/gregf36665/[email protected]#egg=myPackage[with_simplejson]',
]
...
)
Note that the egg name comes from the name line in setup(...)
Add non python files
Assume the following file structure
/food
- setup.py
- MANIFEST.in
- spam
- eggs.dat
- ham.sql
- meat
- beef.txt
- chicken.txt
- foo
- bar.py
- __init__.py
setup.py should contain the following info:
from setuptools import setup
setup(
name="Food",
author="Greg",
author_email="[email protected]",
description="Breakfast module",
version="1.0.0",
install_requires = ["Plate", "Fork>=2.3.1"],
packages=["spam", "spam.meat", "foo"],
include_package_data=True
MANIFEST.in should contain the following
include spam/eggs.dat
include spam/ham.sql
include spam/meat/*.txt
Note that MANIFEST.in and setup.py are at the same level. See the documentation for more info
Future parts
look into python setup.py build python setup.py install
Requirements.txt
todo