use scm_version for stubs. seperate stubs upload from S3 mpy-cross upload steps in actions.

This commit is contained in:
foamyguy 2021-06-19 12:33:34 -05:00
parent abfeb69454
commit 1fe38138e8
2 changed files with 31 additions and 28 deletions

View File

@ -117,14 +117,12 @@ jobs:
with: with:
name: mpy-cross.static-x64-windows name: mpy-cross.static-x64-windows
path: mpy-cross/mpy-cross.static.exe 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')) if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
env: env:
AWS_PAGER: '' AWS_PAGER: ''
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TWINE_USERNAME: ${{ secrets.pypi_username }}
TWINE_PASSWORD: ${{ secrets.pypi_password }}
run: | 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-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 [ -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 [ -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 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 [ -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 - name: Upload stubs to PyPi
twine upload dist/* if: github.event_name == 'push'
fi 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: mpy-cross-mac:
runs-on: macos-10.15 runs-on: macos-10.15

View File

@ -4,35 +4,31 @@
import os import os
import site import site
from datetime import datetime from datetime import datetime
from typing import List from typing import Dict, List
from setuptools import setup from setuptools import setup
from pathlib import Path from pathlib import Path
import subprocess
import re STD_PACKAGES = set(('array', 'math', 'os', 'random', 'struct', 'sys', 'ssl', 'time'))
stub_root = Path("circuitpython-stubs") stub_root = Path("circuitpython-stubs")
stubs = [p.relative_to(stub_root).as_posix() for p in stub_root.glob("*.pyi")] stubs = [p.relative_to(stub_root).as_posix() for p in stub_root.glob("*.pyi")]
git_out = subprocess.check_output(["git", "describe", "--tags"]) def local_scheme(version):
version = git_out.strip().decode("utf-8") return ""
# Detect a development build and mutate it to be valid semver and valid python version. packages = set(os.listdir("circuitpython-stubs")) - STD_PACKAGES
pieces = version.split("-") package_dir = dict((f"{package}-stubs", f"circuitpython-stubs/{package}")
if len(pieces) > 2: for package in packages)
pieces.pop() print("package dir is", package_dir)
# Merge the commit count and build to the pre-release identifier.
pieces[-2] += ".dev." + pieces[-1]
pieces.pop()
version = "-".join(pieces)
def build_data_files_list() -> List[tuple]: def build_package_data() -> Dict[str, List[str]]:
result = [] result = {}
for package in os.listdir("circuitpython-stubs"): for package in packages:
result.append((site.getsitepackages()[0] + "/" + package + "/", result[f"{package}-stubs"] = ["*.pyi", "*/*.pyi"]
["circuitpython-stubs/{}/__init__.pyi".format(package)]))
return result return result
package_data=build_package_data()
setup( setup(
name="circuitpython-stubs", name="circuitpython-stubs",
description="PEP 561 type stubs for CircuitPython", description="PEP 561 type stubs for CircuitPython",
@ -40,8 +36,11 @@ setup(
maintainer="CircuitPythonistas", maintainer="CircuitPythonistas",
maintainer_email="circuitpython@adafruit.com", maintainer_email="circuitpython@adafruit.com",
author_email="circuitpython@adafruit.com", author_email="circuitpython@adafruit.com",
version=version,
license="MIT", license="MIT",
data_files=build_data_files_list(), packages=list(package_data.keys()),
setup_requires=["setuptools>=38.6.0"], 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,
) )