Skip to content

Commit 6093cff

Browse files
Merge branch 'emscripten-4x' into bump-galpy_1.11.0_to_1.11.1_for_emscripten-4x
2 parents ca2f03c + 2a3eb6a commit 6093cff

49 files changed

Lines changed: 689 additions & 900 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Matplotlib Fontcache Update Bot
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * *'
7+
8+
jobs:
9+
10+
update_matplotlib_fontcache:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
branch: [main, emscripten-4x]
15+
16+
if: (github.event_name == 'schedule' && github.repository == 'emscripten-forge/recipes') || (github.event_name != 'schedule')
17+
runs-on: [ubuntu-latest]
18+
steps:
19+
- uses: actions/checkout@v6
20+
with:
21+
ref: ${{ matrix.branch }}
22+
23+
- name: Install micromamba
24+
uses: mamba-org/setup-micromamba@v2
25+
with:
26+
environment-file: ci_env.yml
27+
create-args: >-
28+
microsoft::playwright
29+
pyjs_code_runner
30+
31+
- name: Update matplotlib font cache if needed
32+
shell: bash -l -eo pipefail {0}
33+
run: |
34+
playwright install
35+
python -m emci bot update-matplotlib-fontcache ${{ matrix.branch }}
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.BOT_ACCESS_TOKEN }}

emci/__main__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ def bump_recipes_versions(target_branch_name: str):
7575

7676
bump_recipe_versions(RECIPES_EMSCRIPTEN_DIR, target_branch_name)
7777

78+
79+
@bot_app.command()
80+
def update_matplotlib_fontcache(target_branch_name: str):
81+
from .bot.update_matplotlib_fontcache import update_matplotlib_fontcache
82+
83+
update_matplotlib_fontcache(RECIPES_EMSCRIPTEN_DIR, target_branch_name)
84+
85+
7886
@build_app.command()
7987
def lint(old: str, new: str):
8088
"""

emci/bot/bump_recipes_versions.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,18 @@ def bump_recipe_version(recipe_dir, target_pr_branch_name):
158158

159159
# check if the recipe has test section
160160
# load recipe
161-
automerge = False
161+
automerge = True
162162
with open(recipe_file) as file:
163163
recipe = YAML().load(file)
164-
if 'tests' in recipe:
165-
automerge = True
164+
165+
# Multi-outputs recipe
166+
if hasattr(recipe, "outputs"):
167+
for i, output in enumerate(outputs):
168+
if "tests" not in output:
169+
automerge = False
170+
break
171+
elif 'tests' not in recipe:
172+
automerge = False
166173

167174

168175
branch_name = f"bump-{name}_{current_version}_to_{new_version}_for_{target_pr_branch_name}"
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
from subprocess import run as subprocess_run
2+
import pyjs_code_runner
3+
import socket
4+
from contextlib import closing, contextmanager, redirect_stdout
5+
import os
6+
from pyjs_code_runner.run import run
7+
from pyjs_code_runner.backend.backend import BackendType
8+
from pyjs_code_runner.get_file_filter import get_file_filter
9+
from pathlib import Path
10+
import shutil
11+
import sys
12+
import json
13+
import yaml
14+
import pprint
15+
import io
16+
from ..git_utils import git_branch_ctx, set_bot_user, make_pr_for_recipe, get_current_branch_name
17+
18+
19+
THIS_DIR = Path(os.getcwd())
20+
MAIN_MOUNT_DIR = Path(THIS_DIR) / "main_mount"
21+
PREFIX_PATH = THIS_DIR / "prefix"
22+
23+
START_MARKER = "/// BEGIN FONTCACHE"
24+
END_MARKER = "/// END FONTCACHE"
25+
26+
PYTHON_FILENAME = "generate_fontcache.py"
27+
PYTHON_CODE = f"""
28+
import matplotlib
29+
from pathlib import Path
30+
31+
# This import is the one triggering the font cache building
32+
import matplotlib.pyplot
33+
34+
print('{START_MARKER}')
35+
with open(Path(matplotlib.__file__).parent / "fontlist.json") as fd:
36+
print(fd.read())
37+
print('{END_MARKER}')
38+
"""
39+
40+
ON_GITHUB_ACTIONS = os.environ.get('GITHUB_ACTIONS') == 'true'
41+
42+
43+
def find_free_port():
44+
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
45+
s.bind(("", 0))
46+
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
47+
return s.getsockname()[1]
48+
49+
50+
def update_matplotlib_fontcache(recipe_dir, target_branch_name):
51+
if not ON_GITHUB_ACTIONS:
52+
raise RuntimeError("Cannot update fontcache outside of github actions")
53+
54+
matplotlib_folder = Path(recipe_dir) / "matplotlib"
55+
recipe_file = matplotlib_folder / "recipe.yaml"
56+
fontlist_file = matplotlib_folder / "src" / "fontlist.json"
57+
58+
# Get current font list version
59+
with open(fontlist_file, "r") as fobj:
60+
fontlist = json.load(fobj)
61+
current_fontlist_version = fontlist["_version"]
62+
63+
# Read current matplotlib version
64+
with open(recipe_file) as stream:
65+
recipe = yaml.safe_load(stream)
66+
matplotlib_version = recipe["context"]["version"]
67+
68+
# Create prefix with installing pyjs and matplotlib = _x
69+
subprocess_run(
70+
[
71+
"micromamba",
72+
"create",
73+
"--yes",
74+
"--prefix",
75+
PREFIX_PATH,
76+
"--platform=emscripten-wasm32",
77+
"-c",
78+
"https://prefix.dev/emscripten-forge-4x" if target_branch_name == "emscripten-4x" else "https://prefix.dev/emscripten-forge-dev",
79+
"-c",
80+
"https://prefix.dev/conda-forge",
81+
f"matplotlib={matplotlib_version}",
82+
"pyjs"
83+
],
84+
check=True
85+
)
86+
87+
virtual_work_dir = Path("/")
88+
89+
# Create runnable script in to mount in the emscripten fs
90+
MAIN_MOUNT_DIR.mkdir(exist_ok=True)
91+
with open(MAIN_MOUNT_DIR / PYTHON_FILENAME, "w") as fobj:
92+
fobj.write(PYTHON_CODE)
93+
94+
buffer = io.StringIO()
95+
with redirect_stdout(buffer):
96+
run(
97+
conda_env=PREFIX_PATH,
98+
relocate_prefix="/",
99+
backend_type=BackendType.browser_main,
100+
script=PYTHON_FILENAME,
101+
async_main=False,
102+
mounts=[
103+
(MAIN_MOUNT_DIR, virtual_work_dir)
104+
],
105+
work_dir=virtual_work_dir,
106+
pyjs_dir=None,
107+
cache_dir=None,
108+
use_cache=False,
109+
host_work_dir=None,
110+
backend_kwargs=(lambda: dict(port=find_free_port(), slow_mo=1, headless=True))(),
111+
)
112+
output = buffer.getvalue()
113+
114+
# Cleanup
115+
shutil.rmtree(MAIN_MOUNT_DIR)
116+
shutil.rmtree(PREFIX_PATH)
117+
118+
start = output.find(START_MARKER)
119+
end = output.find(END_MARKER)
120+
121+
if start == -1 or end == -1:
122+
raise ValueError("Fontcache markers not found in the output")
123+
124+
start += len(START_MARKER)
125+
126+
new_fontlist = json.loads(output[start:end].strip())
127+
128+
if new_fontlist["_version"] == current_fontlist_version:
129+
print('Matplotlib fontlist is already up-to-date, nothing to do')
130+
return
131+
132+
print('Matplotlib fontlist has changed! Updating it')
133+
134+
# We are on GitHub Actions, we **cannot** **restore** the user account
135+
# therefore we just set the bot user and use an empty context manager
136+
set_bot_user()
137+
138+
# Write new file
139+
with open(fontlist_file, "w") as fobj:
140+
fobj.write(json.dumps(new_fontlist, indent=2))
141+
142+
# Bump build number
143+
recipe["build"]["number"] = recipe["build"]["number"] + 1
144+
145+
with open(recipe_file, "w") as stream:
146+
yaml.safe_dump(
147+
recipe,
148+
stream,
149+
default_flow_style=False,
150+
sort_keys=False,
151+
)
152+
153+
# Commit and push
154+
branch_name = f"update-matplotlib-fontcache_for_{target_branch_name}"
155+
156+
with git_branch_ctx(branch_name, stash_current=False):
157+
# commit the changes and make a PR
158+
pr_title = f"Update matplotlib fontcache for matplotlib {matplotlib_version}"
159+
make_pr_for_recipe(recipe_dir=recipe_dir, pr_title=pr_title, branch_name=branch_name,
160+
target_branch_name=target_branch_name,
161+
automerge=True)

recipes/recipes/llvm-tblgen/recipe.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
context:
2-
version: 20.1.8
2+
version: 21.1.8
33

44
package:
55
name: llvm-tblgen
@@ -8,10 +8,10 @@ package:
88
source:
99
url: https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-${{ version
1010
}}.tar.gz
11-
sha256: a6cbad9b2243b17e87795817cfff2107d113543a12486586f8a055a2bb044963
11+
sha256: 7ba3f2a8d8fda88be18a31d011e8195d3b7f87f9fa92b20c94cba2d7f65b0e3f
1212

1313
build:
14-
number: 1
14+
number: 0
1515

1616
requirements:
1717
build:

recipes/recipes_emscripten/apsw/recipe.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
context:
2-
version: 3.51.1.0
2+
version: 3.51.2.0
33

44
package:
55
name: apsw
66
version: ${{ version }}
77

88
source:
99
url: https://pypi.io/packages/source/a/apsw/apsw-${{ version }}.tar.gz
10-
sha256: a3322d4f44b19693dc5e3d9b24339ecb2b5225e0ac8b00090b3c466d3c2e4dc6
10+
sha256: 916271dcf55fc3fd150354b6dbbf76d75a1a5e77cbefca3c3603a8b9c51f9529
1111

1212
build:
1313
number: 0

recipes/recipes_emscripten/arrow-cpp/recipe.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
context:
2-
version: 22.0.0
2+
version: 23.0.0
33

44
package:
55
name: arrow-cpp
66
version: ${{ version }}
77

88
source:
99
- url: https://github.com/apache/arrow/releases/download/apache-arrow-${{version}}/apache-arrow-${{version}}.tar.gz
10-
sha256: 131250cd24dec0cddde04e2ad8c9e2bc43edc5e84203a81cf71cf1a33a6e7e0f
10+
sha256: 12f6844a0ba3b99645cd2bc6cc4f44f6a174ab90da37e474f08b7d073433cb60
1111

1212
build:
1313
number: 0

recipes/recipes_emscripten/git2cpp/build.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ export CONFIG_CXXFLAGS="\
22
-Os \
33
-I$BUILD_PREFIX/include \
44
-Wno-deprecated-declarations \
5-
-fexceptions \
65
"
76

87
# stringToNewUTF8 and writeArrayToMemory are used by libgit2.
@@ -11,11 +10,11 @@ export CONFIG_LDFLAGS="\
1110
--minify=0 \
1211
-sALLOW_MEMORY_GROWTH=1 \
1312
-sEXIT_RUNTIME=1 \
14-
-sEXPORTED_RUNTIME_METHODS=FS,ENV,getEnvStrings,TTY,stringToNewUTF8,writeArrayToMemory \
13+
-sEXPORTED_RUNTIME_METHODS=FS,ENV,TTY,stringToNewUTF8,writeArrayToMemory \
1514
-sFORCE_FILESYSTEM=1 \
1615
-sMODULARIZE=1 \
17-
-fexceptions \
18-
--post-js $RECIPE_DIR/post.js \
16+
--pre-js $RECIPE_DIR/pre.js \
17+
-sSTACK_SIZE=1MB \
1918
"
2019

2120
export CXXFLAGS="$CXXFLAGS $CONFIG_CXXFLAGS"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From f79c6a604fb1a8216246af92ef34641e2402bd45 Mon Sep 17 00:00:00 2001
2+
From: Ian Thomas <ianthomas23@gmail.com>
3+
Date: Fri, 16 Jan 2026 10:10:25 +0000
4+
Subject: [PATCH] Simplify string split code
5+
6+
---
7+
src/utils/terminal_pager.cpp | 2 +-
8+
1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+
diff --git a/src/utils/terminal_pager.cpp b/src/utils/terminal_pager.cpp
11+
index e7fe551..1b79996 100644
12+
--- a/src/utils/terminal_pager.cpp
13+
+++ b/src/utils/terminal_pager.cpp
14+
@@ -200,7 +200,7 @@ void terminal_pager::split_input_at_newlines(std::string_view str)
15+
{
16+
auto split = str | std::ranges::views::split('\n')
17+
| std::ranges::views::transform([](auto&& range) {
18+
- return std::string(range.begin(), std::ranges::distance(range));
19+
+ return std::string(range.begin(), range.end());
20+
});
21+
m_lines = std::vector<std::string>{split.begin(), split.end()};
22+
}
23+
--
24+
2.50.1 (Apple Git-155)
25+
File renamed without changes.

0 commit comments

Comments
 (0)