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

osecore exception with FreeCAD 0.19.1 OSE3DPrinter add-on #66

Closed
rayrrr opened this issue Mar 16, 2021 · 3 comments
Closed

osecore exception with FreeCAD 0.19.1 OSE3DPrinter add-on #66

rayrrr opened this issue Mar 16, 2021 · 3 comments

Comments

@rayrrr
Copy link

rayrrr commented Mar 16, 2021

Hi @gbroques! I'm happy to report that 3 days ago FreeCAD 0.19.1 was quietly released. Only the source code is available so far but I compiled it and it looks much better than the older versions overall, and the formerly-broken add-on manager works like a charm!

However, I tried installing the OSE 3D Printer workbench but got the following exception and traceback:

During initialization the error "No module named 'osecore'" occurred in freecad.ose3dprinter
--------------------------------------------------------------------------------
Traceback (most recent call last):
  File "<string>", line 156, in InitApplications
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/root/.FreeCAD/Mod/OSE3dPrinter/freecad/ose3dprinter/init_gui.py", line 6, in <module>
    from .OSE_3D_Printer import register_commands
  File "/root/.FreeCAD/Mod/OSE3dPrinter/freecad/ose3dprinter/OSE_3D_Printer.py", line 4, in <module>
    from .command import (AddExtruderCommand, AddFrameCommand, AddHeatedBedCommand,
  File "/root/.FreeCAD/Mod/OSE3dPrinter/freecad/ose3dprinter/command/__init__.py", line 2, in <module>
    from ._add_axis import AddXAxisCommand, AddYAxisCommand, AddZAxisCommand
  File "/root/.FreeCAD/Mod/OSE3dPrinter/freecad/ose3dprinter/command/_add_axis/__init__.py", line 1, in <module>
    from .add_x_axis_command import AddXAxisCommand
  File "/root/.FreeCAD/Mod/OSE3dPrinter/freecad/ose3dprinter/command/_add_axis/add_x_axis_command.py", line 1, in <module>
    from osecore.app.three_dimensional_space_enums import CoordinateAxis
ModuleNotFoundError: No module named 'osecore'

How does one install osecore? Is there some way to include this with the add-on? If not can we consider writing install instructions and/or releasing a PyPi package to make installation smoother?

I really want to get this working for the final OSE Linux 2.0 release...thanks for all your efforts!

@gbroques
Copy link
Owner

gbroques commented Mar 16, 2021

Hi @rayrrr, this issue is really more appropriate for the ose-3d-printer-workbench repository.

I cover how to install ose-workbench-core under the Installation section in ose-3d-printer-workbench's README.

  1. Download the workbench as a ZIP archive and extract, or use command-line git to clone the repository into the correct location (e.g. ~/.FreeCAD/Mod/ose-3d-printer-workbench)
  2. Follow step 2 for ose-workbench-core by downloading or cloning into the same directory (e.g. ~/.FreeCAD/Mod/ose-workbench-core).

You are not the first person to have issues with this. See gbroques/ose-3d-printer-workbench#99.

Is there some way to include this with the add-on?

Not without committing the entire ose-workbench-core package into ose-3d-printer-workbench, or using git submodules. I'd rather avoid both of these approaches.

The reason this installation process isn't smoother is FreeCAD does not have built in support for workbenches that depend upon pip-installable PyPI packages yet.

I'm hoping they address this in the future and we can install in a single command like:

# This would install ose-workbench-core as it's a dependency
pip install ose-3d-printer-workbench

Let me know if you have ideas to improve the installation process or make the instructions clearer! :)

...thanks for all your efforts!

Likewise, thank you sir!

@rayrrr
Copy link
Author

rayrrr commented Mar 16, 2021

@gbroques I did some research last night and I think the answer could be to leverage Python PEP-587. From the abstract:

Add a new C API to configure the Python Initialization providing finer control on the whole configuration and better error reporting.

It becomes possible to read the configuration and then override some computed parameters before it is applied. It also becomes possible to completely override how Python computes the module search paths (sys.path).

I added the emphasis at the end there to highlight what I believe the relevant implication of PEP-587: in a C application with an embedded Python which is Python 3.8 or above, the C application can also manage its own Python virtualenv, so that FreeCAD Add-Ons such as OSE Workbenches can declare PyPi dependencies like the OSECore Python Module (if we ship it to PyPI as a package). It should then be possible for the C application to load and resolve those dependencies into its own virtualenv automatically via pip under the hood when using the GUI-based Add-On Manager (which is already written in Python) so FreeCAD end users don't have to deal with hidden directories or git cloning.

However, this was implemented in Python 3.8 and the Python interpreter currently embedded in FreeCAD 0.19.1 is running Python 3.7.6. So, this would involve some significant upstream changes, but given that it would greatly increase the potential power of the Add-Ons system, it might get some traction. What do you think?

@gbroques
Copy link
Owner

gbroques commented Mar 16, 2021

On a quick read, the PEP-587 went a bit over my head. 😅

I will have to read this in more depth, but it sounds promising! 😄

As far as:

It should .. be possible ... to load and resolve ... dependencies ... via pip under the hood when using the GUI-based Add-On Manager ... so FreeCAD end users don't have to deal with hidden directories or git cloning.

There's been a fair amount of talk in the FreeCAD community about this and some initial proof-of-concept work as well:

Primarily by a fellow named "looooo".

I do not know the underlying technical details of it and whether each package could have it's own versions of dependencies, or each package must use the same version of a shared dependency.


P.S.

such as OSE Workbenches can declare PyPi dependencies like the OSECore Python Module (if we ship it to PyPI as a package)

To clarify, both ose-3d-printer-workbench and ose-workbench-core are able to be installed via pip and hosted on PyPI already.

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