The best package manager for Python in 2020

Tram Ho

Summary

Talking about the management package for python, in recent years there are quite a lot of support tools, but the advantages and disadvantages of those tools, if not learn through it will certainly be a bit confusing in Choose when starting a new project. In this article, I will be comparing the tools to help us better understand the benefits and how to use them. I am a bit inclined to Poetry so I might be a bit biased, please understand.

Main content:

  • Similarities between Pipenv 、 Poetry 、 Pyflow and how to use it.

Content not mentioned:

  • Explanation of the tools: Pyenv 、 Venv 、 Virtualenv

Test environment:

  • Ubuntu 18.04
  • Python 3.8.0
  • Pipenv 2018.11.26
  • Poetry 1.0.0
  • Pyflow 0.2.1

Especially, Poetry and Pyflow are in development, so there may be wrong commands about these two tools. As of 2019/12/15, Star statistics on the github are as follows, only the Poetry 1.0.0 tool was released 7 days ago

Introduce

Pipenv

https://github.com/pypa/pipenv

This tool is used to manage packages with file requirements.txt (that means managing the libraries listed in this file), for example Node.js has npm, yarn, Ruby has gems, and also can handle the reference of that library (ie, always download dependent libraries to run the main library).

This tool uses file management Pipfile and file Pipfile.lock to manage these links. For example, the pandas library uses numpy as a mandatory link library, so when installing or deleting pandas , the numpy library will also be installed or removed.

Pipfile

Poetry

https://github.com/python-poetry/poetry

While Pipenv is a popular tool, at PEP 518 , pyproject.com introduced Poetry as the official tool used to manage its package.

Pipenv can only be managed on requirements.txt or alt-requirements.txt , but for Poetry it can be managed on more channels such as setup.py , setup.cfg , MANIFEST.in , …, in addition It is also possible to setup linter or formatter on the same file.

Pyflow

https://github.com/David-OConnor/pyflow

Pyflow is probably the latest tool, written in Rust, in addition to PEP 518 introduced by Poetey, which was also exported in PEP 582. Pyflow can handle and switch multiple versions of python in the same virtual environment. Unlike Pipenv / Poetry, which only handles a virtual environment of a Python version with Pyenv + venv, Pyflow can manage multiple versions of Python itself and create a virtual environment with any version.

This doesn’t make much sense right now, but it might be useful if there’s a major update to Python in the future. The advantage is that this tool is written in Rust and seems to be beneficial in speed, etc., but the difficult point is that the Rust development community is a bit weak so if there is an error it will take a long time to resolve.

Using

How to install it can be found in the links below.

As for Pyflow, you can basically use Pip to install, but currently Pyflow is discouraging the use of Pip, because it doesn’t seem to like Mac so it is better to install with Rust.

For all the most basic commands, you can refer to the table listed below.

ActionPipPipenvPoetryPyflow
Create projectpoetry new samplepyflow new sample
Init projectpipenv –python 3.8poetry initpyflow init
Add packagepip install numpypipenv install numpypoetry add numpypyflow install numpy
Remove packagepip uninstall numpypipenv uninstall numpypoetry remove numpypyflow uninstall numpy
Install depedencypip install -r requirements.txtpipenv syncpoetry installpyflow sync
Run virtual environmentpipenv run python main.pypoetry run python main.pypyflow main.py
Build packagepython setup.py bdist_wheepoetry buildpyflow package
Upload package (PyPI)twine upload –repository pypi dist / *poetry publishpyflow publish

Looking at the table above, you can see that in Pyflow and Pipenv the commands seem similar, while in the build package, Poetry and Pyflow have the commands that look the brightest.

The structure of the directory after installing a library is as follows (instal numpy)

pipenv-tree

poetry-tree

pyflow-tree

Refer

https://qiita.com/sk217/items/43c994640f4843a18dbe

Share the news now

Source : Viblo