Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Comparison of Packaging Tools in 2023 (PyCon APAC 2023)

Peacock
October 28, 2023

Comparison of Packaging Tools in 2023 (PyCon APAC 2023)

Peacock

October 28, 2023
Tweet

More Decks by Peacock

Other Decks in Programming

Transcript

  1. Comparison of
    Packaging Tools in 2023
    Peacock (Yoichi Takai),
    at PyCon APAC 2023 (2023/10/28)

    View full-size slide

  2. Slides: slides.p3ac0ck.net/pyconapac2023/index.html
    Feel Free to Take Pictures
    Social Hashtags:
    #pyconapac_2
    #pyconapac2023

    View full-size slide

  3. Introduction
    Backgrounds, Motivations, Target Audiences
    3 / 35

    View full-size slide

  4. Backgrounds and Motivations
    Situation of Python packaging was changed dramatically -
    Adopted 3 PEPs;
    PEP 517: build system specification format
    PEP 621: Standardized pyproject.toml format
    PEP 660: pyproject.toml based editable installs
    4 / 35

    View full-size slide

  5. I felt…
    Needed a
    Pros-Cons
    comparison in now?

    View full-size slide

  6. Target Audiences of this Talk
    Struggling with choosing packaging tools:
    for 3 types of Pythonistas:
    Library / Framework Developer (Complex Project)
    Application Developer (Many People Project)
    Single or Few Files Scripts Developer (Small Project)

    View full-size slide

  7. Table of Contents
    1. Introduction
    1. Background, Motivations, Target Audiences of this Talk
    2. List of Packaging tools to compare in this Talk
    3. Self-Introduction
    2. Pros / Cons for each tool
    1. Pipenv, Poetry, PDM, pip-tools, Hatch, pip (with venv)
    3. What is the best tool? (for Library / Application / Scripting
    Developers)
    4. Appendix: Rye

    View full-size slide

  8. Basic Information
    Name Author First Release License
    Pipenv Kenneth Reitz 2018/06 2018.6.25 MIT
    Poetry Sébastien Eustace 2018/03 0.2.0 MIT
    PDM Frost Ming 2020/01 0.0.1 MIT
    pip-tools Vincent Driessen 2017/04 1.8.2 BSD 3-Clause
    Hatch Ofek Lev 2021/12 Hatch v1rc2 MIT
    pip PyPA 2008/12 (First GitHub commit) MIT

    View full-size slide

  9. Self-Introduction
    Name: Peacock / Yoichi Takai
    Social media names: peacock0803sz
    23 Years Old, 5+ Years of Python Ex
    Work: TOPGATE, Inc. (2022/12 ~)
    Vice-Chair of PyCon APAC 2023
    Likes: Listening to Music / Cameras
    / Audios / Drinking
    9 / 35

    View full-size slide

  10. Pre-explain
    About PEP 621 style pyproject.toml
    10 / 35

    View full-size slide

  11. PEP 621 style pyproject.toml
    ref: https://peps.python.org/pep-0621/
    1 [build-system]
    2 requires = ["setuptools>=45","wheel"]
    3
    4 [project]
    5 name = "my-awesome-package"
    6 readme = "README.md"
    7 license = {file = "LICENSE"}
    8 authors = [{name = "Peacock", email = "[email protected]"}]
    9 version = "0.1.0"
    10 requires-python = ">=3.10"
    11 dependencies = ["SQLAlchemy", "FastAPI"] # list dependencies here
    12
    13 [project.optional-dependencies]
    14 dev = ["black", "flake8", "mypy"] # list dev-dependencies here
    11 / 35

    View full-size slide

  12. Pros/Cons for each tool
    Main comparison points
    12 / 35

    View full-size slide

  13. Pipenv
    https://pipenv.pypa.io/en/latest/
    13 / 35

    View full-size slide

  14. Pipenv: Pros
    Supporting lock-file
    Easy to add/upgrade packages
    Wraps virtualenv
    Pipenv: Cons
    Slow dependency resolver (improved?)
    LIMITED support PEP 621 style pyproject.toml
    14 / 35

    View full-size slide

  15. Poetry
    https://python-poetry.org/
    15 / 35

    View full-size slide

  16. Poetry: Pros
    Dependency management with lock-file
    Wraps virtualenv
    Included Task-runner ( poetry run )
    Helper for the building wheels
    Poetry: Cons
    NOT support PEP 621 style pyproject.toml
    16 / 35

    View full-size slide

  17. PDM
    https://pdm.fming.dev/latest/
    17 / 35

    View full-size slide

  18. PDM: Pros
    Fast dependency resolver
    But you can choose another resolver
    Support PEP 621 style pyproject.toml
    Included Task-runner ( pdm run ), package publisher
    PDM: Cons
    Few GitHub Stars / not Famous
    18 / 35

    View full-size slide

  19. pip-tools
    https://pip-tools.readthedocs.io/en/latest/
    19 / 35

    View full-size slide

  20. pip-tools: Pros
    Simple to use, only 2 commands
    Support PEP 621 style pyproject.toml dependency
    Combine-able with pip or hatch
    Maintained by the Jazzband community
    pipe-tools: Cons
    not Included Task-runner, wheel builder and package
    publisher
    20 / 35

    View full-size slide

  21. Hatch
    https://hatch.pypa.io/latest/
    21 / 35

    View full-size slide

  22. Hatch: Pros
    Configurable to a back-end for building project
    Maintained actively by PyPA, nearly official
    Works with pyproject.toml spec, PEP 621 style
    Hatch: Cons
    Not included dependency updater
    Not supporting lock-file
    22 / 35

    View full-size slide

  23. pip
    https://pip.pypa.io/en/stable/index.html
    23 / 35

    View full-size slide

  24. pip: Pros
    (Almost) Build-in in Python, very simple
    Works with pyproject.toml spec, PEP 621 style
    pip: Cons
    Without wraps virtualenv
    Not supporting file-managed dependency
    Not included task-runner and wheel builder
    24 / 35

    View full-size slide

  25. SUMMARY
    What is the best tool? (In some use cases)
    25 / 35

    View full-size slide

  26. Case 1: Library Developing
    -> Hatch (with pip-tools): Very configurable and flexible
    Reasons
    Almost what you need is included
    ex: Task-runner, wheel builder and publisher
    Maintained actively by PyPA
    Works with pyproject.toml spec, PEP 621 style
    26 / 35

    View full-size slide

  27. Case 2: Application Developing
    -> PDM: All-in-one tool and easy to use
    Reasons
    Fast dependency resolver
    Support PEP 621 style pyproject.toml
    Included Task-runner ( pdm run )
    27 / 35

    View full-size slide

  28. Case 3: Automation Script Developing
    -> pip: Simply to use, Non-dependency (built-in in Python)
    Reasons
    Lightweight, Non-dependency to install itself
    Simple to use, There are many know-hows and examples
    28 / 35

    View full-size slide

  29. CONCLUSION
    Library Developer: Hatch (with pip-tools)
    Very configurable and flexible
    Application Developer: PDM
    All-in-one tool and easy to use
    Automation / Scripting Developer: pip
    Simply to use, Non-dependency (built-in in Python)
    29 / 35

    View full-size slide

  30. Appendix: Rye
    https://rye-up.com
    30 / 35

    View full-size slide

  31. Rye: Pros
    Single-binary, easy to install and use
    Works with pyproject.toml spec, PEP 621 style
    Almost what you want is included;
    virtualenv wrapper, Package Builder, Publisher and
    Python version manager
    31 / 35

    View full-size slide

  32. Rye: Cons
    EXPERIMENTAL, not stable
    Too early to use in production
    Mitsuhiko’s personally project
    Just a wrapper of pip-tools?
    for the dependency manager
    32 / 35

    View full-size slide

  33. Notes: References URLs
    PEP 517 – A build-system independent format for source trees
    PEP 621 – Storing project metadata in pyproject.toml
    PEP 660 – Editable installs for pyproject.toml based builds (wheel based)
    Official Doc for the setuptools by PyPA
    python-poetry/poetry: Use the [project] section in pyproject.toml according to PEP-621
    #3332
    python-poetry/poetry: Add support for pyproject.toml files when adding --editable
    projects … #7670
    My Blog article (in Japanese):
    Isn’t venv + pip good for Python package management? in 2023/1
    Are you using the -c/–constraint option of pip install?

    View full-size slide

  34. Thank You PyCon Community!

    View full-size slide

  35. Questions?
    Hashtag: #pyconapac_2

    View full-size slide