RhinoCode python 3.9.10 needs to be 3.9.16

@eirannejad 3.9

I need to use pypi>3.9.11

But RhinoCode python editor is based on python=3.9.10.

PyPi requirement is:
- pypy=7.3.11 -> python[version='3.8.16|3.9.16',build=0_73_pypy]

Is there any way to install newer python version?

Hello,

What are you trying to do? I don’t know whether Rhino supports the pypy interpreter pypy=7.3.11 (note the difference between the pypy interpreter and the pypi package index for CPython.

Any code which runs OK on CPython version 3.9.16 should also run with no problems on CPython 3.9.10, except in pretty unusual situations.

-Graham

I am trying to run nanobind. I will try with 3.8.16. I will keep posted if it works.

strange - the documentation suggests you just need to pip install (recommended) or conda install it.

It looks like they successfully build it using cmake on Windows with Python 3.9 on GitHub, Avoid casting ndarray_framework to and from int. · wjakob/nanobind@62181dc · GitHub

Just tested on my Windows machine - pip install nanobind works for me with Python 3.9.13

By 3.9 is actually 3.9.18, tried and confirmed by the author.

I have just tried to run 3.8.18 dont work as with pybind11.

If you could try on your side, I would be grateful.

You would need to do the following steps:

  1. Create conda environment: conda create -n wood python==3.8.16 pypy=7.3.11
  2. clone this repo that is a clone of nano example: https://github.com/petrasvestartas/wood_cpp_nano.git
  3. run in rhinocode folowing code:
import os
import os.path as op
import sys
import ctypes

CONDA_ENV = r'C:\Users\petras\.conda\envs\wood'
COMPAS_WOOD_PATH = r'C:\brg\2_code\wood_cpp_nano\build\pp38-pypy38_pp73-win_amd64\Release'

sys.path.append(op.join(CONDA_ENV, r"Lib\site-packages"))
sys.path.append(COMPAS_WOOD_PATH)
os.add_dll_directory(op.join(CONDA_ENV, r'Library\bin'))
os.add_dll_directory(COMPAS_WOOD_PATH)

import nanobind_example
print(nanobind_example.add(1, 2))

Have you pip install ./nanobind_example ? I think you would need to do that for the add function to be visible

1 Like

Tried that, which works, yay!
C:/Users/petras/.rhinocode/py39-rh8/python.exe -m pip install .
image

Although, I cannot run editable install though with -e:
C:/Users/petras/.rhinocode/py39-rh8/python.exe -m pip install -e .

ERROR: File "setup.py" or "setup.cfg" not found. Directory cannot be installed in editable mode: C:\brg\2_code\wood_cpp_nano
(A "pyproject.toml" file was found, but editable mode currently requires a setuptools-based build.)

Locally I can do it by pip install -e . but not for rhino python editor. Nano use pyproject.toml not setup.py which is a more preferred way to do that nowadays.
Any idea why?

1 Like

I’ve used nanobind and pybind11 by directly compiling from the cmakelists.txt. You should be able to do this on your computer and then just ship the compiled libaries.

@stevebaer Could you share your nanobind configuration?
For shipping to pip do you upload a wheel with .pyd files or something more?

hmm not sure - have you updated pip and setuptools (I usually do wheel at the same time too) to the latest versions ? Editable installs look very handy - I will have to try that next time I’m working on wrapping c++ code !

I did not try, but with other package editable works without issues just this nanobind example…

:upside_down_face: the dependencies of Python is really a nightmare

@Petras_Vestartas Python 3.9.10 deployment under .rhinocode/py39-rh8 has all the include/ and lib/ directories for building locally against this python version

  • Currently there is no way you can use another python version inside of Rhino.
  • If you are using a conda environment, make sure it is created for python 3.9.10
  • You can use pyenv to install any|multiple versions of python

I don’t have a nanobind example on hand, but rhino3dm uses pybind11 and builds wheels using setup.py. It would be the same process with nanobind

2 Likes

Thank you, luckily nanobind allows python 3.8.16 which work as pip installable :slight_smile:

1 Like

Thank you for the reference:) crazy amount of work to wrap opennurbs… wow