Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure GitHub Actions to build binary wheels and upload to pypi #117

Merged
merged 27 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d45ef1e
Configure GitHub Actions to build binary wheels for pypi
Akuli Aug 19, 2022
c65192f
Merge remote-tracking branch 'origin/master' into pypiwheels
Akuli Sep 7, 2022
139c2c5
Copy config from other repository
Akuli Sep 7, 2022
a8ce724
Delete old publish script
Akuli Sep 7, 2022
4cdf587
A pile of changes. Still need to test all this
Akuli Sep 7, 2022
bc28dd1
Update wheels.yml
Akuli Sep 7, 2022
5ed541e
TEMPORARILY delete ci.yml
Akuli Sep 7, 2022
66bb76f
TEMPORARILY replace slow things with a zip file of previous build
Akuli Sep 7, 2022
d670a46
Try dis
Akuli Sep 7, 2022
66d9af3
Revert "Try dis"
Akuli Sep 7, 2022
a4b0ebb
TEMPORARILY change package name
Akuli Sep 7, 2022
636b144
fix
Akuli Sep 7, 2022
ae9e669
Revert "TEMPORARILY replace slow things with a zip file of previous b…
Akuli Sep 7, 2022
2964029
Give names to confusing pypi jobs
Akuli Sep 7, 2022
ca73f3e
Style nit
Akuli Sep 7, 2022
faa25ba
Revert "TEMPORARILY change package name"
Akuli Sep 7, 2022
c856d52
Revert "TEMPORARILY delete ci.yml"
Akuli Sep 7, 2022
82cf80d
TEMPORARILY change package name
Akuli Sep 7, 2022
90c8921
TEMPORARILY bump version
Akuli Sep 7, 2022
eab8834
Name binary better
Akuli Sep 7, 2022
eff5fda
Let's try this
Akuli Sep 7, 2022
c45c96f
Revert "TEMPORARILY bump version"
Akuli Sep 7, 2022
61b634a
Revert "TEMPORARILY change package name"
Akuli Sep 7, 2022
9e85a80
Cleanups
Akuli Sep 7, 2022
fa50952
Rename
Akuli Sep 7, 2022
17e9b40
Move comment
Akuli Sep 7, 2022
f963f48
One or more digits
Akuli Aug 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
on:
push:
tags:
- 'v[0-9]+'
- 'test-v[0-9]*' # Uploads to https://test.pypi.org/project/tree-sitter/

jobs:
build-sdist:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: python setup.py sdist
- uses: actions/upload-artifact@v2
with:
name: dist
path: ./dist/*

build-wheels:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-11, windows-2022]

steps:
- uses: actions/checkout@v3
with:
submodules: true

- uses: actions/setup-python@v4
with:
python-version: '3.10'

- if: ${{ startsWith(matrix.os, 'windows') }}
run: script\fetch-fixtures.cmd
- if: ${{ !startsWith(matrix.os, 'windows') }}
run: script/fetch-fixtures

# Build wheels
- run: pip install cibuildwheel==2.9.0
- run: python -m cibuildwheel --output-dir dist
env:
CIBW_TEST_COMMAND: python -m unittest discover -s {package}/tests
CIBW_ARCHS_MACOS: x86_64 arm64

# Make wheels downloadable from GitHub UI and from the pypi step
- uses: actions/upload-artifact@v2
with:
name: dist
path: ./dist/*.whl

release:
runs-on: ubuntu-latest
needs: [build-sdist, build-wheels]
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist
- run: ls -la
- run: ls -la dist

# https://stackoverflow.com/a/58478262
- if: ${{ startsWith(github.ref, 'refs/tags/test-v') }}
name: 'Upload to test.pypi.org'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- if: ${{ startsWith(github.ref, 'refs/tags/v') }}
name: 'Upload to pypi.org'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
12 changes: 0 additions & 12 deletions script/publish

This file was deleted.

12 changes: 10 additions & 2 deletions tests/test_tree_sitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@
from tree_sitter import Language, Parser

LIB_PATH = path.join("build", "languages.so")

# cibuildwheel uses a funny working directory when running tests.
# This is by design, this way tests import whatever is installed and not from the project.
#
# The languages binary is still relative to current working directory to prevent reusing
# a 32-bit languages binary in a 64-bit build. The working directory is clean every time.
project_root = path.dirname(path.dirname(path.abspath(__file__)))
Language.build_library(
LIB_PATH,
[
path.join("tests", "fixtures", "tree-sitter-python"),
path.join("tests", "fixtures", "tree-sitter-javascript"),
path.join(project_root, "tests", "fixtures", "tree-sitter-python"),
path.join(project_root, "tests", "fixtures", "tree-sitter-javascript"),
],
)

PYTHON = Language(LIB_PATH, "python")
JAVASCRIPT = Language(LIB_PATH, "javascript")

Expand Down