Lightning talk given at VTCode Meetup describing how to use setup tools and some of the fields within setup.py. Includes a brief discussion of the various packaging formats (sdist, bdist eggs, and wheels).
2. Intro
• Example setup.py
• setuptools allows you to describe your package, how to install it, and
how to use it.
• Topics
• Misc package metadata
• Modules and imports
• Resources
• Dependencies
• Package formats
6. Dependencies
• distutils -> setuptools
• Although distutils specified metatada about your package, did not include
dependencies of your package.
• Setuptools added dependencies and introduced easy_install, a way to install
your package + your package’s dependencies.
• easy_install has since been replaced by pip.
// Before call to setup in setup.py: tests_require=['nose==1.3.7']
install_requires=['numpy>=1.11.0,<2.0.0']
tests_require=tests_require
extras_require={'tests': tests_require,
'docs': ['Sphinx==1.6.3', 'docutils==0.14']}
7. Package formats
• sdist (source): includes .py files and setup.py itself, any other source (.c, .f* etc), and resources.
• Always universal. Good luck compiling C, Fortran, etc. yourself.
• bdist egg (built): includes .pyc files, any other compiled lib files (.dll, .o, etc), and resources.
• Always architecture and Python version specific. Package creators make for you. Frequently unavailable
and unsupported by pip.
• wheel (source when possible, built when needed): the new standard
• ‘Universal’ wheels are just python source and resources (no .pyc, no setup.py). Must be pure python
(+resources that don’t need to be compiled) with limited conditional dependencies.
• python setup.py bdist_wheel auto-detects if package is not pure Python and produces built wheels for
your architecture and Python version. Likely cannot auto-detect if complex conditional dependencies.
Pre-built wheels for different architectures and python versions are often available
on PyPi when they’re needed.