diff --git a/setup.py b/setup.py index 8c1f27e405..930d6b7905 100644 --- a/setup.py +++ b/setup.py @@ -4,13 +4,15 @@ import os import site from datetime import datetime -from typing import List +from typing import Dict, List from setuptools import setup from pathlib import Path import subprocess import re +STD_PACKAGES = set(('array', 'math', 'os', 'random', 'struct', 'sys', 'ssl', 'time')) + stub_root = Path("circuitpython-stubs") stubs = [p.relative_to(stub_root).as_posix() for p in stub_root.glob("*.pyi")] @@ -28,13 +30,18 @@ if len(pieces) > 2: pieces.pop() version = "-".join(pieces) -def build_data_files_list() -> List[tuple]: - result = [] - for package in os.listdir("circuitpython-stubs"): - result.append((site.getsitepackages()[0] + "/" + package + "/", - ["circuitpython-stubs/{}/__init__.pyi".format(package)])) +packages = set(os.listdir("circuitpython-stubs")) - STD_PACKAGES +package_dir = dict((f"{package}-stubs", f"circuitpython-stubs/{package}") + for package in packages) +print("package dir is", package_dir) + +def build_package_data() -> Dict[str, List[str]]: + result = {} + for package in packages: + result[f"{package}-stubs"] = ["*.pyi", "*/*.pyi"] return result +package_data=build_package_data() setup( name="circuitpython-stubs", description="PEP 561 type stubs for CircuitPython", @@ -44,6 +51,9 @@ setup( author_email="circuitpython@adafruit.com", version=version, license="MIT", - data_files=build_data_files_list(), + packages=list(package_data.keys()), + package_data=package_data, + package_dir = package_dir, setup_requires=["setuptools>=38.6.0"], + zip_safe=False, )