$30 off During Our Annual Pro Sale. View Details »

Maintaining a Python Project When It’s Not Your Job

Maintaining a Python Project When It’s Not Your Job

PyPI is a gold mine of great packages but those packages have to be written first. More often than not, projects that millions of people depend on are written and maintained by only one person. If you’re unlucky, that person is you! This talk tries to lighten the burden by giving you useful tools and approaches.

Hynek Schlawack

May 03, 2019
Tweet

More Decks by Hynek Schlawack

Other Decks in Programming

Transcript

  1. Maintaining a Python Project
    When It’s Not Your Job
    Hynek Schlawack

    View Slide

  2. View Slide

  3. View Slide

  4. Twisted
    cryptography
    CPython
    pyOpenSSL

    View Slide

  5. pem
    doc2dash
    argon2-cffi
    prometheus-async
    environ-config
    first
    Twisted
    cryptography
    CPython
    pyOpenSSL

    View Slide

  6. Remove Friction

    View Slide

  7. From Idea to PyPI:
    A Play in 3 Acts

    View Slide

  8. Act 1: Development

    View Slide

  9. View Slide

  10. View Slide

  11. View Slide

  12. View Slide

  13. .github/CONTRIBUTING.rst

    View Slide

  14. .github/CONTRIBUTING.rst
    .github/CODE_OF_CONDUCT.rst

    View Slide

  15. View Slide

  16. 1.$ pip install -e .[dev]

    View Slide

  17. 1.$ pip install -e .[dev]

    View Slide

  18. 1.$ pip install -e .[dev]

    View Slide

  19. 1.$ pip install -e .[dev]
    2.$ pytest

    View Slide

  20. 1.$ pip install -e .[dev]
    2.$ pytest
    3.$ cd docs; make html

    View Slide

  21. Problems

    View Slide

  22. Problems
    1. remember how

    View Slide

  23. Problems
    1. remember how
    2. only 1 Python version

    View Slide

  24. View Slide

  25. [tox]
    envlist = py27,py37,pypy,pypy3
    tox.ini

    View Slide

  26. [tox]
    envlist = py27,py37,pypy,pypy3
    [testenv]
    tox.ini

    View Slide

  27. [tox]
    envlist = py27,py37,pypy,pypy3
    [testenv]
    extras = tests
    tox.ini

    View Slide

  28. [tox]
    envlist = py27,py37,pypy,pypy3
    [testenv]
    extras = tests
    commands = pytest {posargs}
    tox.ini

    View Slide

  29. [tox]
    envlist = py27,py37,pypy,pypy3
    [testenv]
    extras = tests
    commands = pytest {posargs}
    tox.ini

    View Slide

  30. [tox]
    envlist = py27,py37,pypy,pypy3
    [testenv]
    extras = tests
    commands = pytest {posargs}
    # tox -e py27 -- -x
    tox.ini

    View Slide

  31. Linting

    View Slide

  32. flake8

    View Slide

  33. View Slide

  34. View Slide

  35. View Slide

  36. View Slide

  37. View Slide

  38. View Slide

  39. .pre-commit-config.yaml

    View Slide

  40. .pre-commit-config.yaml
    repos:
    - repo: https://gitlab.com/pycqa/flake8

    View Slide

  41. .pre-commit-config.yaml
    repos:
    - repo: https://gitlab.com/pycqa/flake8
    rev: 3.7.7

    View Slide

  42. .pre-commit-config.yaml
    repos:
    - repo: https://gitlab.com/pycqa/flake8
    rev: 3.7.7
    hooks:
    - id: flake8

    View Slide

  43. .pre-commit-config.yaml
    repos:
    - repo: https://gitlab.com/pycqa/flake8
    rev: 3.7.7
    hooks:
    - id: flake8
    language_version: python3.7

    View Slide

  44. tox.ini

    View Slide

  45. [testenv:lint]
    tox.ini

    View Slide

  46. [testenv:lint]
    deps = pre-commit
    tox.ini

    View Slide

  47. [testenv:lint]
    deps = pre-commit
    skip_install = true
    tox.ini

    View Slide

  48. [testenv:lint]
    deps = pre-commit
    skip_install = true
    commands =
    pre-commit run --all-files
    tox.ini

    View Slide

  49. tox.ini
    [testenv:docs]
    basepython = python3.7
    extras = docs
    commands =

    View Slide

  50. tox.ini
    [testenv:docs]
    basepython = python3.7
    extras = docs
    commands =
    sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/html

    View Slide

  51. tox.ini
    [testenv:docs]
    basepython = python3.7
    extras = docs
    commands =
    sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/html
    sphinx-build -W -b doctest -d {envtmpdir}/doctrees docs docs/_build/html

    View Slide

  52. tox.ini
    [testenv:docs]
    basepython = python3.7
    extras = docs
    commands =
    sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/html
    sphinx-build -W -b doctest -d {envtmpdir}/doctrees docs docs/_build/html
    python -m doctest README.rst

    View Slide

  53. Act 2: Pull Request

    View Slide

  54. .github/PULL_REQUEST_TEMPLATE.md

    View Slide

  55. View Slide

  56. View Slide

  57. View Slide

  58. #travisAlumns

    View Slide

  59. View Slide

  60. View Slide

  61. View Slide

  62. View Slide

  63. View Slide

  64. View Slide

  65. View Slide

  66. Act 3: Release

    View Slide

  67. View Slide

  68. View Slide

  69. __init__.py
    __version__ = "19.2.0.dev0"
    __title__ = "attrs"
    __description__ = "Classes Without Boilerplate"
    __url__ = "https://www.attrs.org/"
    __doc__ = __description__ + " <" + __uri__ + ">"
    __author__ = "Hynek Schlawack"
    __email__ = "[email protected]"
    __license__ = "MIT"
    __copyright__ = "Copyright (c) 2015 Hynek Schlawack"

    View Slide

  70. __init__.py
    __version__ = "19.2.0.dev0"
    __title__ = "attrs"
    __description__ = "Classes Without Boilerplate"
    __url__ = "https://www.attrs.org/"
    __doc__ = __description__ + " <" + __uri__ + ">"
    __author__ = "Hynek Schlawack"
    __email__ = "[email protected]"
    __license__ = "MIT"
    __copyright__ = "Copyright (c) 2015 Hynek Schlawack"

    View Slide

  71. ISO 8601: 1986-03-19

    View Slide

  72. View Slide

  73. Release

    View Slide

  74. View Slide

  75. View Slide

  76. View Slide

  77. View Slide

  78. View Slide

  79. ox.cx/oss
    @hynek
    vrmd.de

    View Slide