mirror of
https://github.com/pocketpy/pocketpy
synced 2025-11-08 04:30:17 +00:00
Compare commits
No commits in common. "e96f1e92bdf22bc9d1818538b519adca3e4a2e6d" and "6a20133587a5bbea9615fc715aa0088ec8a469e4" have entirely different histories.
e96f1e92bd
...
6a20133587
207
.github/workflows/main.yml
vendored
Normal file
207
.github/workflows/main.yml
vendored
Normal file
@ -0,0 +1,207 @@
|
||||
name: build
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
- 'web/**'
|
||||
- '**.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
- 'web/**'
|
||||
- '**.md'
|
||||
jobs:
|
||||
build_win32_amalgamated:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: Compile
|
||||
shell: powershell
|
||||
run: |
|
||||
python amalgamate.py
|
||||
cd amalgamated
|
||||
cl.exe /std:c11 /utf-8 /Ox /I. pocketpy.c main.c /link /out:pkpy.exe
|
||||
build_win32:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: Compile
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p output/x86_64
|
||||
python cmake_build.py
|
||||
cp main.exe output/x86_64
|
||||
cp pocketpy.dll output/x86_64
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: windows
|
||||
path: output
|
||||
- name: Unit Test
|
||||
run: python scripts/run_tests.py
|
||||
- name: Benchmark
|
||||
run: python scripts/run_tests.py benchmark
|
||||
build_linux:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- name: Setup Clang
|
||||
uses: egor-tensin/setup-clang@v1
|
||||
with:
|
||||
version: 15
|
||||
platform: x64
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get install -y libclang-rt-15-dev
|
||||
- name: Unit Test with Coverage
|
||||
run: bash run_tests.sh
|
||||
- name: Upload coverage reports to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
directory: .coverage
|
||||
if: github.ref == 'refs/heads/main'
|
||||
- name: Compile and Test
|
||||
run: |
|
||||
mkdir -p output/x86_64
|
||||
python cmake_build.py
|
||||
python scripts/run_tests.py
|
||||
cp main output/x86_64
|
||||
cp libpocketpy.so output/x86_64
|
||||
env:
|
||||
CC: clang
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: linux
|
||||
path: output
|
||||
- name: Benchmark
|
||||
run: python scripts/run_tests.py benchmark
|
||||
build_linux_x86:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- name: Setup Alpine Linux for aarch64
|
||||
uses: jirutka/setup-alpine@v1
|
||||
with:
|
||||
arch: x86
|
||||
packages: gcc g++ make cmake libc-dev linux-headers python3
|
||||
- name: Build and Test
|
||||
run: |
|
||||
uname -m
|
||||
python cmake_build.py
|
||||
python scripts/run_tests.py
|
||||
python scripts/run_tests.py benchmark
|
||||
shell: alpine.sh --root {0}
|
||||
build_darwin:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- name: Compile and Test
|
||||
run: |
|
||||
python cmake_build.py
|
||||
python scripts/run_tests.py
|
||||
- name: Benchmark
|
||||
run: python scripts/run_tests.py benchmark
|
||||
- name: Test Amalgamated Build
|
||||
run: python amalgamate.py
|
||||
build_android:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- uses: nttld/setup-ndk@v1
|
||||
id: setup-ndk
|
||||
with:
|
||||
ndk-version: r23
|
||||
local-cache: false
|
||||
add-to-path: false
|
||||
- name: Compile Shared Library
|
||||
run: |
|
||||
bash build_android.sh arm64-v8a
|
||||
bash build_android.sh armeabi-v7a
|
||||
bash build_android.sh x86_64
|
||||
|
||||
mkdir -p output/arm64-v8a
|
||||
mkdir -p output/armeabi-v7a
|
||||
mkdir -p output/x86_64
|
||||
|
||||
cp build/android/arm64-v8a/libpocketpy.so output/arm64-v8a
|
||||
cp build/android/armeabi-v7a/libpocketpy.so output/armeabi-v7a
|
||||
cp build/android/x86_64/libpocketpy.so output/x86_64
|
||||
env:
|
||||
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: android
|
||||
path: output
|
||||
build_ios:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
- name: Compile Frameworks
|
||||
run: |
|
||||
git clone https://github.com/leetal/ios-cmake --depth 1 ~/ios-cmake
|
||||
bash build_ios.sh
|
||||
mkdir -p output
|
||||
cp -r build/pocketpy.xcframework output/pocketpy.xcframework
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ios
|
||||
path: output
|
||||
|
||||
merge:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ build_win32, build_linux, build_darwin, build_android, build_ios ]
|
||||
steps:
|
||||
- name: "Create output directory"
|
||||
run: "mkdir $GITHUB_WORKSPACE/output"
|
||||
|
||||
- name: "Merge win32"
|
||||
uses: actions/download-artifact@v4.1.7
|
||||
with:
|
||||
name: windows
|
||||
path: $GITHUB_WORKSPACE/output/windows
|
||||
|
||||
- name: "Merge linux"
|
||||
uses: actions/download-artifact@v4.1.7
|
||||
with:
|
||||
name: linux
|
||||
path: $GITHUB_WORKSPACE/output/linux
|
||||
|
||||
# - name: "Merge darwin"
|
||||
# uses: actions/download-artifact@v4.1.7
|
||||
# with:
|
||||
# name: macos
|
||||
# path: $GITHUB_WORKSPACE/output/macos
|
||||
|
||||
- name: "Merge android"
|
||||
uses: actions/download-artifact@v4.1.7
|
||||
with:
|
||||
name: android
|
||||
path: $GITHUB_WORKSPACE/output/android
|
||||
|
||||
- name: "Merge ios"
|
||||
uses: actions/download-artifact@v4.1.7
|
||||
with:
|
||||
name: ios
|
||||
path: $GITHUB_WORKSPACE/output/ios
|
||||
|
||||
- name: "Upload merged artifact"
|
||||
uses: actions/upload-artifact@v4.3.3
|
||||
with:
|
||||
name: all-in-one
|
||||
path: $GITHUB_WORKSPACE/output
|
||||
76
.github/workflows/pybind11.yml
vendored
Normal file
76
.github/workflows/pybind11.yml
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
name: PKBIND Build and Test
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- "docs/**"
|
||||
- "web/**"
|
||||
- "**.md"
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- "docs/**"
|
||||
- "web/**"
|
||||
- "**.md"
|
||||
|
||||
jobs:
|
||||
build_linux:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up GCC
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc g++
|
||||
|
||||
- name: Set up CMake
|
||||
uses: jwlawson/actions-setup-cmake@v1.10
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cd include/pybind11/tests
|
||||
cmake -B build
|
||||
cmake --build build --config Release --parallel
|
||||
./build/PKBIND_TEST
|
||||
|
||||
build_win:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up MSVC
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
|
||||
- name: Set up CMake
|
||||
uses: jwlawson/actions-setup-cmake@v1.10
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cd include\pybind11\tests
|
||||
cmake -B build
|
||||
cmake --build build --config Release --parallel
|
||||
build\Release\PKBIND_TEST.exe
|
||||
|
||||
build_mac:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Clang
|
||||
run: |
|
||||
brew install llvm
|
||||
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.zshrc
|
||||
source ~/.zshrc
|
||||
|
||||
- name: Set up CMake
|
||||
uses: jwlawson/actions-setup-cmake@v1.10
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
cd include/pybind11/tests
|
||||
cmake -B build -DENABLE_TEST=ON
|
||||
cmake --build build --config Release --parallel
|
||||
./build/PKBIND_TEST
|
||||
42
.github/workflows/website.yml
vendored
Normal file
42
.github/workflows/website.yml
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
name: website
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
###################################################
|
||||
- uses: actions/setup-node@v3.1.1
|
||||
- name: Retype build
|
||||
run: |
|
||||
python scripts/gen_docs.py
|
||||
cd docs
|
||||
npm install retypeapp -g
|
||||
retype build
|
||||
###################################################
|
||||
- name: Setup emsdk
|
||||
uses: mymindstorm/setup-emsdk@v12
|
||||
with:
|
||||
version: latest
|
||||
actions-cache-folder: 'emsdk-cache'
|
||||
- name: Compile
|
||||
run: |
|
||||
bash build_web.sh
|
||||
mv web docs/.retype/static
|
||||
###################################################
|
||||
- uses: crazy-max/ghaction-github-pages@v3
|
||||
with:
|
||||
target_branch: gh-pages
|
||||
build_dir: docs/.retype
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
if: github.ref == 'refs/heads/main'
|
||||
BIN
.github/workflows/workflows.zip
vendored
BIN
.github/workflows/workflows.zip
vendored
Binary file not shown.
@ -6,30 +6,17 @@
|
||||
#include "pocketpy/common/sstream.h"
|
||||
#include "pocketpy/interpreter/vm.h"
|
||||
|
||||
typedef struct c11_array2d_like {
|
||||
typedef struct c11_array2d {
|
||||
py_TValue* data; // slots
|
||||
int n_cols;
|
||||
int n_rows;
|
||||
int numel;
|
||||
py_Ref (*f_get)(struct c11_array2d_like* self, int col, int row);
|
||||
bool (*f_set)(struct c11_array2d_like* self, int col, int row, py_Ref value);
|
||||
} c11_array2d_like;
|
||||
|
||||
typedef struct c11_array2d_like_iterator {
|
||||
c11_array2d_like* array;
|
||||
int j;
|
||||
int i;
|
||||
} c11_array2d_like_iterator;
|
||||
|
||||
typedef struct c11_array2d {
|
||||
c11_array2d_like header;
|
||||
py_TValue* data; // slots
|
||||
} c11_array2d;
|
||||
|
||||
typedef struct c11_array2d_view {
|
||||
c11_array2d_like header;
|
||||
c11_array2d_like* array;
|
||||
c11_vec2i origin;
|
||||
} c11_array2d_view;
|
||||
typedef struct c11_array2d_iterator {
|
||||
c11_array2d* array;
|
||||
int index;
|
||||
} c11_array2d_iterator;
|
||||
|
||||
c11_array2d* py_newarray2d(py_OutRef out, int n_cols, int n_rows);
|
||||
|
||||
|
||||
@ -737,11 +737,8 @@ enum py_PredefinedTypes {
|
||||
tp_vec3i,
|
||||
tp_mat3x3,
|
||||
/* array2d */
|
||||
tp_array2d_like,
|
||||
tp_array2d_like_iterator,
|
||||
tp_array2d,
|
||||
tp_array2d_view,
|
||||
tp_chunked_array2d,
|
||||
tp_array2d_iterator,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
from typing import Callable, Literal, overload, Iterator
|
||||
from typing import Callable, Any, Generic, TypeVar, Literal, overload, Iterator
|
||||
from linalg import vec2i
|
||||
|
||||
Neighborhood = Literal['Moore', 'von Neumann']
|
||||
@ -13,8 +13,6 @@ class array2d_like[T]:
|
||||
@property
|
||||
def height(self) -> int: ...
|
||||
@property
|
||||
def shape(self) -> vec2i: ...
|
||||
@property
|
||||
def numel(self) -> int: ...
|
||||
|
||||
@overload
|
||||
@ -22,42 +20,53 @@ class array2d_like[T]:
|
||||
@overload
|
||||
def is_valid(self, pos: vec2i) -> bool: ...
|
||||
|
||||
def get[R](self, col: int, row: int, default: R = None) -> T | R:
|
||||
"""Get the value at the given position.
|
||||
|
||||
If the position is out of bounds, return the default value.
|
||||
"""
|
||||
|
||||
def render(self) -> str: ...
|
||||
|
||||
def all(self: array2d_like[bool]) -> bool: ...
|
||||
def any(self: array2d_like[bool]) -> bool: ...
|
||||
|
||||
def map[R](self, f: Callable[[T], R]) -> array2d[R]: ...
|
||||
def apply(self, f: Callable[[T], T]) -> None: ...
|
||||
def copy(self) -> 'array2d[T]': ...
|
||||
|
||||
def __eq__(self, other: object) -> array2d[bool]: ... # type: ignore
|
||||
def __ne__(self, other: object) -> array2d[bool]: ... # type: ignore
|
||||
def __iter__(self) -> Iterator[tuple[vec2i, T]]: ...
|
||||
def __repr__(self) -> str: ...
|
||||
|
||||
@overload
|
||||
def __getitem__(self, index: vec2i) -> T: ...
|
||||
@overload
|
||||
def __getitem__(self, index: tuple[int, int]) -> T: ...
|
||||
@overload
|
||||
def __getitem__(self, index: tuple[slice, slice]) -> array2d_view[T]: ...
|
||||
@overload
|
||||
def __getitem__(self, mask: array2d_like[bool]) -> list[T]: ...
|
||||
@overload
|
||||
def __setitem__(self, index: vec2i, value: T): ...
|
||||
@overload
|
||||
def __setitem__(self, index: tuple[int, int], value: T): ...
|
||||
|
||||
|
||||
class array2d_view[T](array2d_like[T]):
|
||||
origin: vec2i
|
||||
|
||||
|
||||
class array2d[T](array2d_like[T]):
|
||||
def __new__(cls, n_cols: int, n_rows: int, default: T | Callable[[vec2i], T] | None = None): ...
|
||||
def __eq__(self, other: object) -> array2d[bool]: ... # type: ignore
|
||||
def __ne__(self, other: object) -> array2d[bool]: ... # type: ignore
|
||||
def __iter__(self) -> Iterator[tuple[vec2i, T]]: ...
|
||||
|
||||
def get[R](self, col: int, row: int, default: R = None) -> T | R:
|
||||
"""Gets the value at the given position. If the position is out of bounds, return the default value."""
|
||||
|
||||
@overload
|
||||
def __setitem__(self, index: tuple[slice, slice], value: T | 'array2d_like[T]'): ...
|
||||
def __getitem__(self, index: tuple[slice, slice]) -> array2d[T]: ...
|
||||
@overload
|
||||
def __setitem__(self, mask: array2d_like[bool], value: T): ...
|
||||
def __getitem__(self, mask: array2d[bool]) -> list[T]: ...
|
||||
@overload
|
||||
def __setitem__(self, index: tuple[slice, slice], value: int | float | str | bool | None | 'array2d[T]'): ...
|
||||
@overload
|
||||
def __setitem__(self, mask: array2d[bool], value: T): ...
|
||||
|
||||
def map[R](self, f: Callable[[T], R]) -> array2d[R]: ...
|
||||
def copy(self) -> 'array2d[T]': ...
|
||||
|
||||
def fill_(self, value: T) -> None: ...
|
||||
def apply_(self, f: Callable[[T], T]) -> None: ...
|
||||
def copy_(self, other: array2d[T] | list[T]) -> None: ...
|
||||
|
||||
def render(self) -> str: ...
|
||||
|
||||
def all(self: array2d[bool]) -> bool: ...
|
||||
def any(self: array2d[bool]) -> bool: ...
|
||||
|
||||
@staticmethod
|
||||
def fromlist(data: list[list[T]]) -> array2d[T]: ...
|
||||
def tolist(self) -> list[list[T]]: ...
|
||||
|
||||
# algorithms
|
||||
def count(self, value: T) -> int:
|
||||
@ -72,7 +81,7 @@ class array2d_like[T]:
|
||||
Returns a tuple `(x, y, width, height)` or raise `ValueError` if the value is not found.
|
||||
"""
|
||||
|
||||
def convolve(self: array2d_like[int], kernel: array2d_like[int], padding: int) -> array2d[int]:
|
||||
def convolve(self: array2d[int], kernel: array2d[int], padding: int) -> array2d[int]:
|
||||
"""Convolves the array with the given kernel."""
|
||||
|
||||
def get_connected_components(self, value: T, neighborhood: Neighborhood) -> tuple[array2d[int], int]:
|
||||
@ -83,24 +92,6 @@ class array2d_like[T]:
|
||||
"""
|
||||
|
||||
|
||||
class array2d_view[T](array2d_like[T]):
|
||||
@property
|
||||
def origin(self) -> vec2i: ...
|
||||
|
||||
|
||||
class array2d[T](array2d_like[T]):
|
||||
def __new__(
|
||||
cls,
|
||||
n_cols: int,
|
||||
n_rows: int,
|
||||
default: T | Callable[[vec2i], T] | None = None
|
||||
): ...
|
||||
|
||||
@staticmethod
|
||||
def fromlist(data: list[list[T]]) -> array2d[T]: ...
|
||||
def tolist(self) -> list[list[T]]: ...
|
||||
|
||||
|
||||
class chunked_array2d[T, TContext]:
|
||||
def __init__(
|
||||
self,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user