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

[wip] create a flatpak #76

Closed
wants to merge 1 commit into from
Closed

[wip] create a flatpak #76

wants to merge 1 commit into from

Conversation

njourdane
Copy link

@njourdane njourdane commented Aug 10, 2019

/!\ do not merge - not working yet /!\

An attempt to fix #70.

I have no experience building flatpacks, I followed flatpak documentation.

It's not working yet, but well, it's a start.

Usage (for now):

sudo apt install flatpak flatpak-builder # or equivalent for your system
cd flatpak
flatpak install flathub org.kde.Sdk//5.12 org.kde.Platform//5.12
flatpak-builder --force-clean cadquery-editor org.cadquery.cadquery-editor.yaml 
flatpak-builder --run cadquery-editor org.cadquery.cadquery-editor.yaml CQ-editor

This fails with this error:

Traceback (most recent call last):
  File "site-packages/OCC/Core/Visualization.py", line 18, in swig_import_helper
  File "importlib/__init__.py", line 126, in import_module
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'OCC.Core._Visualization'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "run.py", line 9, in <module>
  File "/home/adam/anaconda2/envs/cgqui4/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
  File "cq_editor/__main__.py", line 12, in <module>
  File "/home/adam/anaconda2/envs/cgqui4/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
  File "cq_editor/main_window.py", line 10, in <module>
  File "/home/adam/anaconda2/envs/cgqui4/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
  File "cadquery/__init__.py", line 3, in <module>
  File "/home/adam/anaconda2/envs/cgqui4/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
  File "cadquery/occ_impl/shapes.py", line 98, in <module>
  File "/home/adam/anaconda2/envs/cgqui4/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
  File "site-packages/OCC/Core/Visualization.py", line 21, in <module>
  File "site-packages/OCC/Core/Visualization.py", line 20, in swig_import_helper
  File "importlib/__init__.py", line 126, in import_module
ImportError: libGLU.so.1: cannot open shared object file: No such file or directory
[4] Failed to execute script run

Maybe it's because there is hardcoded paths in the repo?

edit: add flatpak command to download runtimes

@Peque
Copy link

Peque commented Aug 10, 2019

I remember getting that error. Do not remember which was the solution, but you may want to try with adding these dependencies:

@njourdane
Copy link
Author

I tried to not copy the dependencies folder, because I'm not supposed to do this since the main command is executed from , and now I have this error:

flatpak: libuuid.so.1: no version information available (required by /usr/lib/libappstream-glib.so.8)
flatpak: symbol lookup error: /usr/lib/libgio-2.0.so.0: undefined symbol: g_ref_count_inc
Error: module cadquery-editor: Child process exited with code 127

Do you think this means that cqe libraries are not recognized?

@Peque
Copy link

Peque commented Aug 13, 2019

@roipoussiere I have no idea sorry. 🤷‍♀️ 😅

@jmwright
Copy link
Member

@roipoussiere I'm guessing it's a version mismatch (lower version number) that doesn't include g_ref_count_inc.

@dumblob
Copy link

dumblob commented Nov 27, 2019

I think having a flatpak with CadQuery would be great. Keep up the work!

@njourdane
Copy link
Author

This week I took over the development of a flatpak for cq-editor.

The goal is to publish an all-in-one app that can be easily installed (several clicks or one command line) on all Linux distributions, without using Conda (I personally always have troubles with it).

More precisely, I'm currently working 4 flatpaks:

Since those 2 lasts are CadQuery dependencies, it does't require so much effort for me to publish them but will potentially be useful for some users, so it's a good deal.

I created 2 flatpaks for CQ oce and occt in order to anticipate the cq transition to occt, while working on a ready to use cq flatpak based on oce. By the way I'm interested by some explanations about this transition to occt, I noted the presence of the OCP repo and the cq ocp branch but I don't know if it's currently working or not.

Note that I created dedicated repositories with the idea of publishing them on flathub (I will add them in its Github organization), but of course the flatpak manifest could also be included in the CadQuery/cq-editor repository if you want.

Once finished, I may eventually work on a Snap app, which is an other application packaging system similar to Flatpak (this will not be so difficult is the flatpak is functional).

I'm currently facing some issues concerning the CadQuery Flatpak development, I list them here, maybe you can help on some of them (I also have other issues that I'm investigating by myself before to create news tickets):

@dumblob
Copy link

dumblob commented May 9, 2020

@roipoussiere that's great you found some time for this. I've looked at the issues you linked but unfortunately can't help off my head with them though I'd love to support the work if it won't eat up much time. If you have any other issues, don't hesitate and ask.

@jmwright
Copy link
Member

@roipoussiere Thanks for taking this on.

By the way I'm interested by some explanations about this transition to occt, I noted the presence of the OCP repo and the cq ocp branch but I don't know if it's currently working or not.

Some tests are still failing, but there is a lot of work going into OCP, and the plan is that it will replace PythonOCC as our OCCT bindings.

@njourdane
Copy link
Author

Some tests are still failing, but there is a lot of work going into OCP, and the plan is that it will replace PythonOCC as our OCCT bindings.

@jmwright Do you think it will be usable soon? Maybe it's better for me to focus on the OCP version for the flatpak.

Anyway, I don't really understand how to install OCP on Linux, even after looked at the azure-pipelines file as explained in the readme, can you briefly explain?

@jmwright
Copy link
Member

@roipoussiere If you don't need the bleeding edge updates, you can download the OCP*.so file from releases. https://github.com/CadQuery/OCP/releases

And then currently you have to use that with the OCP branch of CadQuery. The OCP branch will eventually be merged into master once it's stable enough.

@njourdane
Copy link
Author

@roipoussiere If you don't need the bleeding edge updates, you can download the OCP*.so file from releases. https://github.com/CadQuery/OCP/releases

Thanks. OCP import works but the tests fails because OCP.gp can not be imported. Same for you @jmwright?

click to expand
EEEEEEEE
======================================================================
ERROR: test_cad_objects (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_cad_objects
Traceback (most recent call last):
  File "/usr/lib/python3.7/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/run/build/cadquery/cadquery/tests/test_cad_objects.py", line 5, in 
    from tests import BaseTest
  File "/app/lib/python3.7/site-packages/tests/__init__.py", line 1, in 
    from cadquery import *
  File "/app/lib/python3.7/site-packages/cadquery/__init__.py", line 2, in 
    from .occ_impl.geom import Plane, BoundBox, Vector, Matrix
  File "/app/lib/python3.7/site-packages/cadquery/occ_impl/geom.py", line 3, in 
    from OCP.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp_GTrsf, gp, gp_XYZ
ModuleNotFoundError: No module named 'OCP.gp'
le>
    from OCC.Core.gp import (
======================================================================
ERROR: test_cadquery (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_cadquery
Traceback (most recent call last):
  File "/usr/lib/python3.7/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/run/build/cadquery/cadquery/tests/test_cadquery.py", line 11, in 
    from pytest import approx
ModuleNotFoundError: No module named 'pytest'
  File "/run/build/cadquery/cadquery/tests/test_cadquery.py", line 11, in 
    from pytest import approx
======================================================================
ERROR: test_cqgi (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_cqgi
Traceback (most recent call last):
  File "/usr/lib/python3.7/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/run/build/cadquery/cadquery/tests/test_cqgi.py", line 10, in 
    from cadquery import cqgi
  File "/app/lib/python3.7/site-packages/cadquery/__init__.py", line 2, in 
    from .occ_impl.geom import Plane, BoundBox, Vector, Matrix
  File "/app/lib/python3.7/site-packages/cadquery/occ_impl/geom.py", line 3, in 
    from OCP.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp_GTrsf, gp, gp_XYZ
ModuleNotFoundError: No module named 'OCP.gp'
    from OCC.Core.gp import (
ModuleNotFoundError: No module named 'OCC'
======================================================================
ERROR: test_exporters (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_exporters
Traceback (most recent call last):
  File "/usr/lib/python3.7/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/run/build/cadquery/cadquery/tests/test_exporters.py", line 9, in 
    from cadquery import *
  File "/app/lib/python3.7/site-packages/cadquery/__init__.py", line 2, in 
    from .occ_impl.geom import Plane, BoundBox, Vector, Matrix
  File "/app/lib/python3.7/site-packages/cadquery/occ_impl/geom.py", line 3, in 
    from OCP.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp_GTrsf, gp, gp_XYZ
ModuleNotFoundError: No module named 'OCP.gp'
ModuleNotFoundError: No module named 'OCC'

======================================================================
ERROR: test_importers (unittest.loader._FailedTest)

ImportError: Failed to import test module: test_importers
Traceback (most recent call last):
File "/usr/lib/python3.7/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
import(name)
File "/run/build/cadquery/cadquery/tests/test_importers.py", line 8, in
from cadquery import *
File "/app/lib/python3.7/site-packages/cadquery/init.py", line 2, in
from .occ_impl.geom import Plane, BoundBox, Vector, Matrix
File "/app/lib/python3.7/site-packages/cadquery/occ_impl/geom.py", line 3, in
from OCP.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp_GTrsf, gp, gp_XYZ
ModuleNotFoundError: No module named 'OCP.gp'

======================================================================
ERROR: test_jupyter (unittest.loader._FailedTest)

ImportError: Failed to import test module: test_jupyter
Traceback (most recent call last):
File "/usr/lib/python3.7/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
import(name)
File "/run/build/cadquery/cadquery/tests/test_jupyter.py", line 1, in
from tests import BaseTest
File "/app/lib/python3.7/site-packages/tests/init.py", line 1, in
from cadquery import *
File "/app/lib/python3.7/site-packages/cadquery/init.py", line 2, in
from .occ_impl.geom import Plane, BoundBox, Vector, Matrix
File "/app/lib/python3.7/site-packages/cadquery/occ_impl/geom.py", line 3, in
from OCP.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp_GTrsf, gp, gp_XYZ
ModuleNotFoundError: No module named 'OCP.gp'

======================================================================

ERROR: test_selectors (unittest.loader._FailedTest)

ImportError: Failed to import test module: test_selectors
Traceback (most recent call last):
File "/usr/lib/python3.7/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
import(name)
File "/run/build/cadquery/cadquery/tests/test_selectors.py", line 17, in
from tests import BaseTest, makeUnitCube, makeUnitSquareWire
File "/app/lib/python3.7/site-packages/tests/init.py", line 1, in
from cadquery import *
File "/app/lib/python3.7/site-packages/cadquery/init.py", line 2, in
from .occ_impl.geom import Plane, BoundBox, Vector, Matrix
File "/app/lib/python3.7/site-packages/cadquery/occ_impl/geom.py", line 3, in
from OCP.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp_GTrsf, gp, gp_XYZ
ModuleNotFoundError: No module named 'OCP.gp'

ERROR: test_workplanes (unittest.loader._FailedTest)

ERROR: test_workplanes (unittest.loader._FailedTest)

ImportError: Failed to import test module: test_workplanes
Traceback (most recent call last):
File "/usr/lib/python3.7/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.7/unittest/loader.py", line 377, in _get_module_from_name
import(name)
File "/run/build/cadquery/cadquery/tests/test_workplanes.py", line 7, in
from cadquery import *
File "/app/lib/python3.7/site-packages/cadquery/init.py", line 2, in
from .occ_impl.geom import Plane, BoundBox, Vector, Matrix
File "/app/lib/python3.7/site-packages/cadquery/occ_impl/geom.py", line 3, in
from OCP.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp_GTrsf, gp, gp_XYZ
ModuleNotFoundError: No module named 'OCP.gp'


Ran 8 tests in 0.001s

FAILED (errors=8)

@adam-urbanczyk
Copy link
Member

Looks like OCP is not on you PYTHONPATH. Could you try running the tests like so python -m pytest instead of pytest?

@njourdane
Copy link
Author

njourdane commented May 16, 2020

Looks like OCP is not on you PYTHONPATH.

I can do a import OCP in a Python shell. But not import OCP.gp (neither from OCP import gp)

@njourdane
Copy link
Author

Could you try running the tests like so python -m pytest instead of pytest?

Not better.

cd cadquery/tests
python3 -m pytest
click to expand
================================ test session starts ================================
platform linux -- Python 3.7.4, pytest-5.4.2, py-1.8.1, pluggy-0.13.1
rootdir: /run/build/cadquery/cadquery
collected 0 items / 8 errors                                                        

====================================== ERRORS =======================================
____________________ ERROR collecting tests/test_cad_objects.py _____________________
ImportError while importing test module '/run/build/cadquery/cadquery/tests/test_cad_objects.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
init.py:1: in
from cadquery import *
../cadquery/init.py:2: in
from .occ_impl.geom import Plane, BoundBox, Vector, Matrix
../cadquery/occ_impl/geom.py:3: in
from OCP.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp_GTrsf, gp, gp_XYZ
E ModuleNotFoundError: No module named 'OCP.gp'
______________________ ERROR collecting tests/test_cadquery.py ______________________
ImportError while importing test module '/run/build/cadquery/cadquery/tests/test_cadquery.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
init.py:1: in
from cadquery import *
../cadquery/init.py:2: in
from .occ_impl.geom import Plane, BoundBox, Vector, Matrix
../cadquery/occ_impl/geom.py:3: in
from OCP.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp_GTrsf, gp, gp_XYZ
E ModuleNotFoundError: No module named 'OCP.gp'
________________________ ERROR collecting tests/test_cqgi.py ________________________
ImportError while importing test module '/run/build/cadquery/cadquery/tests/test_cqgi.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
init.py:1: in
from cadquery import *
../cadquery/init.py:2: in
from .occ_impl.geom import Plane, BoundBox, Vector, Matrix
../cadquery/occ_impl/geom.py:3: in
from OCP.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp_GTrsf, gp, gp_XYZ
E ModuleNotFoundError: No module named 'OCP.gp'
_____________________ ERROR collecting tests/test_exporters.py ______________________
ImportError while importing test module '/run/build/cadquery/cadquery/tests/test_exporters.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
init.py:1: in
from cadquery import *
../cadquery/init.py:2: in
from .occ_impl.geom import Plane, BoundBox, Vector, Matrix
../cadquery/occ_impl/geom.py:3: in
from OCP.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp_GTrsf, gp, gp_XYZ
E ModuleNotFoundError: No module named 'OCP.gp'
_____________________ ERROR collecting tests/test_importers.py ______________________
ImportError while importing test module '/run/build/cadquery/cadquery/tests/test_importers.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
init.py:1: in
from cadquery import *
../cadquery/init.py:2: in
from .occ_impl.geom import Plane, BoundBox, Vector, Matrix
../cadquery/occ_impl/geom.py:3: in
from OCP.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp_GTrsf, gp, gp_XYZ
E ModuleNotFoundError: No module named 'OCP.gp'
______________________ ERROR collecting tests/test_jupyter.py _______________________
ImportError while importing test module '/run/build/cadquery/cadquery/tests/test_jupyter.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
init.py:1: in
from cadquery import *
../cadquery/init.py:2: in
from .occ_impl.geom import Plane, BoundBox, Vector, Matrix
../cadquery/occ_impl/geom.py:3: in
from OCP.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp_GTrsf, gp, gp_XYZ
E ModuleNotFoundError: No module named 'OCP.gp'
_____________________ ERROR collecting tests/test_selectors.py ______________________
ImportError while importing test module '/run/build/cadquery/cadquery/tests/test_selectors.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
init.py:1: in
from cadquery import *
../cadquery/init.py:2: in
from .occ_impl.geom import Plane, BoundBox, Vector, Matrix
../cadquery/occ_impl/geom.py:3: in
from OCP.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp_GTrsf, gp, gp_XYZ
E ModuleNotFoundError: No module named 'OCP.gp'
_____________________ ERROR collecting tests/test_workplanes.py _____________________
ImportError while importing test module '/run/build/cadquery/cadquery/tests/test_workplanes.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
init.py:1: in
from cadquery import *
../cadquery/init.py:2: in
from .occ_impl.geom import Plane, BoundBox, Vector, Matrix
../cadquery/occ_impl/geom.py:3: in
from OCP.gp import gp_Vec, gp_Ax1, gp_Ax3, gp_Pnt, gp_Dir, gp_Trsf, gp_GTrsf, gp, gp_XYZ
E ModuleNotFoundError: No module named 'OCP.gp'
============================== short test summary info ==============================
ERROR test_cad_objects.py
ERROR test_cadquery.py
ERROR test_cqgi.py
ERROR test_exporters.py
ERROR test_importers.py
ERROR test_jupyter.py
ERROR test_selectors.py
ERROR test_workplanes.py
!!!!!!!!!!!!!!!!!!!!!! Interrupted: 8 errors during collection !!!!!!!!!!!!!!!!!!!!!!
================================= 8 errors in 0.24s =================================

@njourdane
Copy link
Author

njourdane commented May 16, 2020

fyi I do the following (assuming cadquery - the folder corresponding to cadquery repo at OCP branch - and OCP.cpython-36m-x86_64-linux-gnu.so are in the current directory):

mkdir -p /app/lib/python3.7/site-packages/OCP
mv OCP.cpython-36m-x86_64-linux-gnu.so /app/lib/python3.7/site-packages/OCP
cd cadquery
python3 setup.py install --prefix=${FLATPAK_DEST} --single-version-externally-managed --record=record.txt
python3 -m pytest

Also, in a python3 shell I can do:

import sys
>>> sys.path
['', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/usr/lib/python3.7/site-packages', '/app/lib/python3.7/site-packages']
>>> 'OCP' in sys.modules.keys()
True
>>> import OCP
>>> import OCP.gp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'OCP.gp'

@adam-urbanczyk
Copy link
Member

adam-urbanczyk commented May 16, 2020

Note that OCP.cpython-36m-x86_64-linux-gnu.so is build for python 3.6, you are using 3.7 it seems. Just dump OCP so in the cadquery folder and run python from there. There is no need to run tests from the cadquery/tests folder, just run it form the cadquery folder.

@njourdane
Copy link
Author

I have other projects to focus on right now, so if someone want to continue this work, feel free to contribute.

I reference my sources in this comments.

@ripxorip
Copy link

A (perhaps naive idea). Wouldnt it be possitle to pull the binary release for Linux and wrap that in a flatpak? Or at least use the same recepie when building it in the flatpak as for when its packaged here? @adam-urbanczyk ? Love the project btw

@njourdane
Copy link
Author

Since cadquery can now be installed with pip, I think it makes more sense to create a pip package for cadquery editor instead a flatpack.

@njourdane njourdane closed this Jun 2, 2022
@thepragandsensdiary
Copy link

now 2025... are there plans? seems simple to implement. It's extremely comfy to install programs with flatpak now, pip might not work for everyone, for example I don't want my computer to be filled with some random dependencies again.
Also, does this project support wayland? I believe it doesn't.
Big L tbh, I hate c++ but i'll eat my tongue and use openscad until solved.

@lorenzncode
Copy link
Member

Also, does this project support wayland?

I was able to open CQ-Editor on my machine with wayland.

Screenshot From 2025-01-11 12-53-06

@thepragandsensdiary
Copy link

I meant pure wayland, not Xwayland, it's fine on powerful pc's but my underpowered celeron can't stand the overhead of xwayland (xwayland-satellite). I'm referring to something like QT_QPA_PLATFORM=wayland, native wayland~

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

Successfully merging this pull request may close these issues.

Create flatpak and upload to flathub.org
8 participants