-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass at building a stubs package from the sources
This uses mypy's stubgen to derive stubs from the source code, then wraps the generated stubs in a minimal Python package.
- Loading branch information
1 parent
ca64aaa
commit 8e23e3c
Showing
6 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Build Python Stubs | ||
|
||
# TODO: work out where this should actually run | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
build-python-stubs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
cache: pip | ||
cache-dependency-path: resources/python_stubs/requirements.txt | ||
|
||
- name: Install Dependencies | ||
run: | | ||
pip install -r resources/python_stubs/requirements.txt | ||
- name: Build the package | ||
run: | | ||
resources/python_stubs/build.sh | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: dist | ||
path: resources/python_stubs/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
*.egg-info | ||
|
||
controller-stubs/*.pyi | ||
|
||
build | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Webots Stubs | ||
|
||
Typing stubs for [Webots][webots]' `controller` package. | ||
|
||
These are auto-generated from the Python API which comes with Webots. | ||
|
||
[webots]: https://www.cyberbotics.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
cd $(dirname $0) | ||
|
||
rm -rf controller-stubs | ||
|
||
stubgen ../../lib/controller/python/controller --output . | ||
|
||
mv controller controller-stubs | ||
|
||
python setup.py sdist bdist_wheel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mypy | ||
wheel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from pathlib import Path | ||
|
||
from setuptools import setup # type: ignore[import] | ||
|
||
long_description = (Path(__file__).parent / 'README.md').read_text() | ||
|
||
setup( | ||
name='webots-stubs', | ||
version='0.1.0', # TODO: version with the Webots version number? | ||
url='https://www.cyberbotics.com/', | ||
project_urls={ | ||
'Issue tracker': 'https://github.com/cyberbotics/webots/issues', | ||
'Source Code': 'https://github.com/cyberbotics/webots', | ||
}, | ||
description="Type stubs for Webots' 'controller' package.", | ||
long_description=long_description, | ||
long_description_content_type='text/markdown', | ||
|
||
package_data={'controller-stubs': ['*.pyi']}, | ||
packages=['controller-stubs'], | ||
|
||
license='Apache 2.0', | ||
|
||
classifiers=[ | ||
'Development Status :: 2 - Pre-Alpha', | ||
'Natural Language :: English', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 3 :: Only', | ||
'Programming Language :: Python :: 3.7', | ||
'Programming Language :: Python :: 3.8', | ||
'Programming Language :: Python :: 3.9', | ||
'Programming Language :: Python :: 3.10', | ||
'Programming Language :: Python :: 3.11', | ||
'Topic :: Software Development', | ||
], | ||
) |