Speaker

Mark Smith

Material

Note

Basic Usage

  • minimal setup.py
from setuptools import setup

setup(
    name="helloworld",
    version="0.0.1",
    description="Say hello!",
    py_modules=["helloworld"],
    package_dir={'': 'src'},
)
  • build wheel
python setup.py bdist_wheel
  • test installation locally
    • Links to the code instead of add it to site-packages
pip install -e .

Documentation

  • Compare ReStructured Text and markdown
ReStructured Text Markdown
Pythonic More Widespread
Powerful Simply
Sphinx mkdocs
  • keys added to setup.py
    • classifiers
    • long_description
    • long_description_content_type="text/markdown"

Dependencies

install_required extras_require
production dependencies optional requirements
relaxed versions (users can install without conflicts with other packages) specific versions (developers can have identical develop environment)
  • keys added to setup.py
    • install_requires
    • extras_require
      • dev
  • install package with extras_require
pip install -e .[dev]

Source Distribution

python setup.py sdist
  • keys added to setup.py
    • url
    • author
    • author_email
  • Ideally, everything should be included for source distribution

Publish

python setup.py bdist_wheel sdist
twine upload dist/*

Other Stuffs to add

  • Must Do
    • tox
    • Continuous Integration
  • Nice to have
    • badges
      • code coverage
      • quality metrics
    • test on macOS & windows
    • more document
      • contributors section
      • Code of Conduct

Don't do any thing mention above

Things are changing

  • move metadata from setup.py to setup.cfg
  • move to pyprojec.toml

Share on: TwitterFacebookEmail


Published

Category

EuroPython 2019

Tags

Contact