semvec/pypi-packages huggingface dataset:
test-pkg-setuptools-binlecode 0.0.2
A small test package by setuptools
License: MIT
Requires Python: >=3.8


# build a python package

setuptools guide:
https://setuptools.pypa.io/en/latest/userguide/index.html

This example uses (traiditional way) setup() function within the `setup.py`
script.

```sh
pyenv shell 3.9.7
python -m venv venv
source venv/bin/activate

python -m pip install --upgrade pip wheel setuptools twine
```

## sdist

`python setup sdist` generates source distribution:
- dist folder that contains `<package-name>-<version>.tar.gz`
- <package-name>.egg-info folder

A source distribution contains source code. 
That includes not only Python code but also the source code of any extension
modules (usually in C or C++) bundled with the package. 
With source distributions, extension modules are compiled on the user’s side
rather than the developer’s.

Source distributions also contain a bundle of metadata sitting in a directory
called `<package-name>.egg-info`. Egg distribution format is being replaced
by wheel distribution format.

## bdist and bdist_wheel

`bdist` means build distribution, which is not necessarily binary.

`python setup.py bdist` generates:
- dist/<package-name>-<version>.<platform>.tar.gz, which is the default 
  type of built distribution for the current platform
- build/bdist.<platform>
- build/lib folder that includes modules

`python setup.py bdist_wheel` generates:
- dist/<package-name>-<version>-py3-none-any.whl


Usually both source and wheel build distributions are generated and uploaded
to package index for download and install.

```sh
rm -rf build dist *.egg-info
python setup.py sdist bdist_wheel
```

## upload package to PyPI

First, register PyPI account if not yet.

```sh
twine upload dist/*
```



## install

`python setup.py install` installs the distribution package.

A inline editable install is for development mode:
`python setup.py install --editable .` will install with the source content
that is editable, which is great for debuging and testing changes.

A later [PEP517](https://www.python.org/dev/peps/pep-0517/) standard defines
`pyproject.toml` as the new standard for packaging and distributing python
modules.

If there's no `pyproject.toml` available, setuptools will fall back to 
`setup.py` file.