Skip to content

Commit

Permalink
Fix Windows Jupyterlab packaging
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Stein <steinlink@gmail.com>
  • Loading branch information
texodus committed Aug 5, 2024
1 parent 9a07402 commit c4e5b39
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,5 @@ rust/perspective-js/docs
rust/perspective-python/docs

.pyodide-*/
rust/perspective-python/perspective.data/data/share/jupyter/labextensions/@finos/perspective-jupyterlab/static
rust/perspective-python/perspective.data/data/share/jupyter/labextensions/@finos/perspective-jupyterlab/package.json
rust/perspective-python/*.data
# rust/perspective-python/perspective.data/data/share/jupyter/labextensions/@finos/perspective-jupyterlab/package.json
1 change: 0 additions & 1 deletion packages/perspective-jupyterlab/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"jupyterlab": {
"webpackConfig": "./webpack.config.js",
"extension": true,
"outputDir": "../../rust/perspective-python/perspective.data/data/share/jupyter/labextensions/@finos/perspective-jupyterlab",
"sharedPackages": {
"@jupyter-widgets/base": {
"bundled": false,
Expand Down
20 changes: 16 additions & 4 deletions packages/perspective-jupyterlab/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,29 @@
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

const CopyPlugin = require("copy-webpack-plugin");
const fs = require("node:fs");
const path = require("path");

const pkg = JSON.parse(fs.readFileSync("../../package.json").toString());
const version = pkg.version.replace(/-(rc|alpha|beta)\.\d+/, (x) =>
x.replace("-", "").replace(".", "")
);

const psp_dir = `perspective_python-${version}.data`;

module.exports = {
output: {
path: path.join(
__dirname,
`../../rust/perspective-python/${psp_dir}/data/share/jupyter/labextensions/@finos/perspective-jupyterlab`
),
},
experiments: {
topLevelAwait: true,
},
plugins: [
new CopyPlugin({
patterns: [
{ from: "./install.json", to: "../install.json" },
// { from: "other", to: "public" },
],
patterns: [{ from: "./install.json", to: "../install.json" }],
}),
],
};
8 changes: 8 additions & 0 deletions rust/perspective-python/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

import { execSync } from "child_process";
import * as fs from "node:fs";
import pkg from "./package.json" assert { type: "json" };

let flags = "--release";
if (!!process.env.PSP_DEBUG) {
Expand All @@ -25,6 +27,12 @@ const opts = {
},
};

const version = pkg.version.replace(/-(rc|alpha|beta)\.\d+/, (x) =>
x.replace("-", "").replace(".", "")
);

fs.mkdirSync(`./perspective_python-${version}.data`);

const build_wheel = !!process.env.PSP_BUILD_WHEEL;
const build_sdist = !!process.env.PSP_BUILD_SDIST;

Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions rust/perspective-python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ build-backend = "maturin"

[project]
name = "perspective-python"
version = "3.0.0-rc1"
version = "3.0.0-rc.1"
requires-python = ">=3.9"
dynamic = ["version"]
classifiers = [
Expand All @@ -26,7 +26,7 @@ classifiers = [

[tool.maturin]
module-name = "perspective"
data = "perspective.data"
data = "perspective_python-3.0.0rc2.data"
features = ["pyo3/extension-module"]

[tool.pytest.ini_options]
Expand Down
20 changes: 9 additions & 11 deletions tools/perspective-scripts/repack_wheel.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@

import { execSync } from "node:child_process";
import * as fs from "node:fs";
import * as path from "node:path";
import pkg from "../../package.json" assert { type: "json" };

const __dirname = new URL(".", import.meta.url).pathname;

const wheel_file = fs.readdirSync(".").filter((x) => x.endsWith(".whl"))[0];
const pkg_name = wheel_file.split("-").slice(0, 2).join("-");
execSync(`wheel unpack ${wheel_file}`);

fs.cpSync(
path.join(__dirname, "../../rust/perspective-python/perspective.data"),
`${pkg_name}/perspective_python-${pkg.version.replace(/-rc\.\d+/, (x) =>
x.replace("-", "").replace(".", "")
)}.data`,
{ recursive: true }
const pkg_name = wheel_file.split("-").slice(0, 2).join("-");
const version = pkg.version.replace(/-(rc|alpha|beta)\.\d+/, (x) =>
x.replace("-", "").replace(".", "")
);

const dest = `${pkg_name}/perspective_python-${version}.data`;
const src = `rust/perspective-python/perspective_python-${version}`;
fs.cpSync(src, dest, {
recursive: true,
});

execSync(`wheel pack ${pkg_name}`);

0 comments on commit c4e5b39

Please sign in to comment.