-
Notifications
You must be signed in to change notification settings - Fork 0
Pip
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']
)setup(
...
install_requires = ['SomeRepo @ git+ssh://git@github.com/gregf36665/SomeRepo.git@1.2.3',
'AnotherRepo @ git+ssh://Server:port/home/gregf/anotherRepo.git@4.5.6',
'ThirdRepo @ git+ssh://server/home/path/thirdRepo.git@7.8.9'
]
)Note this uses ssh. See SSH for tips and tricks to make life easier
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
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/myPackage@1.2.3#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/myPackage@1.2.3#egg=myPackage[with_simplejson]',
]
...
)
Note that the egg name comes from the name line in setup(...)
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="gregf36665@gmail.com",
description="Breakfast module",
version="1.0.0",
install_requires = ["Plate", "Fork>=2.3.1"],
packages=["spam", "spam.meat", "foo"],
include_package_data=TrueMANIFEST.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
look into python setup.py build python setup.py install
todo