Skip to content

Commit c5a4e19

Browse files
authored
Merge pull request #1915 from jreese/rst2pyi
Use rst2pyi to generate type stubs and package
2 parents bcda5e1 + e8521c8 commit c5a4e19

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
# Packages
1414
############
15+
dist/
16+
*.egg-info
1517

1618
# Logs and Databases
1719
######################
@@ -25,6 +27,7 @@
2527
######################
2628
build/
2729
bin/
30+
circuitpython-stubs/
2831

2932
# Test failure outputs
3033
######################

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ CONFDIR = .
1717
FORCE = -E
1818
VERBOSE = -v
1919

20+
# path to generated type stubs
21+
STUBDIR = circuitpython-stubs
22+
# Run "make VALIDATE= stubs" to avoid validating generated stub files
23+
VALIDATE = -v
24+
# path to pypi source distributions
25+
DISTDIR = dist
26+
2027
# Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the
2128
# full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the
2229
# executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
@@ -31,7 +38,7 @@ I18NSPHINXOPTS = $(BASEOPTS)
3138

3239
TRANSLATE_SOURCES = extmod lib main.c ports/atmel-samd ports/nrf py shared-bindings shared-module supervisor
3340

34-
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
41+
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext stubs
3542

3643
help:
3744
@echo "Please use \`make <target>' where <target> is one of"
@@ -60,6 +67,7 @@ help:
6067

6168
clean:
6269
rm -rf $(BUILDDIR)/*
70+
rm -rf $(STUBDIR) $(DISTDIR) *.egg-info
6371

6472
html:
6573
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@@ -203,3 +211,7 @@ translate: locale/circuitpython.pot
203211

204212
check-translate: locale/circuitpython.pot $(wildcard locale/*.po)
205213
$(PYTHON) tools/check_translations.py $^
214+
215+
stubs:
216+
rst2pyi $(VALIDATE) shared-bindings/ $(STUBDIR)
217+
python setup.py sdist

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rst2pyi>=0.3.0

setup.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from datetime import datetime
2+
from setuptools import setup
3+
from pathlib import Path
4+
5+
stub_root = Path("circuitpython-stubs")
6+
stubs = [p.relative_to(stub_root).as_posix() for p in stub_root.glob("*.pyi")]
7+
8+
now = datetime.utcnow()
9+
version = now.strftime("%Y.%m.%d")
10+
11+
setup(
12+
name="circuitpython-stubs",
13+
description="PEP 561 type stubs for CircuitPython",
14+
url="https://github.com/adafruit/circuitpython",
15+
maintainer="CircuitPythonistas",
16+
author_email="circuitpython@adafruit.com",
17+
version=version,
18+
license="MIT",
19+
package_data={"circuitpython-stubs": stubs},
20+
packages=["circuitpython-stubs"],
21+
setup_requires=["setuptools>=38.6.0"],
22+
)

0 commit comments

Comments
 (0)