Skip to content

Commit

Permalink
Change to manual trigger update stub
Browse files Browse the repository at this point in the history
  • Loading branch information
laggykiller committed Sep 23, 2023
1 parent 89351e0 commit a0bcb88
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Update stub

on:
push:
on: workflow_dispatch

jobs:
stubgen:
Expand Down
42 changes: 23 additions & 19 deletions update_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@
import shutil
import zipfile

py_bin = shutil.which('python3')
if not py_bin:
py_bin = shutil.which('python')
def main():
py_bin = shutil.which('python3')
if not py_bin:
py_bin = shutil.which('python')

shutil.rmtree('./dist', ignore_errors=True)
os.system(py_bin + ' -m build .')
shutil.rmtree('./dist', ignore_errors=True)
os.system(py_bin + ' -m build .')

for zip_file in os.listdir('dist'):
if os.path.splitext(zip_file)[1] != '.whl':
continue
zip_path = os.path.join('dist', zip_file)
with zipfile.ZipFile(zip_path, mode="r") as archive:
for file in archive.namelist():
if os.path.splitext(file)[1] != '.pyi':
continue
dest_path = os.path.join('src-python', file)
dest_dir = os.path.split(dest_path)[0]
if not os.path.isdir(dest_dir):
os.makedirs(dest_dir)
with open(dest_path, 'wb+') as f:
f.write(archive.read(file))
for zip_file in os.listdir('dist'):
if os.path.splitext(zip_file)[1] != '.whl':
continue
zip_path = os.path.join('dist', zip_file)
with zipfile.ZipFile(zip_path, mode="r") as archive:
for file in archive.namelist():
if os.path.splitext(file)[1] != '.pyi':
continue
dest_path = os.path.join('src-python', file)
dest_dir = os.path.split(dest_path)[0]
if not os.path.isdir(dest_dir):
os.makedirs(dest_dir)
with open(dest_path, 'wb+') as f:
f.write(archive.read(file))

if __name__ == '__main__':
main()

0 comments on commit a0bcb88

Please sign in to comment.