Skip to content

Commit

Permalink
refactor: Use apigen to generate cython.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Jan 7, 2024
1 parent 3a9e66b commit c3690d8
Show file tree
Hide file tree
Showing 21 changed files with 1,586 additions and 611 deletions.
17 changes: 3 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
branches: [master]

jobs:
common:
uses: TokTok/ci-tools/.github/workflows/common-ci.yml@master

# build:
# name: python-${{ matrix.version }}
# runs-on: ubuntu-latest
Expand Down Expand Up @@ -62,17 +65,3 @@ jobs:
- uses: actions/checkout@v2
- name: Build
run: docker build -t pytox .

# clang-analyze:
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v2
# - name: Install
# run: |
# sudo apt update
# sudo apt install -y --no-install-recommends --no-install-suggests libtoxcore-dev
# - name: Build
# run: |
# clang -fsyntax-only pytox/*.c -Werror -Weverything -Wno-reserved-id-macro -Wno-documentation-deprecated-sync -Wno-shorten-64-to-32 -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-conversion -Wno-padded -Wno-conversion $(pkg-config --cflags-only-I python3)
# clang --analyze pytox/*.c $(pkg-config --cflags-only-I python3)
42 changes: 27 additions & 15 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,37 @@ load("//tools/project:build_defs.bzl", "project")

project(license = "gpl3-https")

genrule(
name = "pytox/core",
srcs = [
"pytox/src/core.pyx",
"//c-toxcore:tox/tox.h",
],
outs = ["pytox/core.pyx"],
cmd = "$(location //py_toxcore_c/tools:gen_api) $(location pytox/src/core.pyx) $(location //c-toxcore:tox/tox.h) > $@",
tools = ["//py_toxcore_c/tools:gen_api"],
)
#genrule(
# name = "pytox/core",
# srcs = [
# "pytox/src/core.pyx",
# "//c-toxcore:tox/tox.h",
# ],
# outs = ["pytox/core.pyx"],
# cmd = "$(location //py_toxcore_c/tools:gen_api) $(location pytox/src/core.pyx) $(location //c-toxcore:tox/tox.h) > $@",
# tools = ["//py_toxcore_c/tools:gen_api"],
#)

pyx_library(
name = "pytox",
srcs = [
"pytox/av.pyx",
"pytox/core.pyx",
],
srcs = glob([
"pytox/**/*.pxd",
"pytox/**/*.pyx",
]),
cdeps = ["//c-toxcore"],
cython_directives = {"language_level": "3"},
cython_directives = {
"embedsignature": "True",
"embedsignature.format": "python",
"language_level": "3",
},
tags = ["no-cross"],
visibility = ["//visibility:public"],
)

genrule(
name = "pytox_stubs",
outs = [mod[:-4] + ".pyi" for mod in glob(["pytox/**/*.pyx"])],
cmd = "$(location //py_toxcore_c/tools:stubgen) -o $(GENDIR)/py_toxcore_c" + " ".join([" -m %s" % mod[:-4].replace("/", ".") for mod in glob(["pytox/**/*.pyx"])]),
tags = ["manual"],
tools = ["//py_toxcore_c/tools:stubgen"],
)
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ RUN git clone --depth=1 --recursive https://github.com/TokTok/c-toxcore /build/c
&& ldconfig

COPY pytox /build/pytox
COPY tools /build/tools

RUN mypy --strict tools/gen_api.py \
&& tools/gen_api.py pytox/src/core.pyx /usr/local/include/tox/tox.h > pytox/core.pyx \
&& cython pytox/av.pyx pytox/core.pyx
RUN cython -I. $(find pytox -name "*.pyx")

COPY setup.py /build/
RUN python3 setup.py install \
Expand Down
6 changes: 0 additions & 6 deletions pytox/av.pyx

This file was deleted.

233 changes: 0 additions & 233 deletions pytox/src/core.pyx

This file was deleted.

Loading

0 comments on commit c3690d8

Please sign in to comment.