From 7f7665c1c02437e1b4717495f0de7d8f01933dd5 Mon Sep 17 00:00:00 2001 From: John Reese Date: Sat, 11 May 2019 20:00:22 -0700 Subject: Use rst2pyi to generate type stubs and package --- .gitignore | 3 +++ Makefile | 14 +++++++++++++- requirements-dev.txt | 1 + setup.py | 22 ++++++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 requirements-dev.txt create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 69f71847b..3e5bd2830 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,8 @@ # Packages ############ +dist/ +*.egg-info # Logs and Databases ###################### @@ -25,6 +27,7 @@ ###################### build/ bin/ +circuitpython-stubs/ # Test failure outputs ###################### diff --git a/Makefile b/Makefile index 5d5d99fb8..dc546279d 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,13 @@ CONFDIR = . FORCE = -E VERBOSE = -v +# path to generated type stubs +STUBDIR = circuitpython-stubs +# Run "make VALIDATE= stubs" to avoid validating generated stub files +VALIDATE = -v +# path to pypi source distributions +DISTDIR = dist + # Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the # full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the # executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) @@ -31,7 +38,7 @@ I18NSPHINXOPTS = $(BASEOPTS) TRANSLATE_SOURCES = extmod lib main.c ports/atmel-samd ports/nrf py shared-bindings shared-module supervisor -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext stubs help: @echo "Please use \`make ' where is one of" @@ -60,6 +67,7 @@ help: clean: rm -rf $(BUILDDIR)/* + rm -rf $(STUBDIR) $(DISTDIR) html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @@ -203,3 +211,7 @@ translate: locale/circuitpython.pot check-translate: locale/circuitpython.pot $(wildcard locale/*.po) $(PYTHON) tools/check_translations.py $^ + +stubs: + rst2pyi $(VALIDATE) shared-bindings/ $(STUBDIR) + python setup.py sdist diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 000000000..278fe7fd5 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1 @@ +rst2pyi=0.1.0 \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 000000000..780d97152 --- /dev/null +++ b/setup.py @@ -0,0 +1,22 @@ +from datetime import datetime +from setuptools import setup +from pathlib import Path + +stub_root = Path("circuitpython-stubs") +stubs = [p.relative_to(stub_root).as_posix() for p in stub_root.glob("*.pyi")] + +now = datetime.utcnow() +version = now.strftime("%Y.%m.%d") + +setup( + name="circuitpython-stubs", + description="PEP 561 type stubs for CircuitPython", + url="https://github.com/adafruit/circuitpython", + author="John Reese", + author_email="john@noswap.com", + version=version, + license="MIT", + package_data={"circuitpython-stubs": stubs}, + packages=["circuitpython-stubs"], + setup_requires=["setuptools>=38.6.0"], +) \ No newline at end of file -- cgit v1.2.3 From f831d8443598f624ffca40e33448233987dddf5f Mon Sep 17 00:00:00 2001 From: John Reese Date: Sun, 2 Jun 2019 15:08:48 -0700 Subject: Update maintainer/email for stub package, bump rst2pyi dep --- requirements-dev.txt | 2 +- setup.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 278fe7fd5..7cd491ade 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1 +1 @@ -rst2pyi=0.1.0 \ No newline at end of file +rst2pyi>=0.3.0 diff --git a/setup.py b/setup.py index 780d97152..1e0d81da3 100644 --- a/setup.py +++ b/setup.py @@ -12,11 +12,11 @@ setup( name="circuitpython-stubs", description="PEP 561 type stubs for CircuitPython", url="https://github.com/adafruit/circuitpython", - author="John Reese", - author_email="john@noswap.com", + maintainer="CircuitPythonistas", + author_email="circuitpython@adafruit.com", version=version, license="MIT", package_data={"circuitpython-stubs": stubs}, packages=["circuitpython-stubs"], setup_requires=["setuptools>=38.6.0"], -) \ No newline at end of file +) -- cgit v1.2.3 From e8521c83797f0e54dca4ebc4750224c84a31457e Mon Sep 17 00:00:00 2001 From: John Reese Date: Sun, 2 Jun 2019 15:12:29 -0700 Subject: Clean up egg-info directory as well --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dc546279d..09fbf9c1a 100644 --- a/Makefile +++ b/Makefile @@ -67,7 +67,7 @@ help: clean: rm -rf $(BUILDDIR)/* - rm -rf $(STUBDIR) $(DISTDIR) + rm -rf $(STUBDIR) $(DISTDIR) *.egg-info html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html -- cgit v1.2.3