Skip to content

Commit 1fe3813

Browse files
committed
use scm_version for stubs. seperate stubs upload from S3 mpy-cross upload steps in actions.
1 parent abfeb69 commit 1fe3813

File tree

2 files changed

+31
-28
lines changed

2 files changed

+31
-28
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,29 @@ jobs:
117117
with:
118118
name: mpy-cross.static-x64-windows
119119
path: mpy-cross/mpy-cross.static.exe
120-
- name: Upload stubs and mpy-cross builds to S3
120+
- name: Upload mpy-cross builds to S3
121121
if: github.event_name == 'push' || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
122122
env:
123123
AWS_PAGER: ''
124124
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
125125
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
126-
TWINE_USERNAME: ${{ secrets.pypi_username }}
127-
TWINE_PASSWORD: ${{ secrets.pypi_password }}
128126
run: |
129127
[ -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
130128
[ -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
131129
[ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp mpy-cross/mpy-cross.static s3://adafruit-circuit-python/bin/mpy-cross/mpy-cross.static-amd64-linux-${{ env.CP_VERSION }} --no-progress --region us-east-1
132130
[ -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
133131
zip -9r circuitpython-stubs.zip circuitpython-stubs
134132
[ -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
135-
if [[ -z "${{steps.need-pypi.outputs.setup-py}}" && -z "$TWINE_PASSWORD" ]]; then
136-
python setup.py sdist
137-
twine upload dist/*
138-
fi
133+
134+
- name: Upload stubs to PyPi
135+
if: github.event_name == 'push'
136+
env:
137+
TWINE_USERNAME: ${{ secrets.pypi_username }}
138+
TWINE_PASSWORD: ${{ secrets.pypi_password }}
139+
run: |
140+
echo "Uploading dev release to PyPi"
141+
python setup.py sdist
142+
twine upload dist/*
139143
140144
mpy-cross-mac:
141145
runs-on: macos-10.15

setup.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,43 @@
44
import os
55
import site
66
from datetime import datetime
7-
from typing import List
7+
from typing import Dict, List
88

99
from setuptools import setup
1010
from pathlib import Path
11-
import subprocess
12-
import re
11+
12+
STD_PACKAGES = set(('array', 'math', 'os', 'random', 'struct', 'sys', 'ssl', 'time'))
1313

1414
stub_root = Path("circuitpython-stubs")
1515
stubs = [p.relative_to(stub_root).as_posix() for p in stub_root.glob("*.pyi")]
1616

17-
git_out = subprocess.check_output(["git", "describe", "--tags"])
18-
version = git_out.strip().decode("utf-8")
17+
def local_scheme(version):
18+
return ""
1919

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)
2824

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"]
3429
return result
3530

31+
package_data=build_package_data()
3632
setup(
3733
name="circuitpython-stubs",
3834
description="PEP 561 type stubs for CircuitPython",
3935
url="https://github.com/adafruit/circuitpython",
4036
maintainer="CircuitPythonistas",
4137
maintainer_email="[email protected]",
4238
author_email="[email protected]",
43-
version=version,
4439
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,
4746
)

0 commit comments

Comments
 (0)