Skip to content

Commit

Permalink
Precompiled system image default
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrekker committed Apr 10, 2024
1 parent 0a2ad7e commit f3bfcaa
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 22 deletions.
25 changes: 15 additions & 10 deletions .erb/scripts/beforePack.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,25 @@ const precompilePluto = async ({ julia_path }) => {
const SYSIMAGE_LOCATION = path.join(
assetPath,
// TODO: auto version number
'pluto-sysimage.so'
'pluto.so'
);

// immediately return if the sysimage has already been compiled
if (fs.existsSync(SYSIMAGE_LOCATION)) {
return new Promise((resolve) => resolve());
}

const PRECOMPILE_SCRIPT_LOCATION = path.join(assetPath, 'precompile.jl');
const PRECOMPILE_STATEMENTS_FILE_LOCATION = path.join(
const PRECOMPILE_EXECUTION_LOCATION = path.join(
assetPath,
'pluto_precompile.jl'
'precompile_execution.jl'
);
fs.writeFileSync(PRECOMPILE_STATEMENTS_FILE_LOCATION, '');

const res = spawn(julia_path, [
`--project=${path.join(assetPath, 'env_for_julia')}`,
PRECOMPILE_SCRIPT_LOCATION,
SYSIMAGE_LOCATION,
PRECOMPILE_STATEMENTS_FILE_LOCATION,
PRECOMPILE_EXECUTION_LOCATION,
]);

// stderr includes precompile status text
Expand Down Expand Up @@ -164,12 +168,13 @@ exports.default = async (context) => {
spinner1.success({ text: '\tExtracted!', mark: '✓' });
}

// NOT DOING THIS, see https://github.com/JuliaPluto/PlutoDesktop/issues/56
// await precompilePluto({
// julia_path: path.join(assetPath, JULIA_DIR_NAME, 'bin', 'julia.exe'),
// });

await prepareJuliaDepot({
julia_path: path.join(assetPath, JULIA_DIR_NAME, 'bin', 'julia.exe'),
});

// NOT DOING THIS, see https://github.com/JuliaPluto/PlutoDesktop/issues/56
// maybe we are... (CB)
await precompilePluto({
julia_path: path.join(assetPath, JULIA_DIR_NAME, 'bin', 'julia.exe'),
});
};
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ npm-debug.log.*

# Julia
assets/julia*
assets/pluto-sysimage.so
assets/pluto_precompile.jl
assets/pluto.so

# ENV
.env.local
Expand Down
8 changes: 3 additions & 5 deletions assets/precompile.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
copy!(LOAD_PATH, ["@"])
import Pkg; Pkg.instantiate()

# copy!(LOAD_PATH, ["@"])
import PackageCompiler
import Pluto

PackageCompiler.create_sysimage(["Pluto"];
sysimage_path=ARGS[1],
precompile_statements_file=ARGS[2],
)
precompile_execution_file=ARGS[2],
)
14 changes: 14 additions & 0 deletions assets/precompile_execution.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Pluto

const host, port = "127.0.0.1", 7221
baseurl = "http://$host:$port"

@async begin
Pluto.run(; host, port, require_secret_for_open_links=false, require_secret_for_access=false, launch_browser=false)
end



Pluto.HTTP.get("$baseurl")
Pluto.HTTP.get("$baseurl/new")
exit()
13 changes: 8 additions & 5 deletions src/main/startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function startup(app: App) {

statusUpdate('loading');

const SYSIMAGE_LOCATION = getAssetPath('pluto-sysimage.so');
const SYSIMAGE_LOCATION = getAssetPath('pluto.so');

// ensure depot has been copied from read-only installation directory to writable directory
if (!fs.existsSync(DEPOT_LOCATION)) {
Expand All @@ -42,10 +42,13 @@ export async function startup(app: App) {
}

const options = [`--project=${Globals.JULIA_PROJECT}`];
if (!process.env.DEBUG_PROJECT_PATH) {
if (fs.existsSync(SYSIMAGE_LOCATION))
options.push(`--sysimage=${SYSIMAGE_LOCATION}`);
}
// if (!process.env.DEBUG_PROJECT_PATH) {
if (fs.existsSync(SYSIMAGE_LOCATION))
options.push(`--sysimage=${SYSIMAGE_LOCATION}`);
generalLogger.info(
`System image found at ${SYSIMAGE_LOCATION}. Julia will use this instead of the default`
);
// }

options.push(getAssetPath('run_pluto.jl'));
// See run_pluto.jl for info about these command line arguments.
Expand Down

0 comments on commit f3bfcaa

Please sign in to comment.