Skip to content

Commit bfb7cf1

Browse files
Merge branch 'emscripten-4x' into initial-build-robotics-toolbox-python_for_emscripten-4x
2 parents c579181 + 3b6da57 commit bfb7cf1

414 files changed

Lines changed: 13620 additions & 27279 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

emci/bot/bump_recipes_versions.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,16 @@ def empty_context_manager():
284284
# Check for opened PRs and merge them if the CI passed
285285
print("Checking opened PRs and merge them if green!")
286286

287-
288-
command = ["gh","pr","list","--author","emscripten-forge-bot","--base",pr_target_branch,"--json","number,title"]
287+
command = [
288+
"gh", "pr", "list",
289+
"--author", "emscripten-forge-bot",
290+
"--base", pr_target_branch,
291+
"--json", "number,title",
292+
"--limit", "200" # default is only 30
293+
]
289294
# run command and get the output as json
290295
all_prs = json.loads(subprocess.check_output(command).decode('utf-8'))
291296

292-
293-
294297
all_recipes = [recipe for recipe in Path(recipe_dir).iterdir() if recipe.is_dir()]
295298
# map from folder names to recipe-dir
296299
recipe_name_to_recipe_dir = {recipe.name: recipe for recipe in all_recipes}

emci/find_recipes_with_changes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def find_recipes_with_changes(old, new):
1414
file_with_change = file_with_change[len(f"recipes/{subdir}/") :]
1515
file_with_change = os.path.normpath(file_with_change)
1616
recipe = file_with_change.split(os.sep)[0]
17-
recipes_with_changes[subdir].add(recipe)
17+
if os.path.exists(f"recipes/{subdir}/{recipe}"):
18+
recipes_with_changes[subdir].add(recipe)
1819

1920
for subdir in RECIPES_SUBDIR_MAPPING.keys():
2021
recipes_with_changes[subdir] = sorted(list(recipes_with_changes[subdir]))

emci/schema.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import re
2-
from pydantic import BaseModel, field_validator
3-
from typing import Optional
2+
from pydantic import BaseModel, field_validator, model_validator
3+
from typing import Optional, Any
44

55
class Source(BaseModel):
66
url: str | list[str]
@@ -14,8 +14,8 @@ def validate_single_url(url: str) -> str:
1414
if not ("${{version" in url.replace(" ", "") and "}}" in url):
1515
raise ValueError(f"{url} must contain ${{{{ version }}}} for automatic updates.\n")
1616
# Check it's a valid URL
17-
if not re.match(r"^https://.*\.(tar\.gz|tar\.bz2|tar\.xz)$", url):
18-
raise ValueError(f"{url} must be a valid link to an archive file (tar.gz, tar.bz2, etc.)\n")
17+
if not re.match(r"^(https://.*|http://.*)\.(tar\.gz|tar\.bz2|tar\.xz|tgz|zip)$", url):
18+
raise ValueError(f"{url} must be a valid link (https://...) to an archive file (tar.gz, tar.bz2, tar.xz, .tgz, or .zip)\n")
1919

2020
return url
2121

@@ -39,4 +39,19 @@ class About(BaseModel):
3939

4040
class Recipe(BaseModel):
4141
about: About
42-
source: Source
42+
source: Optional[Source] = None
43+
tests: Optional[Any] = None
44+
45+
@model_validator(mode='before')
46+
@classmethod
47+
def check_tests_exists(cls, values):
48+
if 'tests' not in values or values['tests'] is None:
49+
if 'outputs' in values:
50+
for output_dict in values['outputs']:
51+
if 'tests' not in output_dict:
52+
pkg_name = output_dict.get('package', {}).get('name', 'unknown')
53+
raise AttributeError(f"Output '{pkg_name}' must have a 'tests' section.")
54+
else:
55+
raise AttributeError("Recipe must have a 'tests' section.")
56+
57+
return values

recipes/recipes/cross-python_emscripten-wasm32/FindPython.cmake renamed to recipes/recipes/cross-python-cmake_emscripten-wasm32/FindPython.cmake

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,42 @@ if (NOT TARGET Python::Interpreter)
101101
IMPORTED_LOCATION "${Python_EXECUTABLE}"
102102
)
103103
message(STATUS "Created Python::Interpreter IMPORTED executable target.")
104-
endif()
104+
endif()
105+
106+
107+
108+
109+
110+
function(python_add_library name)
111+
cmake_parse_arguments(PYLIB "WITH_SOABI" "TYPE;USE_SABI" "SOURCES" ${ARGN})
112+
113+
# Default type
114+
if(NOT PYLIB_TYPE)
115+
set(PYLIB_TYPE MODULE)
116+
endif()
117+
118+
# Allow positional sources (anything not parsed as a keyword)
119+
if(NOT PYLIB_SOURCES)
120+
set(PYLIB_SOURCES ${PYLIB_UNPARSED_ARGUMENTS})
121+
endif()
122+
123+
# Validate sources
124+
if(NOT PYLIB_SOURCES)
125+
message(FATAL_ERROR "No source files provided to python_add_library(${name})")
126+
endif()
127+
128+
# Library type handling
129+
if(PYLIB_TYPE STREQUAL "MODULE")
130+
set(options MODULE)
131+
elseif(PYLIB_TYPE STREQUAL "SHARED")
132+
set(options SHARED)
133+
elseif(PYLIB_TYPE STREQUAL "STATIC")
134+
set(options STATIC)
135+
else()
136+
message(FATAL_ERROR "Invalid library type specified: ${PYLIB_TYPE}")
137+
endif()
138+
139+
add_library(${name} ${options} ${PYLIB_SOURCES})
140+
target_include_directories(${name} PRIVATE ${Python_INCLUDE_DIRS})
141+
target_link_libraries(${name} PRIVATE ${Python_LIBRARIES})
142+
endfunction()
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
4+
# is cmake installed in the build prefix?
5+
# check the conda-meta.yaml file for the cmake dependency
6+
if compgen -G "${BUILD_PREFIX}/conda-meta/cmake-*.json" > /dev/null; then
7+
8+
echo "CMake is installed, setting up custom FindPython.cmake"
9+
10+
# we overwrite the FindPython.cmake **IN THE BUILD PREFIX**
11+
CUSTOM_FIND_PYTHON=$BUILD_PREFIX/share/cross-python-cmake/FindPython.cmake
12+
13+
# guess the cmake version (ie 4.0.1)
14+
CMAKE_VERSION=""
15+
if command -v cmake &> /dev/null; then
16+
# cmake is found, try to get the version
17+
if CMAKE_VERSION_OUTPUT=$($BUILD_PREFIX/bin/cmake --version 2>&1); then
18+
# Command succeeded
19+
CMAKE_VERSION=$(echo "$CMAKE_VERSION_OUTPUT" | head -n 1 | cut -d ' ' -f 3)
20+
echo "CMake version: $CMAKE_VERSION"
21+
else
22+
# Command failed for other reasons (e.g., bad arguments, corrupted binary)
23+
echo "Error: 'cmake --version' failed."
24+
echo "Output:"
25+
echo "$CMAKE_VERSION_OUTPUT"
26+
CMAKE_VERSION="unknown" # Set a default or error value
27+
fi
28+
else
29+
# cmake is not found
30+
# this is a problem, we cannot proceed
31+
echo "Error: CMake is not installed in the build prefix."
32+
exit 1
33+
fi
34+
# remove the patch version
35+
CMAKE_VERSION=$(echo $CMAKE_VERSION | cut -d '.' -f 1-2)
36+
37+
CMAKE_MODULE_DIR="$BUILD_PREFIX/share/cmake-$CMAKE_VERSION/Modules"
38+
39+
# if the cmake-moduledir is not at the expected location
40+
# we assume that this is an error
41+
if [[ ! -d "$CMAKE_MODULE_DIR" ]]; then
42+
echo "Error: CMake module directory $CMAKE_MODULE_DIR does not exist at the expected location."
43+
echo "This might be an error on the emscripten-forge side."
44+
echo "Please report this issue."
45+
exit 1
46+
fi
47+
48+
cp $CUSTOM_FIND_PYTHON $CMAKE_MODULE_DIR/FindPython.cmake
49+
50+
else
51+
echo "CMake is not installed, skipping custom FindPython.cmake setup"
52+
fi
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# Copy the [de]activate scripts to $PREFIX/etc/conda/[de]activate.d.
4+
# This will allow them to be run on environment activation.
5+
for TASK in "activate" "deactivate"
6+
do
7+
mkdir -p "${PREFIX}/etc/conda/${TASK}.d"
8+
cp "${RECIPE_DIR}/${TASK}.sh" "${PREFIX}/etc/conda/${TASK}.d/${TASK}_z-${PKG_NAME}.sh"
9+
done
10+
11+
12+
mkdir -p "${PREFIX}/share/cross-python-cmake"
13+
cp $RECIPE_DIR/FindPython.cmake "${PREFIX}/share/cross-python-cmake/FindPython.cmake"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
if [[ "${CONDA_BUILD:-0}" == "1" && "${CONDA_BUILD_STATE}" != "TEST" ]]; then
4+
unset PYTHONPATH
5+
if [[ "${_CONDA_BACKUP_PYTHONPATH}" != "" ]]; then
6+
export PYTHONPATH=${_CONDA_BACKUP_PYTHONPATH}
7+
fi
8+
fi
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
context:
2+
name: cross-python-cmake_emscripten-wasm32
3+
version: 3.13.1
4+
5+
package:
6+
name: ${{ name }}
7+
version: ${{ version }}
8+
9+
build:
10+
number: 0
11+
12+
requirements:
13+
about:
14+
summary: cross-python-cmake is a helper which patches some FindPython.cmake files
15+
16+
extra:
17+
recipe-maintainers:
18+
- DerThorsten

recipes/recipes/cross-python_emscripten-wasm32/activate.sh

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -67,55 +67,4 @@ export PIP_ARGS="--prefix=$PREFIX --no-deps -vv"
6767

6868
# Set up flags
6969
export LDFLAGS="$EM_FORGE_SIDE_MODULE_LDFLAGS"
70-
export CFLAGS="$EM_FORGE_SIDE_MODULE_CFLAGS"
71-
72-
73-
# is cmake installed in the build prefix?
74-
# check the conda-meta.yaml file for the cmake dependency
75-
if compgen -G "${BUILD_PREFIX}/conda-meta/cmake-*.json" > /dev/null; then
76-
77-
echo "CMake is installed, setting up custom FindPython.cmake"
78-
79-
# we overwrite the FindPython.cmake **IN THE BUILD PREFIX**
80-
CUSTOM_FIND_PYTHON=$BUILD_PREFIX/share/cross-python/FindPython.cmake
81-
82-
# guess the cmake version (ie 4.0.1)
83-
CMAKE_VERSION=""
84-
if command -v cmake &> /dev/null; then
85-
# cmake is found, try to get the version
86-
if CMAKE_VERSION_OUTPUT=$($BUILD_PREFIX/bin/cmake --version 2>&1); then
87-
# Command succeeded
88-
CMAKE_VERSION=$(echo "$CMAKE_VERSION_OUTPUT" | head -n 1 | cut -d ' ' -f 3)
89-
echo "CMake version: $CMAKE_VERSION"
90-
else
91-
# Command failed for other reasons (e.g., bad arguments, corrupted binary)
92-
echo "Error: 'cmake --version' failed."
93-
echo "Output:"
94-
echo "$CMAKE_VERSION_OUTPUT"
95-
CMAKE_VERSION="unknown" # Set a default or error value
96-
fi
97-
else
98-
# cmake is not found
99-
# this is a problem, we cannot proceed
100-
echo "Error: CMake is not installed in the build prefix."
101-
exit 1
102-
fi
103-
# remove the patch version
104-
CMAKE_VERSION=$(echo $CMAKE_VERSION | cut -d '.' -f 1-2)
105-
106-
CMAKE_MODULE_DIR="$BUILD_PREFIX/share/cmake-$CMAKE_VERSION/Modules"
107-
108-
# if the cmake-moduledir is not at the expected location
109-
# we assume that this is an error
110-
if [[ ! -d "$CMAKE_MODULE_DIR" ]]; then
111-
echo "Error: CMake module directory $CMAKE_MODULE_DIR does not exist at the expected location."
112-
echo "This might be an error on the emscripten-forge side."
113-
echo "Please report this issue."
114-
exit 1
115-
fi
116-
117-
cp $CUSTOM_FIND_PYTHON $CMAKE_MODULE_DIR/FindPython.cmake
118-
119-
else
120-
echo "CMake is not installed, skipping custom FindPython.cmake setup"
121-
fi
70+
export CFLAGS="$EM_FORGE_SIDE_MODULE_CFLAGS"

recipes/recipes/cross-python_emscripten-wasm32/build.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ do
99
done
1010

1111

12-
mkdir -p "${PREFIX}/share/cross-python"
13-
cp $RECIPE_DIR/FindPython.cmake "${PREFIX}/share/cross-python/FindPython.cmake"
12+
mkdir -p "${PREFIX}/share/cross-python"

0 commit comments

Comments
 (0)