mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 05:52:22 -04:00
Bypass install_name_tool invocation on macOS
Not sure when https://github.com/astral-sh/uv/issues/14893 will be ready, and this seems to solve the problem for now. Closes #4227
This commit is contained in:
parent
8d5c385c76
commit
06f9d41a96
3 changed files with 35 additions and 24 deletions
|
@ -30,6 +30,12 @@ lipo -create \
|
|||
-output "$APP_LAUNCHER/Contents/MacOS/launcher"
|
||||
cp "$OUTPUT_DIR/uv" "$APP_LAUNCHER/Contents/MacOS/"
|
||||
|
||||
# Build install_name_tool stub
|
||||
clang -arch arm64 -o "$OUTPUT_DIR/stub_arm64" stub.c
|
||||
clang -arch x86_64 -o "$OUTPUT_DIR/stub_x86_64" stub.c
|
||||
lipo -create "$OUTPUT_DIR/stub_arm64" "$OUTPUT_DIR/stub_x86_64" -output "$APP_LAUNCHER/Contents/MacOS/install_name_tool"
|
||||
rm "$OUTPUT_DIR/stub_arm64" "$OUTPUT_DIR/stub_x86_64"
|
||||
|
||||
# Copy support files
|
||||
ANKI_VERSION=$(cat ../../../.version | tr -d '\n')
|
||||
sed "s/ANKI_VERSION/$ANKI_VERSION/g" Info.plist > "$APP_LAUNCHER/Contents/Info.plist"
|
||||
|
@ -40,7 +46,7 @@ cp ../versions.py "$APP_LAUNCHER/Contents/Resources/"
|
|||
|
||||
# Codesign/bundle
|
||||
if [ -z "$NODMG" ]; then
|
||||
for i in "$APP_LAUNCHER/Contents/MacOS/uv" "$APP_LAUNCHER/Contents/MacOS/launcher" "$APP_LAUNCHER"; do
|
||||
for i in "$APP_LAUNCHER/Contents/MacOS/uv" "$APP_LAUNCHER/Contents/MacOS/install_name_tool" "$APP_LAUNCHER/Contents/MacOS/launcher" "$APP_LAUNCHER"; do
|
||||
codesign --force -vvvv -o runtime -s "Developer ID Application:" \
|
||||
--entitlements entitlements.python.xml \
|
||||
"$i"
|
||||
|
|
6
qt/launcher/mac/stub.c
Normal file
6
qt/launcher/mac/stub.c
Normal file
|
@ -0,0 +1,6 @@
|
|||
// Copyright: Ankitects Pty Ltd and contributors
|
||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
int main(void) {
|
||||
return 0;
|
||||
}
|
|
@ -261,11 +261,6 @@ fn handle_version_install_or_update(state: &State, choice: MainMenuChoice) -> Re
|
|||
None
|
||||
};
|
||||
|
||||
let have_venv = state.venv_folder.exists();
|
||||
if cfg!(target_os = "macos") && !have_developer_tools() && !have_venv {
|
||||
println!("If you see a pop-up about 'install_name_tool', you can cancel it, and ignore the warning below.\n");
|
||||
}
|
||||
|
||||
// Prepare to sync the venv
|
||||
let mut command = Command::new(&state.uv_path);
|
||||
command.current_dir(&state.uv_install_root);
|
||||
|
@ -277,17 +272,29 @@ fn handle_version_install_or_update(state: &State, choice: MainMenuChoice) -> Re
|
|||
}
|
||||
}
|
||||
|
||||
// remove CONDA_PREFIX/bin from PATH to avoid conda interference
|
||||
#[cfg(target_os = "macos")]
|
||||
if let Ok(conda_prefix) = std::env::var("CONDA_PREFIX") {
|
||||
if cfg!(target_os = "macos") {
|
||||
// remove CONDA_PREFIX/bin from PATH to avoid conda interference
|
||||
if let Ok(conda_prefix) = std::env::var("CONDA_PREFIX") {
|
||||
if let Ok(current_path) = std::env::var("PATH") {
|
||||
let conda_bin = format!("{conda_prefix}/bin");
|
||||
let filtered_paths: Vec<&str> = current_path
|
||||
.split(':')
|
||||
.filter(|&path| path != conda_bin)
|
||||
.collect();
|
||||
let new_path = filtered_paths.join(":");
|
||||
command.env("PATH", new_path);
|
||||
}
|
||||
}
|
||||
// put our fake install_name_tool at the top of the path to override
|
||||
// potential conflicts
|
||||
if let Ok(current_path) = std::env::var("PATH") {
|
||||
let conda_bin = format!("{conda_prefix}/bin");
|
||||
let filtered_paths: Vec<&str> = current_path
|
||||
.split(':')
|
||||
.filter(|&path| path != conda_bin)
|
||||
.collect();
|
||||
let new_path = filtered_paths.join(":");
|
||||
command.env("PATH", new_path);
|
||||
let exe_dir = std::env::current_exe()
|
||||
.ok()
|
||||
.and_then(|exe| exe.parent().map(|p| p.to_path_buf()));
|
||||
if let Some(exe_dir) = exe_dir {
|
||||
let new_path = format!("{}:{}", exe_dir.display(), current_path);
|
||||
command.env("PATH", new_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -930,14 +937,6 @@ fn handle_uninstall(state: &State) -> Result<bool> {
|
|||
Ok(true)
|
||||
}
|
||||
|
||||
fn have_developer_tools() -> bool {
|
||||
Command::new("xcode-select")
|
||||
.args(["-p"])
|
||||
.output()
|
||||
.map(|output| output.status.success())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
fn build_python_command(state: &State, args: &[String]) -> Result<Command> {
|
||||
let python_exe = if cfg!(target_os = "windows") {
|
||||
let show_console = std::env::var("ANKI_CONSOLE").is_ok();
|
||||
|
|
Loading…
Reference in a new issue