distuils is the standard packaging tool of Python, and setuptools is its improvement.
from distutils.core import setup
setup(
name = 'hello',
version = '1.0',
packages = ['hello'],
)
python setup.py sdist
# got a tar.gz file in dist dictionary
from setuptools import setup
setup(
name='mypackage',
author='Giorgos Myrianthous',
version='0.1',
install_requires=[
'pandas',
'numpy',
'matplotlib',
],
# ... more options/metadata
)
[metadata]
name = mypackage
author = Giorgos Myrianthous
version = 0.1
[options]
install_requires =
pandas
numpy
matplotlib
python setup.py bdist_egg
# got a egg file in dist dictionary
PyPI · The Python Package Index
Once you upload your egg file onto PyPI, you can download and install your module throught easy_install(deprecated) or pip
The requirements.txt is a file listing all the dependencies for a specific Python project.
matplotlib>=2.2
numpy>=1.15.0, <1.21.0
pandas
pytest==4.0.1
pip install -r requirements.txt
In case you are using both, your setup.py (and/or setup.cfg) files should include the list of abstract dependencies, whereas the requirements.txt file must contain the concrete dependencies with the specific pins for each package version (using == pin).
The goal of this file is to allow you to define what build tools are needed in order to build your package – no longer assuming it must be Setuptools. And it can be Poetry or Filt.
/path/to/example/project/
├── src/ Source dir.
│ └── example/ Python package directory.
│ ├── __init__.py This makes the directory a package.
│ └── example_module.py Example module.
├── pyproject.toml Definition of build process of the package.
├── README.md README with info of the project.
└── setup.cfg Configuration details of the python package.
Tools are standardizing on pyproject.toml, so now projects like Black, coverage.py, towncrier, and tox (in a way) allow you to specify their configurations in pyproject.toml instead of in a separate file.