No, FreeCAD ignores any other python on the system. If it doesn't it's a problem. This is why we can't use PYTHONPATH, PYHONHOME, etc.
I meant the python which is shipped with FreeCAD...
sgrogan wrote:All this being said, maybe we should just "force" a conda based approach? It does everything we want it to do. The users are resistant to change. We can offer an installer with limited flexibility, for those that prefer this, or a conda based approach where we use the conda based tools instead of the hacks I'm using now (to make it portable)?
Yes and no. The problem is still that conda is to difficult for someone who only want to use FreeCAD. In the long run people from conda will maybe come up with a solution to create a portable build, but in the meantime your approach is maybe the best solution...
Regarding the pip integration: I found a way which works for a pure conda environment and also for the portable build. I don't care much about the directory where all the user-packages are installed. Choosing it to be the default user-directory is for sure the simplest way. Maybe we can also add an option to select the user-pip-dir, but I guess this is not first priority.
So here some testing with the current pip-wrapper (I have also tested on linux with conda, but this is from the protable build on windows):
1. adding the scripts directory to the path (I guess this should be done by default (@sgrogan)
Code: Select all
>>> import os
>>> os.environ["PATH"] += "C:\\Users\\katja\\Downloads\\FreeCAD_0.18.14495_Conda_Py3QT5-WinVS2016_x64\\bin\\Scripts;"
1. import the pip-wrappers (extension module for freecad) and list all system packages. These packages are added to a temporary constraint file which is used during installation to not update these versions (stability).
Code: Select all
>>> from freecad.pip.app import pip
>>> pip.list_system()
[['certifi', '2018.8.13'], ['cycler', '0.10.0'], ['future', '0.16.0'], ['gitdb2', '2.0.4'], ['GitPython', '2.1.11'], ['kiwisolver', '1.0.1'], ['matplotlib', '2.2.2'], ['mkl-fft', '1.0.5'], ['mkl-random', '1.0.1'], ['numpy', '1.14.3'], ['pip', '18.0'], ['Pivy', '0.6.4'], ['pybind11', '2.3.dev0'], ['pyparsing', '2.2.0'], ['python-dateutil', '2.7.3'], ['pytz', '2018.5'], ['setuptools', '40.0.0'], ['six', '1.11.0'], ['smmap2', '2.0.4'], ['tornado', '5.1'], ['wheel', '0.31.1'], ['wincertstore', '0.2']]
2. list all editable packages (packages which are installed in "development mode", similar to symlinking)
3. list all user packages (packages installed into the --user directory)
4. try to install scipy
Code: Select all
>>> pip.install("scipy")
Collecting scipy
Using cached https://files.pythonhosted.org/packages/62/e2/364f0bcc641aeff79d743c732769d5dc31a1e78c27699229431412c4b425/scipy-1.1.0-cp36-none-win_amd64.whl
Requirement already satisfied: numpy==1.14.3 in c:\users\katja\downloads\freecad_0.18.14495_conda_py3qt5-winvs2016_x64\bin\lib\site-packages (from -c C:\Users\katja\AppData\Local\Temp\constraintsr9ygaxnp.txt (line 10)) (1.14.3)
Installing collected packages: scipy
Successfully installed scipy-1.1.0
5. check if it is installed in user directory
Code: Select all
>>> pip.list_user()
[['scipy', '1.1.0']]
6. try to install pandas and test it
Code: Select all
>>> pip.install("pandas")
Collecting pandas
Using cached https://files.pythonhosted.org/packages/0e/67/def5bfaf4d3324fdb89048889ec523c0903c5efab1a64c8dbe0ac8eec13c/pandas-0.23.4-cp36-cp36m-win_amd64.whl
Requirement already satisfied: python-dateutil==2.7.3 in c:\users\katja\downloads\freecad_0.18.14495_conda_py3qt5-winvs2016_x64\bin\lib\site-packages (from -c C:\Users\katja\AppData\Local\Temp\constraintsr9ygaxnp.txt (line 15)) (2.7.3)
Requirement already satisfied: pytz==2018.5 in c:\users\katja\downloads\freecad_0.18.14495_conda_py3qt5-winvs2016_x64\bin\lib\site-packages (from -c C:\Users\katja\AppData\Local\Temp\constraintsr9ygaxnp.txt (line 16)) (2018.5)
Requirement already satisfied: numpy==1.14.3 in c:\users\katja\downloads\freecad_0.18.14495_conda_py3qt5-winvs2016_x64\bin\lib\site-packages (from -c C:\Users\katja\AppData\Local\Temp\constraintsr9ygaxnp.txt (line 10)) (1.14.3)
Requirement already satisfied: six==1.11.0 in c:\users\katja\downloads\freecad_0.18.14495_conda_py3qt5-winvs2016_x64\bin\lib\site-packages (from -c C:\Users\katja\AppData\Local\Temp\constraintsr9ygaxnp.txt (line 18)) (1.11.0)
Installing collected packages: pandas
Successfully installed pandas-0.23.4
>>> import pandas as pd
>>> pd.DataFrame(pip.list_user(), columns=["name", "version"])
name version
0 pandas 0.23.4
1 scipy 1.1.0
>>> pd.DataFrame(pip.list(), columns=["name", "version"])
name version
0 certifi 2018.8.13
1 cycler 0.10.0
2 future 0.16.0
3 gitdb2 2.0.4
4 GitPython 2.1.11
5 kiwisolver 1.0.1
6 matplotlib 2.2.2
7 mkl-fft 1.0.5
8 mkl-random 1.0.1
9 numpy 1.14.3
10 pandas 0.23.4
11 pip 18.0
12 Pivy 0.6.4
13 pybind11 2.3.dev0
14 pyparsing 2.2.0
15 python-dateutil 2.7.3
16 pytz 2018.5
17 scipy 1.1.0
18 setuptools 40.0.0
19 six 1.11.0
20 smmap2 2.0.4
21 tornado 5.1
22 wheel 0.31.1
23 wincertstore 0.2
7. uninstall a user package
Code: Select all
>>> pip.uninstall("scipy")
Uninstalling scipy-1.1.0:
Successfully uninstalled scipy-1.1.0
8. try to uninstall a system package (numpy) -> I guess this should throw an exception, currently it prints a error message
Code: Select all
>>> pip.uninstall("numpy")
pkg is not a user-package
9. install package in development mode:
Code: Select all
>>> pip.install_develop("C:\\Users\\katja\\lo_projects\\OpenGlider")
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Users\katja\AppData\Roaming\Python\Python36\site-packages\freecad\pip\app.py", line 38, in install_develop
print_msg(process("pip", "install", "-e", fp, "--user", self._c_option()))
File "C:\Users\katja\AppData\Roaming\Python\Python36\site-packages\freecad\pip\app.py", line 13, in process
raise RuntimeError(err.decode("utf8"))
RuntimeError: The scripts dxfaudit.exe and dxfpp.exe are installed in 'C:\Users\katja\AppData\Roaming\Python\Python36\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
>>> pip.list_editable()
[['OpenGlider', '0.1']]
again we see the problem that bin/Scripts should be in path...
this operation also installed some dependencies:
Code: Select all
>>> pip.list_user()
[['ezdxf', '0.8.8'], ['ezodf', '0.3.2'], ['lml', '0.0.4'], ['odfpy', '1.3.5'], ['OpenGlider', '0.1'], ['pandas', '0.23.4'], ['pyexcel', '0.5.9.1'], ['pyexcel-io', '0.5.9.1'], ['pyexcel-ods', '0.5.3'], ['svgwrite', '1.1.12'], ['texttable', '1.4.0']]
so to me using pip with system packages constrained looks quite promising as this makes sense for virtual environments, FreeCAD installed in a system and bundles. Now we only have to find a way how to install to a custom user directory...