From 1fe38138e85b8e23bcddd5e675eae9533c78997f Mon Sep 17 00:00:00 2001 From: foamyguy Date: Sat, 19 Jun 2021 12:33:34 -0500 Subject: [PATCH] use scm_version for stubs. seperate stubs upload from S3 mpy-cross upload steps in actions. --- .github/workflows/build.yml | 18 +++++++++------- setup.py | 41 ++++++++++++++++++------------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bdd8086771..1b949db6f2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -117,14 +117,12 @@ jobs: with: name: mpy-cross.static-x64-windows path: mpy-cross/mpy-cross.static.exe - - name: Upload stubs and mpy-cross builds to S3 + - name: Upload mpy-cross builds to S3 if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested')) env: AWS_PAGER: '' AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - TWINE_USERNAME: ${{ secrets.pypi_username }} - TWINE_PASSWORD: ${{ secrets.pypi_password }} run: | [ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp mpy-cross/mpy-cross.static-aarch64 s3://adafruit-circuit-python/bin/mpy-cross/mpy-cross.static-aarch64-${{ env.CP_VERSION }} --no-progress --region us-east-1 [ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp mpy-cross/mpy-cross.static-raspbian s3://adafruit-circuit-python/bin/mpy-cross/mpy-cross.static-raspbian-${{ env.CP_VERSION }} --no-progress --region us-east-1 @@ -132,10 +130,16 @@ jobs: [ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp mpy-cross/mpy-cross.static.exe s3://adafruit-circuit-python/bin/mpy-cross/mpy-cross.static-x64-windows-${{ env.CP_VERSION }}.exe --no-progress --region us-east-1 zip -9r circuitpython-stubs.zip circuitpython-stubs [ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp circuitpython-stubs.zip s3://adafruit-circuit-python/bin/stubs/circuitpython-stubs-${{ env.CP_VERSION }}.zip --no-progress --region us-east-1 - if [[ -z "${{steps.need-pypi.outputs.setup-py}}" && -z "$TWINE_PASSWORD" ]]; then - python setup.py sdist - twine upload dist/* - fi + + - name: Upload stubs to PyPi + if: github.event_name == 'push' + env: + TWINE_USERNAME: ${{ secrets.pypi_username }} + TWINE_PASSWORD: ${{ secrets.pypi_password }} + run: | + echo "Uploading dev release to PyPi" + python setup.py sdist + twine upload dist/* mpy-cross-mac: runs-on: macos-10.15 diff --git a/setup.py b/setup.py index 760186beed..4152cc0017 100644 --- a/setup.py +++ b/setup.py @@ -4,35 +4,31 @@ 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")] -git_out = subprocess.check_output(["git", "describe", "--tags"]) -version = git_out.strip().decode("utf-8") +def local_scheme(version): + return "" -# Detect a development build and mutate it to be valid semver and valid python version. -pieces = version.split("-") -if len(pieces) > 2: - pieces.pop() - # Merge the commit count and build to the pre-release identifier. - pieces[-2] += ".dev." + pieces[-1] - pieces.pop() -version = "-".join(pieces) +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_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)])) +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", @@ -40,8 +36,11 @@ setup( maintainer="CircuitPythonistas", maintainer_email="circuitpython@adafruit.com", author_email="circuitpython@adafruit.com", - version=version, license="MIT", - data_files=build_data_files_list(), - setup_requires=["setuptools>=38.6.0"], + packages=list(package_data.keys()), + package_data=package_data, + package_dir = package_dir, + setup_requires=["setuptools_scm", "setuptools>=38.6.0"], + use_scm_version={"local_scheme": local_scheme}, + zip_safe=False, )