Skip to content

Commit

Permalink
Merge branch 'main' into bump-gmpy2_2.1.2_to_2.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
DerThorsten authored Jun 28, 2024
2 parents e082aa9 + 8232546 commit 7b75f2d
Show file tree
Hide file tree
Showing 138 changed files with 12,779 additions and 575 deletions.
64 changes: 46 additions & 18 deletions .github/workflows/build_recipes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:
GITHUB_OWNER: "emscripten-forge"
strategy:
fail-fast: false
matrix:
emsdk_ver: ["3.1.45"]

steps:
################################################################
Expand Down Expand Up @@ -59,14 +57,6 @@ jobs:
cache-environment: true
post-cleanup: 'all'

################################################################
# EMSDK
################################################################
- name: Setup emsdk
shell: bash -el {0}
run: |
./emsdk/setup_emsdk.sh ${{ matrix.emsdk_ver }} $(pwd)/emsdk_install
################################################################
# POST ENV INSTALL CONFIG
################################################################
Expand Down Expand Up @@ -99,13 +89,51 @@ jobs:
################################################################
- name: Upload packages to Quetz
if: (github.event_name == 'push' && github.repository == 'emscripten-forge/recipes')
shell: bash -el {0}
shell: bash -l {0}
env:
QUETZ_API_KEY: ${{ secrets.QUETZ_API_KEY }}
run: |
# loop over {emscripten-wasm32, linux-64, noarch}
overall_success=true
# Loop over {emscripten-wasm32, linux-64, noarch}
for platform in emscripten-wasm32 linux-64 noarch; do
mkdir -p ${GITHUB_WORKSPACE}/output/${platform}
for package in $(ls ${GITHUB_WORKSPACE}/output/${platform}/*.tar.bz2); do
echo "Uploading ${package} for ${platform} (build with rattler)"
QUETZ_API_KEY=${{ secrets.QUETZ_API_KEY}} quetz-client -u https://beta.mamba.pm post_file_to_channel emscripten-forge ${package}
done
done
if [ -d "${GITHUB_WORKSPACE}/output/${platform}" ]; then
cd "${GITHUB_WORKSPACE}/output/${platform}"
files=$(ls *.tar.bz2 2> /dev/null)
if [ -n "$files" ]; then
for package in $files; do
echo "Uploading ${package} for ${platform}"
FILE_SHA256=$(sha256sum "${package}" | awk '{ print $1 }')
CURL_CMD=(
curl -H "X-API-Key: ${QUETZ_API_KEY}" -X POST
"https://beta.mamba.pm/api/channels/emscripten-forge/upload/${package}?sha256=${FILE_SHA256}&force=false"
--data-binary "@${package}"
-o response_body.txt
-w "%{http_code}"
-s
)
HTTP_STATUS=$( "${CURL_CMD[@]}" )
RESPONSE=$(<response_body.txt)
# Check the HTTP status code and log appropriate message
if [[ "$HTTP_STATUS" -eq 201 ]]; then
echo "Upload succeeded for ${package} on ${platform}"
else
echo "Error: Upload failed with HTTP status $HTTP_STATUS"
echo "Response Body: $RESPONSE"
overall_success=false
fi
rm -f response_body.txt
done
fi
fi
done
# Check if all uploads were successful
if [ "$overall_success" = false ]; then
echo "One or more uploads failed"
exit 1
else
echo "All uploads completed successfully"
fi
38 changes: 38 additions & 0 deletions .github/workflows/on_compiler_changes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: compile pyjs
on:
push:
branches:
- 'main'
paths:
- 'recipes/recipes/emscripten_emscripten-wasm3/**'
pull_request:
paths:
- 'recipes/recipes/emscripten_emscripten-wasm32/**'
jobs:

build_simple_with_pixi:
runs-on: ubuntu-latest
env:
TARGET_PLATFORM: emscripten-wasm32
GITHUB_OWNER: "emscripten-forge"
strategy:
fail-fast: false

steps:
################################################################
# SETUP
################################################################
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

################################################################
# CONFIG
################################################################
- uses: prefix-dev/[email protected]
with:
pixi-version: v0.20.1
- run: |
pixi run setup
pixi run build-emscripten-wasm32-pkg recipes/recipes_emscripten/pyjs
2 changes: 0 additions & 2 deletions .github/workflows/run_with_pixi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ jobs:
GITHUB_OWNER: "emscripten-forge"
strategy:
fail-fast: false
matrix:
emsdk_ver: ["3.1.45"]

steps:
################################################################
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Emscripten forge
[![CI](https://img.shields.io/badge/emscripten_forge-docs-yellow)](https://emscripten-forge.org)
[![CI](https://img.shields.io/badge/emscripten_forge-blog-pink)](https://emscripten-forge.org)

[![CI](https://img.shields.io/badge/emscripten_forge-blog-pink)](https://emscripten-forge.org/blog/)


Visit [emscripten-forge.org](https://emscripten-forge.org) for more information and the documentation.
4 changes: 2 additions & 2 deletions ci_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dependencies:
- python
- ruamel.yaml
- typer
- rattler-build >= 0.16.0
- rattler-build >= 0.18.1
- pixi
- quetz-client
- jinja2
- curl
29 changes: 19 additions & 10 deletions conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,48 @@ c_compiler:
then:
- clang

c_compiler_version:


cxx_compiler:
- if: emscripten
then:
- 3
- emscripten
- if: linux
then:
- 9
- gxx
- if: osx
then:
- 11
- clangxx

cxx_compiler:
c_compiler_version:
- if: emscripten
then:
- emscripten
- 3.1.45
- if: linux
then:
- gxx
- 9
- if: osx
then:
- clangxx
- 11


cxx_compiler_version:
- if: emscripten
then:
- 3
- 3.1.45
- if: linux
then:
- 9
- if: osx
then:
- 11

zip_keys:
-
- cxx_compiler_version
- c_compiler_version


cuda_compiler:
- undefined
cuda_compiler_version:
Expand Down Expand Up @@ -367,7 +376,7 @@ hdf4:
hdf5:
- 1.12.2
icu:
- '69'
- '73'
ipopt:
- 3.14
isl:
Expand Down
7 changes: 7 additions & 0 deletions docs/blog/.authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ authors:
avatar: https://avatars.githubusercontent.com/u/904752?v=4 # Author avatar
slug: DerThorsten # Author profile slug
url: https://github.com/DerThorsten # Author website URL

wolfv:
name: Wolf Vollprecht
description: main author of emscripten-forge
avatar: https://avatars.githubusercontent.com/u/885054?v=4
slug: wolfv # Author profile slug
url: https://prefix.dev # Author website URL
15 changes: 15 additions & 0 deletions docs/blog/posts/repack_emscripten.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
date: 2024-05-24
category:
- rust

authors:
- derthorsten
- wolfv
---

# Emscripten is now a proper package

So far, the emscripten package was a bit of a hack. It relied on a text file `~.emsdkdir` in the home directory which contained the directory of the emscripten installation. This was not very nice, because it was hard to build packages for several emscripten versions.

But now, emscripten is a repacked package that installs emscripten into the conda environment. This allows in principle to compile packages for multiple emscripten versions.
49 changes: 33 additions & 16 deletions docs/development/adding_packages.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
# Adding packages

To add a new package to emscripten-forge, just create a Pull Request in this repository.
To add a new package to emscripten-forge, just create a Pull Request in [this repository](https://github.com/emscripten-forge/recipes/pulls).
The recipe format is described in the [rattler-build recipe format](https://github.com/prefix-dev/rattler-build?tab=readme-ov-file#the-recipe-format)


## C/C++ Packages
### CMake

Adding cmake based packages is easy. Usually it is enough to replace the `cmake` command with the `emcmake` command and
`make` with `emmake` (see the [emscripten documentation](https://emscripten.org/docs/compiling/Building-Projects.html#integrating-with-a-build-system) for more details)
`make` with `emmake` (see the [emscripten documentation](https://emscripten.org/docs/compiling/Building-Projects.html#integrating-with-a-build-system) for more details).

To build a shared library with CMake, one needs flags.
These flags can be put into a `.cmake` file:
```CMake
# overwriteProp.cmake
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) # does not need to be global :)
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-s SIDE_MODULE=1")
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-s SIDE_MODULE=1")
set(CMAKE_STRIP FALSE) # used by default in pybind11 on .so modules # only for needed when using pybind11
```

This can be passed to the as command line argument to cmake
```
# CLI
... -DCMAKE_PROJECT_INCLUDE=overwriteProp.cmake
```


**Example recipes**:
Expand All @@ -20,19 +35,20 @@ Adding cmake based packages is easy. Usually it is enough to replace the `cmake`

### Configure / Make

Usually it is enough to replace the `./configure` command with the `emconfigure ./configure` (see the [emscripten documentation](https://emscripten.org/docs/compiling/Building-Projects.html#integrating-with-a-build-system) for more details)
Usually it is enough to replace the `./configure` command with the `emconfigure ./configure` (see the [emscripten documentation](https://emscripten.org/docs/compiling/Building-Projects.html#integrating-with-a-build-system) for more details).


## Python Packages

### pip / setuptools
For simple package only these requirements are usually necessary:
```yaml

For a simple package, only these requirements are usually necessary:

```yaml
requirements:
build:
- python
- cross-python_${{target_platform}}
- cross-python_${{ target_platform }}
- ${{ compiler("c") }}
- pip
host:
Expand All @@ -46,9 +62,10 @@ requirements:
* [regex](https://github.com/emscripten-forge/recipes/tree/main/recipes/recipes_emscripten/regex)
### menson
### meson
For a meson package, the following requirements are usually needed.
```yaml
requirements:
build:
Expand All @@ -59,10 +76,10 @@ requirements:
host:
- python
```
Furthermore a `emscripten.meson.cross` file is necessary to set the correct compiler and flags for the cross compilation.
Furthermore, an `emscripten.meson.cross` file is necessary to set the correct compiler and flags for cross compilation.

```toml
# binaries section is at the end as may want to append python binary.
# binaries section is at the end to be able to append the python binary.
[properties]
needs_exe_wrapper = true
Expand All @@ -81,8 +98,7 @@ pkgconfig = 'pkg-config'
```

in the build script we append the python binary to the cross file and
pass the cross file to the pip command.
In the build script, we append the python binary to the *.cross* file and pass this *.cross* file to the pip command.

```bash
#!/bin/bash
Expand All @@ -94,20 +110,21 @@ ${PYTHON} -m pip install . -vvv --no-deps --no-build-isolation \
-Csetup-args="--cross-file=$SRC_DIR/emscripten.meson.cross"
```


**Example recipes**:

* [contourpy](https://github.com/emscripten-forge/recipes/tree/main/recipes/recipes_emscripten/contourpy)
* [numpy](https://github.com/emscripten-forge/recipes/tree/main/recipes/recipes_emscripten/numpy)

### rust
Building rust package with PyO3 / maturin works usually out of the box.
### rust

Building rust packages with PyO3 / maturin typically works out of the box.

For a maturin / cffi / pyo3 package, the following requirements are usually necessary:

```yaml
requirements:
build:
- cross-python_${{target_platform}}
- cross-python_${{ target_platform }}
- cffi == 1.15.1 (# at the time of writing pinning cffi == 1.15.1 is necessary, may change in the future)
- setuptools-rust
- rust
Expand All @@ -116,7 +133,7 @@ requirements:
host:
- python
# at the time of writing pinning cffi == 1.15.1 is necessary, may change in the future)
- cffi == 1.15.1
- cffi == 1.15.1
run:
# at the time of writing pinning cffi == 1.15.1 is necessary, may change in the future)
- cffi == 1.15.1
Expand Down
Loading

0 comments on commit 7b75f2d

Please sign in to comment.