diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e126673 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,158 @@ +name: CI + +on: + push: + branches: + - main + tags: + - "*.*.*" + pull_request: + +jobs: + linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Cache + uses: Swatinem/rust-cache@v2 + - uses: messense/maturin-action@v1 + with: + manylinux: auto + command: build + args: --release -o dist --find-interpreter + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + # Docker with Apple Silicon + manylinux-aarch64: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Cache + uses: Swatinem/rust-cache@v2 + - uses: messense/maturin-action@v1 + with: + target: aarch64-unknown-linux-gnu + command: build + args: --release -o dist --find-interpreter + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + # ARM7 + armv7: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Cache + uses: Swatinem/rust-cache@v2 + - uses: messense/maturin-action@v1 + with: + target: armv7 + command: build + args: --release -o dist --find-interpreter + container: messense/manylinux_2_24-cross:armv7 + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + musllinux-x86_64: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Cache + uses: Swatinem/rust-cache@v2 + - uses: messense/maturin-action@v1 + with: + target: x86_64 + command: build + args: --release -o dist --find-interpreter + manylinux: musllinux_1_1 + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + musllinux-aarch64: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Cache + uses: Swatinem/rust-cache@v2 + - uses: messense/maturin-action@v1 + with: + target: aarch64 + command: build + args: --release -o dist --find-interpreter + manylinux: musllinux_1_1 + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - name: Cache + uses: Swatinem/rust-cache@v2 + - uses: messense/maturin-action@v1 + with: + command: build + args: --release -o dist --universal2 --find-interpreter + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - name: Cache + uses: Swatinem/rust-cache@v2 + - uses: messense/maturin-action@v1 + with: + command: build + args: --release -o dist --universal2 --find-interpreter + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + # release: + # name: Release + # runs-on: ubuntu-latest + # if: "startsWith(github.ref, 'refs/tags/')" + # needs: + # [ + # macos, + # linux, + # windows, + # manylinux-aarch64, + # armv7, + # musllinux-x86_64, + # musllinux-aarch64, + # ] + # steps: + # - uses: actions/download-artifact@v3 + # with: + # name: wheels + # - name: Publish to PyPI + # uses: messense/maturin-action@v1 + # env: + # MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + # with: + # command: upload + # args: --skip-existing * diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml deleted file mode 100644 index 1dc208c..0000000 --- a/.github/workflows/rust.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Rust - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Build - run: cargo build --verbose diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4500b14 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,18 @@ +[build-system] +requires = ["maturin>=0.13,<0.14"] +build-backend = "maturin" + +[project] +name = "regex" +requires-python = ">=3.7" +classifiers = [ + "Programming Language :: Rust", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] +description = "A port of the Rust regex library to python for super speed linear matching." + +[project.urls] +"Source Code" = "https://github.com/litmus-web/Python-Regex" +Issues = "https://github.com/litmus-web/Python-Regex/issues" +Documentation = "https://github.com/litmus-web/Python-Regex" diff --git a/regex.pyi b/regex.pyi new file mode 100644 index 0000000..b79e07b --- /dev/null +++ b/regex.pyi @@ -0,0 +1,28 @@ +from typing import Optional, List + +from typing_extensions import Tuple + +class Regex(object): + ... + + def is_match(self, other: str) -> bool: ... + + def is_match_at(self, other: str, start: int) -> bool: ... + + def find(self, other: str) -> Optional[str]: ... + + def findall(self, other: str) -> List[str]: ... + + def all_captures(self, other: str) -> List[List[Optional[str]]]: ... + + def captures(self, other: str) -> Optional[List[Optional[str]]]: ... + + def matches(self, other: str) -> List[Tuple[int, int]]: ... + + +class RegexSet(object): + ... + + def is_match(self, other: str) -> bool: ... + + def find(self, other: str) -> List[int]: ... diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7af0c75 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +maturin +typing-extensions