diff --git a/emci/rattler_build.py b/emci/rattler_build.py index a2107fec7..17d6c0275 100644 --- a/emci/rattler_build.py +++ b/emci/rattler_build.py @@ -26,9 +26,9 @@ def build_with_rattler(recipe=None, recipes_dir=None, emscripten_wasm32=False): # add conda forge and emscripten-forge channels cmd.extend([ - "-c", "microsoft", + "-c", "https://repo.mamba.pm/emscripten-forge", "-c", "conda-forge", - "-c", "https://repo.mamba.pm/emscripten-forge" + "-c", "microsoft", ]) # pass existing env vars to subprocess diff --git a/recipes/recipes/pytester/rattler_recipe.yaml b/recipes/recipes/pytester/rattler_recipe.yaml index b8f92d943..393a568a8 100644 --- a/recipes/recipes/pytester/rattler_recipe.yaml +++ b/recipes/recipes/pytester/rattler_recipe.yaml @@ -13,7 +13,8 @@ outputs: version: ${{ version }} build: - number: 4 + number: 6 + noarch: python requirements: @@ -33,7 +34,7 @@ outputs: name: pytester-run version: ${{ version }} build: - number: 4 + number: 6 noarch: generic requirements: run: diff --git a/recipes/recipes/rust/LICENSE b/recipes/recipes/rust/LICENSE new file mode 100644 index 000000000..468cd79a8 --- /dev/null +++ b/recipes/recipes/rust/LICENSE @@ -0,0 +1,23 @@ +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/recipes/recipes/rust/activate-rust.sh b/recipes/recipes/rust/activate-rust.sh new file mode 100644 index 000000000..1913c4e4c --- /dev/null +++ b/recipes/recipes/rust/activate-rust.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +echo "Activating Rust" + + + +export RUSTUP_HOME=$BUILD_PREFIX/.rustup +export CARGO_HOME=$BUILD_PREFIX/.cargo +export PATH=$CARGO_HOME/bin:$PATH + + +#echo $PKG_VERSION > ${PREFIX}/.rust_version + +# is there a .bashenv file? +if [ -f ${PREFIX}/.bashenv ]; then + # create a backup of the .bashenv file + cp ${PREFIX}/.bashenv ${PREFIX}/.bashenv.bak +fi + + +# load the rust version from the .rust_version file + +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y #--default-toolchain=1.78.0 +rustup install nightly-2024-04-22 +rustup default nightly-2024-04-22 +rustup target add wasm32-unknown-emscripten + + + + +export OPENSSL_INCLUDE_PATH=$PREFIX/include +export OPENSSL_LIBRARY_PATH=$PREFIX/lib +export OPENSSL_DIR=$PREFIX/lib +export WASM32_UNKNOWN_EMSCRIPTEN_OPENSSL_LIB_DIR=$PREFIX/lib +export WASM32_UNKNOWN_EMSCRIPTEN_OPENSSL_DIR=$PREFIX/lib +export WASM32_UNKNOWN_EMSCRIPTEN_OPENSSL_INCLUDE_DIR=$PREFIX/include + + +export PYO3_CROSS=1 +export PYO3_PYTHON=python3 +export PYO3_CROSS_PYTHON_VERSION=$PY_VER +export PYO3_CROSS_LIB_DIR=$PREFIX/lib +export PYO3_CROSS_INCLUDE_DIR=$PREFIX/include +export PYO3_PYTHON=python + +export CARGO_BUILD_TARGET="wasm32-unknown-emscripten" +export LDFLAGS="$LDFLAGS -L${PREFIX}/lib" \ No newline at end of file diff --git a/recipes/recipes/rust/build.sh b/recipes/recipes/rust/build.sh new file mode 100644 index 000000000..63c87e25a --- /dev/null +++ b/recipes/recipes/rust/build.sh @@ -0,0 +1,7 @@ +mkdir -p ${PREFIX}/etc/conda/activate.d +mkdir -p ${PREFIX}/etc/conda/deactivate.d + + +cp "${RECIPE_DIR}"/activate-rust.sh ${PREFIX}/etc/conda/activate.d/activate_z-${PKG_NAME}.sh +cp "${RECIPE_DIR}"/deactivate-rust.sh ${PREFIX}/etc/conda/deactivate.d/deactivate_z-${PKG_NAME}.sh + diff --git a/recipes/recipes/rust/deactivate-rust.sh b/recipes/recipes/rust/deactivate-rust.sh new file mode 100644 index 000000000..3ffe1cb21 --- /dev/null +++ b/recipes/recipes/rust/deactivate-rust.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +echo "Deactivating Rust" + +unset CARGO_HOME +unset RUSTUP_HOME + + + +# is there a .bashenv.bak file? +if [ -f ${PREFIX}/.bashenv.bak ]; then + # restore the .bashenv file + mv ${PREFIX}/.bashenv.bak ${PREFIX}/.bashenv +fi \ No newline at end of file diff --git a/recipes/recipes/rust/rattler_recipe.yaml b/recipes/recipes/rust/rattler_recipe.yaml new file mode 100644 index 000000000..2c57041aa --- /dev/null +++ b/recipes/recipes/rust/rattler_recipe.yaml @@ -0,0 +1,22 @@ +context: + name: rust + version: "1.79.0" + +package: + name: ${{ name|lower }} + version: ${{ version }} + + +build: + number: 29 + +requirements: + build: + - curl + +about: + summary: rust + +extra: + recipe-maintainers: + - DerThorsten diff --git a/recipes/recipes_emscripten/cryptography/build.sh b/recipes/recipes_emscripten/cryptography/build.sh index 6f8b4b7c5..7c4dcd955 100644 --- a/recipes/recipes_emscripten/cryptography/build.sh +++ b/recipes/recipes_emscripten/cryptography/build.sh @@ -1,3 +1,3 @@ #!/bin/bash -export LDFLAGS="$LDFLAGS -L${PREFIX}/lib" -${PYTHON} -m pip install . +${PYTHON} -m pip install . -vvv + diff --git a/recipes/recipes_emscripten/cryptography/patches/0001-Tell-rust-lang-libc-that-time_t-is-64-bits.patch b/recipes/recipes_emscripten/cryptography/patches/0001-Tell-rust-lang-libc-that-time_t-is-64-bits.patch new file mode 100644 index 000000000..1ee33c0c8 --- /dev/null +++ b/recipes/recipes_emscripten/cryptography/patches/0001-Tell-rust-lang-libc-that-time_t-is-64-bits.patch @@ -0,0 +1,27 @@ +From aeadf0c7223c0b8c7e209f6b555dfc91de31a34c Mon Sep 17 00:00:00 2001 +From: Hood Chatham +Date: Mon, 29 Jan 2024 16:34:05 -0800 +Subject: [PATCH] Tell rust-lang/libc that time_t is 64 bits + +See upstream PR: +https://github.com/rust-lang/libc/pull/3569#event-11634944887 +--- + src/rust/Cargo.toml | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml +index 2322486d0..52e7231d7 100644 +--- a/src/rust/Cargo.toml ++++ b/src/rust/Cargo.toml +@@ -7,6 +7,9 @@ publish = false + # This specifies the MSRV + rust-version = "1.63.0" + ++[patch.crates-io] ++libc = { git = 'https://github.com/hoodmane/libc.git', branch = 'emscripten-time_t-64-bit-2' } ++ + [dependencies] + once_cell = "1" + cfg-if = "1" +-- +2.25.1 \ No newline at end of file diff --git a/recipes/recipes_emscripten/cryptography/rattler_recipe.yaml b/recipes/recipes_emscripten/cryptography/rattler_recipe.yaml new file mode 100644 index 000000000..8c343d032 --- /dev/null +++ b/recipes/recipes_emscripten/cryptography/rattler_recipe.yaml @@ -0,0 +1,47 @@ +context: + name: cryptography + version: '42.0.2' + +package: + name: cryptography + version: ${{ version }} + +source: +- url: https://files.pythonhosted.org/packages/0f/6f/40f1b5c6bafc809dd21a9e577458ecc1d8062a7e10148d140f402b535eaa/cryptography-${{version}}.tar.gz + sha256: e0ec52ba3c7f1b7d813cd52649a5b3ef1fc0d433219dc8c93827c57eab6cf888 + patches: + - patches/0001-Tell-rust-lang-libc-that-time_t-is-64-bits.patch + +build: + number: 2 + +requirements: + build: + - cross-python_${{target_platform}} + - cffi == 1.15.1 + - openssl + - setuptools-rust + - rust + + host: + - python + - openssl + - cffi == 1.15.1 + run: + - cffi == 1.15.1 +tests: + - script: pytester + requirements: + build: + - pytester + run: + - pytester-run + files: + recipe: + - test_import_cryptography.py + +extra: + emscripten_tests: + python: + pytest_files: + - test_import_cryptography.py diff --git a/recipes/recipes_emscripten/cryptography/recipe.yaml b/recipes/recipes_emscripten/cryptography/recipe.yaml deleted file mode 100644 index 0f43d3777..000000000 --- a/recipes/recipes_emscripten/cryptography/recipe.yaml +++ /dev/null @@ -1,35 +0,0 @@ -context: - name: cryptography - version: '3.3.2' - -package: - name: cryptography - version: '{{ version }}' - -source: -- url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz - sha256: 5a60d3780149e13b7a6ff7ad6526b38846354d11a15e21068e57073e29e19bed - -build: - number: 1 - ignore_run_exports: - - python_abi - -requirements: - build: - - cross-python_emscripten-wasm32 - - cffi == 1.15.1 - - openssl - - pip - host: - - python - - openssl - - cffi == 1.15.1 - #run: - # #- cffi - -extra: - emscripten_tests: - python: - pytest_files: - - test_import_cryptography.py diff --git a/recipes/recipes_emscripten/cryptography/test_import_cryptography.py b/recipes/recipes_emscripten/cryptography/test_import_cryptography.py index 19ed17736..6fd86a9e3 100644 --- a/recipes/recipes_emscripten/cryptography/test_import_cryptography.py +++ b/recipes/recipes_emscripten/cryptography/test_import_cryptography.py @@ -2,7 +2,10 @@ def test_import_cryptography(): import cryptography import cryptography.fernet + from cryptography.hazmat.primitives.padding import ANSIX923, PKCS7 import cryptography.hazmat import cryptography.utils import cryptography.x509 - \ No newline at end of file + + + diff --git a/recipes/recipes_emscripten/pycrdt/build.sh b/recipes/recipes_emscripten/pycrdt/build.sh new file mode 100644 index 000000000..47c63b944 --- /dev/null +++ b/recipes/recipes_emscripten/pycrdt/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash + + +export MATURIN_PYTHON_SYSCONFIGDATA_DIR=${PREFIX}/etc/conda/_sysconfigdata__emscripten_wasm32-emscripten.py +${PYTHON} -m pip install . -vvv + diff --git a/recipes/recipes_emscripten/pycrdt/rattler_recipe.yaml b/recipes/recipes_emscripten/pycrdt/rattler_recipe.yaml new file mode 100644 index 000000000..86b0bf992 --- /dev/null +++ b/recipes/recipes_emscripten/pycrdt/rattler_recipe.yaml @@ -0,0 +1,41 @@ +context: + name: pycrdt + version: '0.8.19' + +package: + name: ${{name}} + version: ${{ version }} + +source: +- url: https://github.com/jupyter-server/pycrdt/archive/refs/tags/v${{version}}.tar.gz + sha256: 7284bd052c1b7ee56d1f3ffbc7dcd0c72181c6cd92ae3744c63ee80373827b48 + +build: + number: 0 + +requirements: + build: + - cross-python_${{target_platform}} + - cffi == 1.15.1 + - setuptools-rust + - rust + - maturin + + host: + - python + - openssl + - cffi == 1.15.1 + run: + - cffi == 1.15.1 + - typing_extensions + +tests: + - script: pytester + requirements: + build: + - pytester + run: + - pytester-run + files: + recipe: + - test_pycrdt.py \ No newline at end of file diff --git a/recipes/recipes_emscripten/pycrdt/test_pycrdt.py b/recipes/recipes_emscripten/pycrdt/test_pycrdt.py new file mode 100644 index 000000000..82ccd62b3 --- /dev/null +++ b/recipes/recipes_emscripten/pycrdt/test_pycrdt.py @@ -0,0 +1,38 @@ +import json +from pycrdt import Array, Doc, Map, Text + +def callback(events, event): + events.append( + dict( + delta=event.delta, + path=event.path, + ) + ) + + +def test_str(): + doc = Doc() + map2 = Map({"key": "val"}) + array1 = Array([2, 3, map2]) + map1 = Map({"foo": array1}) + array0 = Array([0, 1, None, map1]) + doc["array"] = array0 + assert str(array0) == '[0.0,1.0,null,{"foo":[2.0,3.0,{"key":"val"}]}]' + + +def test_nested(): + doc = Doc() + text1 = Text("my_text1") + array1 = Array([0, "foo", 2]) + text2 = Text("my_text2") + map1 = Map({"foo": [3, 4, 5], "bar": "hello", "baz": text2}) + array0 = Array([text1, array1, map1]) + doc["array"] = array0 + ref = [ + "my_text1", + [0, "foo", 2], + {"bar": "hello", "foo": [3, 4, 5], "baz": "my_text2"}, + ] + assert json.loads(str(array0)) == ref + assert isinstance(array0[2], Map) + assert isinstance(array0[2]["baz"], Text) \ No newline at end of file diff --git a/recipes/recipes_emscripten/pydantic_core/build.sh b/recipes/recipes_emscripten/pydantic_core/build.sh new file mode 100644 index 000000000..47c63b944 --- /dev/null +++ b/recipes/recipes_emscripten/pydantic_core/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash + + +export MATURIN_PYTHON_SYSCONFIGDATA_DIR=${PREFIX}/etc/conda/_sysconfigdata__emscripten_wasm32-emscripten.py +${PYTHON} -m pip install . -vvv + diff --git a/recipes/recipes_emscripten/pydantic_core/rattler_recipe.yaml b/recipes/recipes_emscripten/pydantic_core/rattler_recipe.yaml new file mode 100644 index 000000000..e4df7cfe0 --- /dev/null +++ b/recipes/recipes_emscripten/pydantic_core/rattler_recipe.yaml @@ -0,0 +1,44 @@ +context: + name: pydantic_core + version: '2.16.2' + +package: + name: pydantic_core + version: ${{ version }} + +source: +- url: https://files.pythonhosted.org/packages/0d/72/64550ef171432f97d046118a9869ad774925c2f442589d5f6164b8288e85/pydantic_core-${{ version }}.tar.gz + sha256: 0ba503850d8b8dcc18391f10de896ae51d37fe5fe43dbfb6a35c5c5cad271a06 + +build: + number: 2 + +requirements: + build: + - cross-python_${{target_platform}} + - cffi == 1.15.1 + - openssl + - setuptools-rust + - rust + - maturin + - typing_extensions + + host: + - python + - openssl + - cffi == 1.15.1 + - typing_extensions + run: + - cffi == 1.15.1 + - typing_extensions + +tests: + - script: pytester + requirements: + build: + - pytester + run: + - pytester-run + files: + recipe: + - test_pydantic_core.py \ No newline at end of file diff --git a/recipes/recipes_emscripten/pydantic_core/test_pydantic_core.py b/recipes/recipes_emscripten/pydantic_core/test_pydantic_core.py new file mode 100644 index 000000000..8c22880ff --- /dev/null +++ b/recipes/recipes_emscripten/pydantic_core/test_pydantic_core.py @@ -0,0 +1,40 @@ + +def test_pydantic_core(): + from pydantic_core import SchemaValidator, ValidationError + + + v = SchemaValidator( + { + 'type': 'typed-dict', + 'fields': { + 'name': { + 'type': 'typed-dict-field', + 'schema': { + 'type': 'str', + }, + }, + 'age': { + 'type': 'typed-dict-field', + 'schema': { + 'type': 'int', + 'ge': 18, + }, + }, + 'is_developer': { + 'type': 'typed-dict-field', + 'schema': { + 'type': 'default', + 'schema': {'type': 'bool'}, + 'default': True, + }, + }, + }, + } + ) + + r1 = v.validate_python({'name': 'Samuel', 'age': 35}) + assert r1 == {'name': 'Samuel', 'age': 35, 'is_developer': True} + + # pydantic-core can also validate JSON directly + r2 = v.validate_json('{"name": "Samuel", "age": 35}') + assert r1 == r2 \ No newline at end of file