-
Notifications
You must be signed in to change notification settings - Fork 16
/
setup.py
38 lines (28 loc) · 1.42 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
"""
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
# (1) check required versions (from https://medium.com/@daveshawley/safely-using-setup-cfg-for-metadata-1babbe54c108)
import pkg_resources
pkg_resources.require("setuptools>=39.2")
pkg_resources.require("setuptools_scm")
# (2) Generate download url using git version
from setuptools_scm import get_version # noqa: E402
URL = "https://github.com/smarie/mkdocs-gallery"
DOWNLOAD_URL = URL + "/tarball/" + get_version()
# (3) Call setup() with as little args as possible
setup(
download_url=DOWNLOAD_URL,
use_scm_version={
"write_to": "src/mkdocs_gallery/_version.py"
}, # we can't put `use_scm_version` in setup.cfg yet unfortunately
)