Company
Date Published
Author
Elliot Gunn
Word count
1496
Language
English
Hacker News points
None

Summary

Python packages are discussed in this article, focusing on managing dependencies for data people. Dependency management is crucial as it keeps track of other packages required to work correctly. The Python Package Index (PyPI) is a central repository of open-source Python packages that can be used to search and make packages available. Two methods of managing dependencies are explored: the old way using `setup.py` files, which were previously recommended, and the new way using `pyproject.toml` files, introduced as part of PEP 518 and PEP 621. The latter is simpler and easier to read than `setup.py`. Extras can be specified in both methods, allowing for optional features that require additional dependencies. Alternative tools like Poetry provide a more user-friendly approach with version constraint resolution and automatic virtual environment management. Virtual environments create isolated Python environments to allow different versions of Python and libraries to be used without interfering with each other. They are created using the `python -m venv` command, activated using the `source` command, and deactivated by typing `deactivate`. It's best practice to keep virtual environments in the same directory as the project and add them to `.gitignore` if they're in a Git repository.