-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
39 lines (28 loc) · 991 Bytes
/
Copy pathsetup.py
File metadata and controls
39 lines (28 loc) · 991 Bytes
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
# SPDX-License-Identifier: Apache-2.0
"""A setuptools based setup module.
This module is only necessary for building the CFFI module library.
"""
from typing import Any
from packaging.version import Version
from setuptools import setup
from setuptools_scm.git import parse as git_parse
from setuptools_scm.version import ScmVersion
def custom_parse(root: str, config: Any) -> ScmVersion | None:
"""Custom parse function that removes tag local segment.
Removes semver metadata from tags to generate pypi compatible versions.
"""
version: ScmVersion | None = git_parse(root, config)
if version is None:
return None
# Strip local segment from parsed tag so setuptools-scm does not
# re-append it
base = str(version.tag).split("+")[0]
version.tag = Version(base)
return version
setup(
cffi_modules=["build_ffi.py:compile_ffi"],
use_scm_version={
"parse": custom_parse,
"version_scheme": "no-guess-dev",
},
)