Unfortunately, python packaging has a complicated history, and new tools are still emerging. My understanding is that the current "gold standard" is to use setup_tools
to define a setup.py
file. This file will allow others to install your project's source code using pip. If you want to be able to install with pip without explicitly downloading the source first, you will need to publish your project to pypi using python setup.py upload
.
Below is the setup.py
boilerplate I use as a starting point:
#!/usr/bin/env python
""" boilerplate for new project setup.py """
from setuptools import setup
import io
import projectname
def read(*filenames, **kwargs):
encoding = kwargs.get('encoding', 'utf-8')
sep = kwargs.get('sep', '\n')
buf = []
for filename in filenames:
with io.open(filename, encoding=encoding) as f:
buf.append(f.read())
return sep.join(buf)
long_description = read('README.md') #, 'CHANGES.txt')
setup(name='projectname',
version=projectname.__version__,
description='short desc of projectname',
long_description=long_description,
author='Tylar Murray',
author_email='code+projectname@tylar.info',
url='https://github.com/7yl4r/projectname',
tests_require=['nose'],
install_requires=[
'networkx' # or whatever
],
#cmdclass={'test': PyTest},
packages=['projectname', 'OtherProjectProvidedPackage2']
)
NOTE: this template requires you to have a README.md
and something like __version__="0.1.23"
in your top-level __init__.py
Regarding your P.S. question: Technically you should open a new question for this but in short the answer is you should include both as covered here and in this answer particularly.