|
4 | 4 | import os
|
5 | 5 | import site
|
6 | 6 | from datetime import datetime
|
7 |
| -from typing import List |
| 7 | +from typing import Dict, List |
8 | 8 |
|
9 | 9 | from setuptools import setup
|
10 | 10 | from pathlib import Path
|
11 |
| -import subprocess |
12 |
| -import re |
| 11 | + |
| 12 | +STD_PACKAGES = set(('array', 'math', 'os', 'random', 'struct', 'sys', 'ssl', 'time')) |
13 | 13 |
|
14 | 14 | stub_root = Path("circuitpython-stubs")
|
15 | 15 | stubs = [p.relative_to(stub_root).as_posix() for p in stub_root.glob("*.pyi")]
|
16 | 16 |
|
17 |
| -git_out = subprocess.check_output(["git", "describe", "--tags"]) |
18 |
| -version = git_out.strip().decode("utf-8") |
| 17 | +def local_scheme(version): |
| 18 | + return "" |
19 | 19 |
|
20 |
| -# Detect a development build and mutate it to be valid semver and valid python version. |
21 |
| -pieces = version.split("-") |
22 |
| -if len(pieces) > 2: |
23 |
| - pieces.pop() |
24 |
| - # Merge the commit count and build to the pre-release identifier. |
25 |
| - pieces[-2] += ".dev." + pieces[-1] |
26 |
| - pieces.pop() |
27 |
| -version = "-".join(pieces) |
| 20 | +packages = set(os.listdir("circuitpython-stubs")) - STD_PACKAGES |
| 21 | +package_dir = dict((f"{package}-stubs", f"circuitpython-stubs/{package}") |
| 22 | + for package in packages) |
| 23 | +print("package dir is", package_dir) |
28 | 24 |
|
29 |
| -def build_data_files_list() -> List[tuple]: |
30 |
| - result = [] |
31 |
| - for package in os.listdir("circuitpython-stubs"): |
32 |
| - result.append((site.getsitepackages()[0] + "/" + package + "/", |
33 |
| - ["circuitpython-stubs/{}/__init__.pyi".format(package)])) |
| 25 | +def build_package_data() -> Dict[str, List[str]]: |
| 26 | + result = {} |
| 27 | + for package in packages: |
| 28 | + result[f"{package}-stubs"] = ["*.pyi", "*/*.pyi"] |
34 | 29 | return result
|
35 | 30 |
|
| 31 | +package_data=build_package_data() |
36 | 32 | setup(
|
37 | 33 | name="circuitpython-stubs",
|
38 | 34 | description="PEP 561 type stubs for CircuitPython",
|
39 | 35 | url="https://github.com/adafruit/circuitpython",
|
40 | 36 | maintainer="CircuitPythonistas",
|
41 | 37 | maintainer_email="[email protected]",
|
42 | 38 |
|
43 |
| - version=version, |
44 | 39 | license="MIT",
|
45 |
| - data_files=build_data_files_list(), |
46 |
| - setup_requires=["setuptools>=38.6.0"], |
| 40 | + packages=list(package_data.keys()), |
| 41 | + package_data=package_data, |
| 42 | + package_dir = package_dir, |
| 43 | + setup_requires=["setuptools_scm", "setuptools>=38.6.0"], |
| 44 | + use_scm_version={"local_scheme": local_scheme}, |
| 45 | + zip_safe=False, |
47 | 46 | )
|
0 commit comments