Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install IfcOpenShell WASM #10

Open
Michele-x98 opened this issue Sep 1, 2023 · 4 comments
Open

Unable to install IfcOpenShell WASM #10

Michele-x98 opened this issue Sep 1, 2023 · 4 comments

Comments

@Michele-x98
Copy link

Hello, i'm using pyodide and ifcopenshell wasm inside a React application but i got an error while the installation of the WASM file.
I placed the WASM file inside the root folder of my application, and then inside the App.js file i initialise the pyodide using the relative npm package inside a function that is called during the first render of the React component:

const { loadPyodide } = require("pyodide");
const initPyodide = async (code) => {
  const pyodide = await loadPyodide({
    indexURL : "https://cdn.jsdelivr.net/pyodide/v0.23.4/full/",
  });

  await pyodide.loadPackage("micropip");
  const micropip = await pyodide.pyimport("micropip");
  await micropip.install('../IfcOpenShell-0.7.0-py3-none-any.whl');
  console.log(await pyodide.runPython(`
            import ifcopenshell
            ifcopenshell.version`));

  return "IfcOpenShell loaded";
}

Everything works fine until the

 await micropip.install('../IfcOpenShell-0.7.0-py3-none-any.whl'); 

line, where an exception is thrown:

Screenshot 2023-09-01 at 07 29 59

I'm quite new to WASM and so on, if someone could help me and explain what i'm doing wrong i would appreciate it a lot.

@Michele-x98
Copy link
Author

Just to give a little bit more of context to whoever will read it and maybe gain some useful suggestions, what I'm currently trying to do is create a web platform that is able to load an IFC file, render the 3D model and allow the end-user to enrich the model with IoT sensor, allowing also to see changes on Subsection of the IfcSensor element in real-time. I was trying to do it everything in Python using Streamlit as Web Framework, but due to some limitations, i decided to try this new approach.

@aothms
Copy link
Member

aothms commented Sep 1, 2023

First thing I would imagine to try is to use the exact same pyodide version that we use in the example [0] as that is also the pyodide (and python interpreter version) used to compile the ifcopenshell native module.

[0] https://github.com/IfcOpenShell/wasm-preview/blob/master/index.html#L77C1-L77C110

I must admit I would expect a different error if that's the issue. Maybe something else to look at is what server do you use and whether the wheel is correctly served as a binary file. (When you download the .whl from your server and rename it to .zip are you able to open it using your default utility to open an archive?)

@Michele-x98
Copy link
Author

Michele-x98 commented Sep 1, 2023

Thanks for the reply, i have updated both the cdn version to 0.22.0a1 and the pyodide npm package to the same version, still the same error. It's weird because using the example [0] https://github.com/IfcOpenShell/wasm-preview/blob/master/index.html#L77C1-L77C110 it works as expected, but using it inside a react component it fails while loading the ifcopenshell library.

It also work the import of micropip:
Screenshot 2023-09-01 at 10 49 21

What do you mean for

download the .whl from your server

I have downloaded the .whl file from this the repository, did i made a mistake or misunderstood something?

@aothms
Copy link
Member

aothms commented Sep 1, 2023

What do you mean for

download the .whl from your server

I have downloaded the .whl file from this the repository, did i made a mistake or misunderstood something?

The error is actually quite clear:

zipfile.BadZipFile: File is not a zip file

So that's what I meant to investigate. What if it's really not a zip file when served from your server due to how it's served by react dev server or due to some corruption when you initially download it or maybe you get a 404 because the file doesn't exist there locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants