There are two key issues I have when developing python libraries and testing them on RhinoCode. I am using vscode and pip to install my local package to rhinocode python directory, since I am always working within a conda environment.
Following are key problems:
RESTART RHINO - everytime I add new code, methods or classes in vscode I need to reload rhino. First time you pip install your package like this: C:/Users/my_user_name/.rhinocode/py39-rh8/python.exe -m pip install -e .
But still rhino needs to be restarted every time you change code in Visual Studio Code.
CONDA - rhinocode uses its own environment so everything must be installed through PIP, this leads to two sub-problems:
2.1. I always need to switch between my conda environment and rhino editor since is impossible to work on conda.
2.2. The PIP only solution prevents to install conda packages specially c++ ones e.g. boost, cgal and others, let alone local packages that pip builds on c++ conda libraries.
I am wondering why the decision was made to have a stadalone python editor instead of more flexible conda environments that you switch simple everytime you work on different project? I think I heard this questions from multiple users.
I get that for fully polished libraries it is a great editor, but for development it is really slowing the work.
Using # env: /put/path/here/ on top of your script
We had an issue reloading imported modules in Python 3 runtime that is fixed for Rhino 8.6 RC. You can use importlib.reload method at the top of your script to reload the imported module when you are making changes to that in vscode
Our pip also had an issue installing some packages due to missing libraries in ~/.rhinocode/py39-rh8 folder. We have solved that for Rhino 8.5 RC that is out right now. It should be better now but let me know if it still can not install your packages. You can also add # venv: site-packages to the top of your script in case of problematic packages to install them in the default site-packages/ instead of site-envs/ as it normally does.
Thank you for a reply. The egg link works. But the problem I am facing now is .pyd file. By .pyd I am refererring to c++ compiled code of mine in my conda environment.
I compiled it using 3.9.10 version. But even manually adding the path to sys does not recognize it. I tried all sorts of different solutions the whole week…
Any suggestions how to load correctly .pyd?
I also thought about compiling my .pyd file using rhino Python.exe, but you do not redistribute Python39.lib nor python.h C++ headers.
Which python package is this? I am assuming you are adding the path to where the package folder exists and not the path that directly contains the .pyd files right? sys.path are search paths for where the package folder exist. Just checking to make sure
numpy has .pyd libraries and they seem to be working.
One other thing you can to test do is to add the path of where the .pyd files are loaded to the system PATH in environment variables and see if Rhino will find those when running the script. I’d like to know that if it does, so maybe I can improve this.
Also I do not know about .pyd files, but .dll always must have these two .dlls next to it, due to CGAL dependency. I have also an other version of code using ctypes library on python. But debugging through ctypes library c++ is really tedious and slow process. Meaning one c++ error, whole rhino crash. I really wish that I could directly load .pyd file instead of.
hitting this error when pip install-ing in editable mode. I am using python 3.9.10 installed with pyenv and latest pip. Is there anything else I need to setup to install this package?
Obtaining file:///C:/Users/ein/compas_wood
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... error
error: subprocess-exited-with-error
× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> [22 lines of output]
Traceback (most recent call last):
File "C:\Users\ein\.pyenv\pyenv-win\versions\3.9.10\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
main()
File "C:\Users\ein\.pyenv\pyenv-win\versions\3.9.10\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "C:\Users\ein\.pyenv\pyenv-win\versions\3.9.10\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 132, in get_requires_for_build_editable
return hook(config_settings)
File "C:\Users\ein\AppData\Local\Temp\pip-build-env-51sch7av\overlay\Lib\site-packages\setuptools\build_meta.py", line 441, in get_requires_for_build_editable
return self.get_requires_for_build_wheel(config_settings)
File "C:\Users\ein\AppData\Local\Temp\pip-build-env-51sch7av\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "C:\Users\ein\AppData\Local\Temp\pip-build-env-51sch7av\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
self.run_setup()
File "C:\Users\ein\AppData\Local\Temp\pip-build-env-51sch7av\overlay\Lib\site-packages\setuptools\build_meta.py", line 480, in run_setup
super().run_setup(setup_script=setup_script)
File "C:\Users\ein\AppData\Local\Temp\pip-build-env-51sch7av\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
exec(code, locals())
File "<string>", line 100, in <module>
File "<string>", line 42, in get_eigen_include
File "C:\Users\ein\.pyenv\pyenv-win\versions\3.9.10\lib\ntpath.py", line 78, in join
path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
The .dlls you see in screenshot I copied manually. But they do not have any effect. It is quite hard to debug the not found error you see. The .pyd is the one that is not linked properly.