Closed looooo closed 5 years ago
Hey @looooo yeah I would really like to get the interface running. Unfortunately the API is not stabilized and therefore the FreeCAD interface code will not work, yet. We also did some effort to port the whole package to Py3 (we've accepted the PR just a few days ago.). So it should work with Py3 (except the ZMX parser because of this strange UTF16 files.)
Independent from that, I added the freecad
and freecad/PyrateWorkbench
to the setup.py and would like to know how the requirements.in
can be used to automatically load the packages from pip?
edit: updated setup.py according to your specifications.
https://packaging.python.org/discussions/install-requires-vs-requirements/#requirements-files
Whereas install_requires defines the dependencies for a single project, Requirements Files are often used to define the requirements for a complete Python environment.
So I guess you have to add the dependencies directly in the setup.py file. You can also have a look here: https://github.com/booya-at/OpenGlider/blob/develop/setup.py#L75L81
Thanks for the clarification. Is there a fast way to setup FreeCAD with python3 under linux? Such that I can test the workbench?
@looooo I just updated the imports in the PyrateWorkbench code. In Py27 it initializes at least without errors. If I load the workbench, the Log command is not found.
@joha2 the simplest way I know is conda. But conda also has it's difficulties. In case you want to try it:
initConda
)`alias initConda='export PATH="/home/lo/conda/bin:$PATH"'
for ubuntu18.04 you will also need to add a hack to get a useable freecad:
alias initConda='export QT_STYLE_OVERRIDE=gtk2&&export PATH="/home/lo/conda/bin:$PATH"'
then start a new terminal and type:
initConda
and create a new environment with freecad:
conda create -n freecad freecad scipy sympy pyyaml -c conda-forge
(as you can see, you can add several packages which should be part of the environment. This can be done also later with pip, but conda is the saver way to get more difficult dependencies installed)
once that is done the commands to activate that environment are printed. Once the freecad-env is actiavted start freecad with FreeCAD
. I guess this should be all.
to install and try pyrate, best install it with pip pip works for conda-environments like it does for your system. So you won't touch the system installed python-packages... you can also install scipy, sympy,
I also tested with py3 and found some obvious problems. Maybe you can have a look: https://github.com/joha2/pyrate/pull/38
@looooo thanks for cleaning up our mess for Py3 usability :-) I will try your description for setting up a mini conda environment for FreeCAD with Py3 support. Maybe this is also worth to be mentioned in our README.md file or in the wiki, isn't it?
The FreeCAD interface itself for pyrateoptics has to be rewritten completely, I think. So maybe these import problems vanish anyway in the future. For debugging the workbench it is really a pity that the errors do not come with a regular traceback (at least in the Py27 version). Is this fixed in the Py3 version? I spent a few minutes figuring out where the import problems have their origin.
btw. I merged your PR.
For debugging the workbench it is really a pity that the errors do not come with a regular traceback (at least in the Py27 version). Is this fixed in the Py3 version? I spent a few minutes figuring out where the import problems have their origin.
Yes, this is really a problem and it is even worse in py3. The best is to create a forum-topic for this issue. I will have a look in the next week
Yeah I will open the topic in the forum immediately. I think this traceback problem is persistent for years, there has to be a reason for it. But anyways: Big thanks for your efforts!
-> https://forum.freecadweb.org/viewtopic.php?f=10&p=254055#p254055
I do not know if this is the right place, but there are still some problems with py3: the first gui-command () fails with:
Running the Python command 'CreateSystemCommand' failed:
Traceback (most recent call last):
File "/home/lo/.local/lib/python3.6/site-packages/freecad/PyrateWorkbench/Commands_OpticalSystem.py", line 76, in Activated
osobs.initFromGivenOpticalSystem(osobs.initDemoSystem())
File "/home/lo/.local/lib/python3.6/site-packages/freecad/PyrateWorkbench/Observer_OpticalSystem.py", line 287, in initFromGivenOpticalSystem
for (key_elem, elem) in s.elements.iteritems():
'dict' object has no attribute 'iteritems'
should be s.elements.items() I guess there are more of these...
btw.: Installing with pip now works fine. I tried with using your branch directly:
pip intall https://github.com/joha2/pyrate/archive/master.zip --user
@looooo ah nice that the pip install works. Not so fine is that there are still py3 errors. I will check with 2to3.
@looooo now I fixed the most critical reports for 2to3. I am not sure why those files where not changed. Now 2to3 is only complaining about some list() casts which I should do.
@joha2 tested another time and the first command seems to work now. But I have to admit that I do not have any idea how the workbench works...
@looooo big thanks for testing and support! The interface is broken, anyway. We did not adapted it to the refactored code from mid 2017. I will update the thread in the forum, but I will put a remark there that the code is still buggy and the PR have to be merged into the main repo.
@looooo does the pip download work also for the freecad-daily version? (I.e. is it also in the Py27 version available?)
yes for linux. Windows is missing pip (and won't get support for pip because of binary incompatibility to the available py27-distributions). No idea about mac. I guess pip should be available.
Are there ideas about a failsafe solution (i.e. pip not available) available?
you can always install with python setup.py install
. But I guess the dependencies are the problem... In the end py2 will (hopefully) go away in 2020...
And the FreeCAD part? If pip is not available and the user wants to install the plugin (i.e. pyrate) with the addonmanager, how can I make my package cover this case? May I simply create an InitGui.py file where I from init_gui import *
as a wrapper? Or is there another possibility?
Simple copy the freecad dir to any path in sys.path. eg.: Ext/freecad/pyrate ...
What about the Mod/ subdirectory? In the past the addons had to be copied there.
No, this is not supported for the new modules.
@looooo I just realized another issue: When I installed pyrate via pip into my global python environment, FreeCADs addon manager realizes this, but cannot (obviously) uninstall the package. Is this a FreeCAD-Addon issue or do I have to take about that for myself in pyrate? Should the addon manager complain about pip installations which do not reside in the Mod directory?
Pip installable packages should not be installed with the current-add-on manager and should not be located in any Mod directory. But I am not sure if I have understood the question correctly.
@looooo thanks for your fast answer! Yeah the problem is that pyrate is still in the addon manager available as a download such that it is downloaded into the .FreeCAD/Mod directory. But I am not sure why this works anyway.
the setup.py must have an entry for the freecad package. Similar to this one here: https://github.com/FreeCAD/Workbench-Starterkit/blob/master/setup.py#L8L9
Also the requirements/dependencies are not installed in an automatic way. I did it manually with
pip install -r requirements.in
Launching freecad with py3 gives me this error:so I guess this still doesn't work with py3?
edit.: would be nice to make this work. Also to have another example for proper packaging for FreeCAD.