-
Notifications
You must be signed in to change notification settings - Fork 16
/
setup.py
40 lines (32 loc) · 1.58 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
To understand this project's build structure
- This project uses setuptools, so it is declared as the build system in the pyproject.toml file
- We use as much as possible `setup.cfg` to store the information so that it can be read by other tools such as `tox`
and `nox`. So `setup.py` contains **almost nothing** (see below)
This philosophy was found after trying all other possible combinations in other projects :)
A reference project that was inspiring to make this move : https://github.com/Kinto/kinto/blob/master/setup.cfg
See also:
https://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files
https://packaging.python.org/en/latest/distributing.html
https://github.com/pypa/sampleproject
"""
from setuptools import setup
import pkg_resources
# (1) check required versions (from https://medium.com/@daveshawley/safely-using-setup-cfg-for-metadata-1babbe54c108)
pkg_resources.require("setuptools>=39.2")
pkg_resources.require("setuptools_scm")
# (2) read the setup.cfg to grab useful metadata
from setuptools.config import read_configuration
conf_dict = read_configuration("setup.cfg")
PKG_NAME = conf_dict['metadata']['name']
URL = conf_dict['metadata']['url']
# (3) Generate download url using git version
from setuptools_scm import get_version # noqa: E402
DOWNLOAD_URL = URL + "/tarball/" + get_version()
# (4) Call setup() with as little args as possible
setup(
download_url=DOWNLOAD_URL,
use_scm_version={
"write_to": "%s/_version.py" % PKG_NAME
}, # we can't put `use_scm_version` in setup.cfg yet unfortunately
)