realthunder / solvespace

Parametric 2d/3d CAD
http://solvespace.com/
GNU General Public License v3.0
15 stars 3 forks source link

building solvespace without gui components #1

Closed looooo closed 6 years ago

looooo commented 6 years ago

The origin project has an option to disable the gui [1]. Would it be possible to add such a feature to your fork. I guess most of the dificult dependecies are mainly for the gui. As the gui is not used for FreeCAD, it would be nice to build without it.

[1] https://github.com/solvespace/solvespace/blob/master/CMakeLists.txt#L37

looooo commented 6 years ago

I guess this is the relevant commit: https://github.com/solvespace/solvespace/commit/e127b28a2dcd4c7511eed7e881aa5c495cd392b1#diff-af3b638bc2a3e6c650974192a53c7291

realthunder commented 6 years ago

I have added a non-gui cmake target. To build only the python extension, make _slvs. The build instruction can be found at here.

But I haven't tried Python 3 yet.

looooo commented 6 years ago

I see, thanks. My problem are the gui dependencies which cmake tries to find. The origin project disable the find_package(xy) when BUILD_GUI is disabled.

realthunder commented 6 years ago

The commit you mentioned is not in my branch, because I am not basing on upstream master. If you are on windows, I think checking out out all the submodules should be enough to satisfy all the dependency. That's what I did.

looooo commented 6 years ago

I am trying to create a conda-package for linux and windows. There are builds for most of the dependencies available but not for some gui-stuff. Thats why I am asking to add this option.

I guess adding this option is not too much work, and I can try to do that, but I need to know if it makes sense. Are the gui-dependencies relevant for freecad? What dependencies are relevant for freecad?

realthunder commented 6 years ago

I see. And no, none of the gui stuff is needed.

looooo commented 6 years ago

what about libdxfrw?

realthunder commented 6 years ago

Not used either. The python extension _slvs only uses a small part of the whole solvespace project, just the solver part, namly libslvs, which I changed to a static library, libslvs_static. The compiled _slvs.so, or _slvs.pyd has no external dependency.

looooo commented 6 years ago

With some patching it seems like cmake accepts my setup now.

But now I am stuck with a more difficult error. Maybe you have an idea whats wrong here:

In file included from /opt/conda/conda-bld/solvespace_1530429004042/work/src/solvespace.h:291:0,
                 from /opt/conda/conda-bld/solvespace_1530429004042/work/src/lib.cpp:7:
/opt/conda/conda-bld/solvespace_1530429004042/work/src/dsc.h:264:10: error:   initializing argument 1 of ‘void SolveSpace::IdList<T, H>::Add(T*) [with T = SolveSpace::Constraint; H = SolveSpace::hConstraint]’ [-fpermissive]
     void Add(T *t) {
          ^
/opt/conda/conda-bld/solvespace_1530429004042/work/src/lib.cpp:249:16: warning: missing initializer for member ‘SolveSpace::Group::tag’ [-Wmissing-field-initializers]
     Group g = {};

I am using gcc4.8.2 from centos.

realthunder commented 6 years ago

Which target are you compiling? The python extension target _slvs depends on my newly added target named slvs_static. It is similar to their original library target, slvs. When building SolveSpace as a library, you need to define a macro LIBRARY. See here. The error suggests you are missing this macro.

looooo commented 6 years ago

I am building the _slvs target. see this recipe: https://github.com/FreeCAD/FreeCAD_Conda/blob/master/solvespace/build.sh

looooo commented 6 years ago

Looking at the cmake, there seems to be a static library (static_slvs) and a shared library (slvs). And the python library also depends on slvs (the shared library). I am using now the master branch of this repo. Which branch should I use?

realthunder commented 6 years ago

If you are cloning my fork, you can use the python branch. But it seems you've already using this branch according to your meta.yaml file. I guess the install target in your build.sh is causing the problem. Are there any wiki I can read about freecad conda setup? Maybe I'll give it a try.

looooo commented 6 years ago

https://github.com/FreeCAD/FreeCAD_Conda#how-to-install-freecad-with-conda but the docs are not in very good shape. Things are changing too fast. To install freecad with conda only the conda-forge channel is needed. (So do not add freecad-channel and cad-channel) I can also provide linux and windows builds for your FreeCAD-fork.

without the install target the recipe works, but nothing gets installed. to build the package everything should be installed to the host-env. Maybe we can simple copy the output of the build.

looooo commented 6 years ago

I was able to create the package with copying the _slvs.so file directly [1]. (not the best solution but at least it seems to work) I also removed the runtime-deps, so the build only depends on python. It seems to be importable in python and FreeCAD.

But the assembly3 modul still doesn't work with the python3 build of the freecad-link-fork.

[1] https://anaconda.org/freecad/solvespace/files

looooo commented 6 years ago

also there is a build from your FreeCAD-fork available now. I couldn't upload to anaconda.org because my internet is too slow. But I was able to upload to github. The package is now available from https://github.com/FreeCAD/FreeCAD_Conda/releases (freecad_assembly). I guess you can install it by creating a freecad environment and uninstall freecad with (-f) option and install freecad_assembly by using the path to the package. (Not the best way. I will try improve this.)

So now we only have to get assembly3-wb python3 compatible (https://github.com/realthunder/FreeCAD_assembly3/issues/14)

I keep this Issue open because I think it's a good idea to have the no-gui option available. But this will be solved anyway once you rebase on the tip of the current project. (No idea if this will happen, or if the symp/scipy-solver is the more important goal.

realthunder commented 6 years ago

I have successfully install freecad-conda on Linux with asm3, using your suggested method.

In case anyone want to try this now, here is what I did.

looooo commented 6 years ago

nice, but I think you have done it the hard way. I guess using some conda-commands will help with setting up the environment. The freecad-0.17 install was a test to check if it is easier to get freecad installed this way. But I still prefer installing miniconda and then creating a seperate freecad-environment... Once I upload the freecad_assembly-package things will get a bit more simple.

Also note that the libraries coming with freecad-0.17-conda-installer-Linux-x86_64.sh are outdated. I guess the linking you have done is not necessary with the newer packages.

realthunder commented 6 years ago

@looooo I've made some change to SolveSpace code. Please update the conda package. Thanks!

looooo commented 6 years ago

Yes I will do. Can you:

realthunder commented 6 years ago

Done at here

looooo commented 6 years ago

thanks, done: