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

[USING, DON'T MERGE THO] Enable Lexical-style parsing #1

Open
wants to merge 58 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
cf619fd
Set up tests
zswaff Mar 21, 2024
e606efe
Improve comments
zswaff Mar 21, 2024
4b1b72f
Update tests
zswaff Mar 27, 2024
d5785dc
Start implementing rust version and add JS version for reference
zswaff Apr 4, 2024
9441f3d
Set up python binding for direct function
zswaff May 6, 2024
bec43ee
Added parse_nested_xml_text_nodes test
ahonko May 21, 2024
59379af
Clean up
ahonko May 21, 2024
022f618
Removed playground.ts
ahonko May 22, 2024
c1623a9
Clean up lexical parsing XML text nodes
ahonko May 22, 2024
cc486a1
Clean up tests
ahonko May 22, 2024
c3582f6
Reverted non related changes in tests
ahonko May 22, 2024
0f64aeb
Moved parse_nested_xml_text_nodes test to y_doc module
ahonko May 22, 2024
ef62cbd
Polish
zswaff May 22, 2024
08bd33b
Tweak version to fix issues with pip resolution
zswaff May 22, 2024
fdbb622
Added more tests
ahonko May 24, 2024
bf079d5
Refactored, removed rust tests
ahonko May 25, 2024
6ce5e4d
Clean up
ahonko May 25, 2024
7bd93d4
Cleanup test
zswaff May 25, 2024
f2903d9
ypy reverse direction
ahonko May 31, 2024
54a944f
Tweak comments
zswaff May 31, 2024
7f93c38
Tweak again
zswaff May 31, 2024
ae613ba
Merge pull request #2 from its-dart/ahonko/DA-54-ypy-reverse-direction
zswaff May 31, 2024
d8d5aa8
ypy enable ints and nulls
ahonko Jun 4, 2024
712cb3a
Merge pull request #3 from its-dart/ahonko/DA-148-ypy-enable-ints-and…
zswaff Jun 4, 2024
c61b1c7
Update version in Cargo.toml
zswaff Jun 4, 2024
8a4c454
ypy use XmlText rather than XmlElement for tree
ahonko Jun 10, 2024
f9d0507
Clean up
ahonko Jun 10, 2024
627e0ef
Clean up
ahonko Jun 10, 2024
f8359b2
Merge pull request #4 from its-dart/ahonko/DA-159-ypy-use-XmlText-rat…
zswaff Jun 10, 2024
f9732ab
Update Cargo.toml
zswaff Jun 10, 2024
c6e6f17
Revert BigInt stuff
zswaff Jun 10, 2024
93f432e
Simplify version
zswaff Jun 10, 2024
b9c796a
Merge pull request #5 from its-dart/zack/revert-bigint
zswaff Jun 10, 2024
c1accaf
Set up library workflow
zswaff Jul 16, 2024
ffa6bad
Update Cargo.toml
ahonko Jul 16, 2024
fcbd331
Install correct lib for testing
zswaff Jul 16, 2024
8b09e9a
Keep improving wheel build process
zswaff Jul 16, 2024
b1ec2a0
Bump version
zswaff Jul 16, 2024
3e21db2
Comment out macos tests
zswaff Jul 16, 2024
0161dbd
Remove all mac tests
zswaff Jul 16, 2024
c4519c7
Rename package
zswaff Jul 16, 2024
496a023
Bump version to get new y-crdt
zswaff Jul 17, 2024
d2b3a37
Revert package rename
zswaff Jul 17, 2024
a34b648
Bump pyo3 version
zswaff Jul 19, 2024
d519732
Bump pyo3 version
zswaff Jul 19, 2024
8002cea
Fix version
zswaff Jul 19, 2024
6720b0c
Create test
zswaff Jul 19, 2024
a2ecb74
Added parsing Element and Fragment XML nodes while processing Text node
ahonko Jul 19, 2024
8ec52e9
Fixed tests
ahonko Jul 19, 2024
52b1afc
Merge pull request #6 from its-dart/zack/parse-nested-elements
zswaff Jul 20, 2024
de73c6b
Bump version
zswaff Jul 20, 2024
e9d95e6
Attempt to enable pushing xml elements
zswaff Jul 31, 2024
9bc1a79
Bump 0.6.3-alpha.18 version
ahonko Mar 18, 2025
37c2e4f
Fix wheels GH workflow
ahonko Mar 18, 2025
8c97274
Fix and clean up wheels GH workflow
ahonko Mar 18, 2025
5a2341c
Added support for binary data in attributes (#7)
jonathon-love Mar 18, 2025
24019a2
Add node_modules to gitignore
ahonko Mar 18, 2025
f9ed0e5
Bump 0.6.3-alpha.19 version
ahonko Mar 18, 2025
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
171 changes: 25 additions & 146 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,82 +15,43 @@ env:
jobs:
macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: "3.11"
architecture: x64
- uses: dtolnay/rust-toolchain@stable
- name: Build wheels - x86_64
- name: Build wheels - ${{ matrix.target }}
uses: PyO3/maturin-action@v1
with:
target: x86_64
target: ${{ matrix.target }}
args: --release --out dist --sdist -i 3.7 3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9
- name: Test built wheel - x86_64
run: |
pip install y-py --no-index --find-links dist --force-reinstall
pip install pytest
pytest
- name: Build wheels - universal2
uses: PyO3/maturin-action@v1
with:
args: --release --target universal2-apple-darwin --out dist -i 3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9
- name: Test built wheel - universal2
run: |
pip install y-py --no-index --find-links dist --force-reinstall
pytest
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist

windows:
runs-on: windows-latest
name: windows (${{ matrix.platform.target }})
strategy:
matrix:
platform:
- target: x64
interpreter: 3.7 3.8 3.9 3.10 3.11
- target: x86
interpreter: 3.7 3.8 3.9 3.10 3.11
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
architecture: ${{ matrix.platform.target }}
- uses: dtolnay/rust-toolchain@stable
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist -i ${{ matrix.platform.interpreter }}
- name: Test built wheel
run: |
pip install y-py --no-index --find-links dist --force-reinstall
pip install pytest
pytest
- name: Upload wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4.6.0
with:
name: wheels
name: wheels-macos-${{ matrix.target }}
path: dist

linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, i686]
target: [x86_64]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: "3.11"
architecture: x64
- name: Build wheels
- name: Build wheels - ${{ matrix.target }}
uses: PyO3/maturin-action@v1
with:
rust-toolchain: stable
Expand All @@ -100,13 +61,13 @@ jobs:
- name: Test built wheel
if: matrix.target == 'x86_64'
run: |
pip install y-py --no-index --find-links dist --force-reinstall
pip install y-py-dart --no-index --find-links dist --force-reinstall
pip install pytest
pytest
- name: Upload wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4.6.0
with:
name: wheels
name: wheels-linux-${{ matrix.target }}
path: dist

linux-cross:
Expand All @@ -118,121 +79,39 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Build wheels
python-version: "3.11"
- name: Build wheels - ${{ matrix.target }}
uses: PyO3/maturin-action@v1
with:
rust-toolchain: stable
target: ${{ matrix.target }}
manylinux: auto
args: --release --out dist -i 3.7 3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9

- uses: uraimo/[email protected]
if: matrix.target != 'ppc64'
name: Test built wheel
with:
arch: ${{ matrix.target }}
distro: ubuntu20.04
githubToken: ${{ github.token }}
install: |
apt-get update
apt-get install -y --no-install-recommends python3 python3-pip
pip3 install -U pip pytest
run: |
pip3 install y-py --no-index --find-links dist/ --force-reinstall
pytest

- name: Upload wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4.6.0
with:
name: wheels
name: wheels-linux-cross-${{ matrix.target }}
path: dist

wasm:
runs-on: ubuntu-20.04
# Pyodide began supporting `micropip.install` from emscripten-compiled binary wheels
# in Pyodide 0.21.0 (Aug 2022), so no need to build wheels for versions before then.
# As of Nov 2022, the matrix for emscripten/python versions since then is simple.
# Update this matrix when new Pyodide versions come out that bump the Python interpreter
# or emscripten version. Ref: https://pyodide.org/en/stable/project/changelog.html
strategy:
matrix:
python-version: ["3.10.2"]
emscripten-version: ["3.1.14"]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install Rust
# if this isn't here, wasm wheel build fails with error: failed to run `rustc` to learn about target-specific information
uses: actions-rs/toolchain@v1
with:
# maturin build will generate args -Z link-native-libraries=no which is only accepted on nightly compiler
toolchain: nightly
profile: minimal
override: true
- name: Rustup add wasm32 target
# maturin build --target wasm32-unknown-emscripten requires rust to add that target first
run: rustup target add wasm32-unknown-emscripten
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v11
with:
version: ${{ matrix.emscripten-version }}
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: wasm32-unknown-emscripten
args: --release --out wasm_wheel --find-interpreter
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wasm_wheel
path: wasm_wheel

pypi-release:
name: Publish to Pypi on Release
name: Publish to PyPI on Release
runs-on: ubuntu-latest
needs:
- macos
- windows
- linux
- linux-cross
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4.1.8
with:
name: wheels
merge-multiple: true
path: dist
pattern: wheels-*
- uses: actions/setup-python@v2
- name: Publish to PyPi
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
pip install --upgrade twine
twine upload --skip-existing *

# Can't upload emscripten wheels to Pypi, see https://github.com/pypi/warehouse/issues/10416.
# For now, this will attach the binary wheels to the Release page in Github. Users can
# download those into a pyodide environment and micropip.install from there.
wasm-release:
name: Attach wasm wheel to Release
runs-on: ubuntu-latest
needs:
- wasm
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v3
with:
name: wasm_wheel

- name: Attach assets to Release
uses: softprops/action-gh-release@v1
with:
files: '*.whl'
# 'name' (release name) defaults to the tag ref in this action.
# If release naming pattern changes, will need to configure 'name' here.



twine upload --skip-existing dist/*
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ Cargo.lock
docs/_*
.DS_Store
*.pyc
dist
dist
node_modules
.venv
15 changes: 12 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "y-py"
version = "0.7.0-alpha.1"
version = "0.6.3-alpha.19"
rust-version = "1.72"
edition = "2021"

Expand All @@ -12,8 +12,17 @@ crate-type = ["cdylib"]

[dependencies]
lib0 = "0.16.10"
yrs = "0.16.10"
yrs = { git = "https://github.com/its-dart/y-crdt.git", branch = "v0.16.10" }

[dev-dependencies]
assert-json-diff = "2.0.2"
serde = { version = "1.0.136", features = ["derive"] }
serde_json = { version = "1.0.79", features = ["unbounded_depth"] }

[dependencies.pyo3]
version = "0.19.2"
version = "0.21.0"
# Make the extension-module feature optional and default.
# See https://pyo3.rs/v0.21.2/faq.html#i-cant-run-cargo-test-or-i-cant-build-in-a-cargo-workspace-im-having-linker-issues-like-symbol-not-found-or-undefined-reference-to-_pyexc_systemerror for more details
# extension-module = ["pyo3/extension-module"]
# default = ["extension-module"]
features = ["extension-module"]
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["maturin>=1.2.3,<2"]
build-backend = "maturin"

[project]
name = "y-py"
name = "y-py-dart"
description = "Python bindings for the Y-CRDT built from yrs (Rust)"
license = { file = "LICENSE" }
authors = [
Expand All @@ -30,10 +30,10 @@ classifiers = [
]

[project.urls]
Homepage = "https://github.com/y-crdt/ypy"
Source = "https://github.com/y-crdt/ypy"
Issues = "https://github.com/y-crdt/ypy/issues"
Pypi = "https://pypi.org/project/y-py"
Homepage = "https://github.com/its-dart/ypy"
Source = "https://github.com/its-dart/ypy"
Issues = "https://github.com/its-dart/ypy/issues"
Pypi = "https://pypi.org/project/y-py-dart"

[tool.hatch.envs.test]
dependencies = ["pytest", "maturin"]
Expand Down
5 changes: 5 additions & 0 deletions src/json_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ impl<'a> JsonBuildable for CompatiblePyType<'a> {

buffer.push_str("]");
}
CompatiblePyType::ByteArray(bytes) => {
return Err(PyTypeError::new_err(
"Binary objects cannot be converted to JSON format"
));
}
CompatiblePyType::Dict(dict) => {
buffer.push_str("{");
let length = dict.len();
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![recursion_limit = "512"]

use pyo3::prelude::*;
use pyo3::wrap_pyfunction;
mod json_builder;
Expand Down
1 change: 1 addition & 0 deletions src/shared_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub enum CompatiblePyType<'a> {
String(&'a pytypes::PyString),
List(&'a pytypes::PyList),
Dict(&'a pytypes::PyDict),
ByteArray(&'a pytypes::PyByteArray),
YType(YPyType<'a>),
None,
}
Expand Down
7 changes: 7 additions & 0 deletions src/type_conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ impl<'a> TryFrom<&'a PyAny> for CompatiblePyType<'a> {
Ok(Self::List(list))
} else if let Ok(dict) = py_any.downcast::<pytypes::PyDict>() {
Ok(Self::Dict(dict))
} else if let Ok(bytes) = py_any.downcast::<pytypes::PyByteArray>() {
Ok(Self::ByteArray(bytes))
} else if let Ok(v) = YPyType::try_from(py_any) {
Ok(Self::YType(v))
} else {
Expand Down Expand Up @@ -259,6 +261,7 @@ impl<'a> From<CompatiblePyType<'a>> for PyObject {
CompatiblePyType::String(s) => s.into(),
CompatiblePyType::List(list) => list.into(),
CompatiblePyType::Dict(dict) => dict.into(),
CompatiblePyType::ByteArray(bytes) => bytes.into(),
CompatiblePyType::YType(y_type) => y_type.into(),
CompatiblePyType::None => Python::with_gil(|py| py.None()),
}
Expand Down Expand Up @@ -339,6 +342,10 @@ impl<'a> TryFrom<CompatiblePyType<'a>> for Any {
.collect();
result.map(|res| Any::Map(Box::new(res)))
},
CompatiblePyType::ByteArray(b) => {
let bytes: Vec<u8> = b.extract()?;
Ok(Any::Buffer(bytes.into_boxed_slice()))
}
CompatiblePyType::None => Ok(Any::Null),
CompatiblePyType::YType(v) => Err(MultipleIntegrationError::new_err(format!(
"Cannot integrate a nested Ypy object because is already integrated into a YDoc: {v}"
Expand Down
Loading
Loading