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:
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

View File

@ -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,
)