-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python modules not working in python 3.10 #2535
Comments
I did discover that manually setting
|
@proppy any thoughts? |
For reference, I'm trying to understand the design flow better which is very difficult to do with a Docker container. This was the last piece I had to solve in order to get it to work. I've succeeded in hardening the inverter sample project using the following invocation:
|
Did you gave the conda-eda installation a try? This shouldn't require any container, can should give you an easy to get an environment bootstrapped, also see hdl/conda-eda#247 |
I did see that, and I've been referring to that quite a bit when setting things up. It's been super helpful. I couldn't see where the PDK files were sourced from, which is what led me to start from there. |
@proppy do you understand why it wouldn't import the package in OR? |
What is sys.path in python3 versus OR? I just tried it locally and they are the same. |
@maliberty it must be because the system python lib directory doesn't get added to the module search path. This could be fixed by calling https://docs.python.org/3/c-api/init.html#c.Py_SetPath before init, but you'd have to detect it from the host python environment. |
I'm not very well-versed in the ways of Python, but I thought the general rule was to avoid using system python. Besides, users may not have the rights to install packages in the root. That's the reason why I went with a venv, and why the It seems as though the build process ignores any sort of venv and will use the system python regardless of whether there is another interpreter in the path. I just did a clean build of |
@proppy from https://docs.python.org/3/glossary.html#term-import-path
so it does seem to come from sys.path. |
Small precision, openroad is its own python interpreter, so having a different
Yes but in that case I believe @xobs has installed additional packages in a venv, which does not seem discoverable by the embedded python interpreter unless provided with @xobs can you check if setting |
@proppy however venv is passing that to the regular python interpreter should work the same for OR. |
Setting
|
by default venv create a symlink to the system python:
The default interpreter has a quite a bit logic in it, to resolve the default import path depending of the location executable/symlinks, the presence of a In the case of openroad since we embed the interpreter, my initial guess was that none of things that compute default import path relative to the
https://docs.python.org/3/library/sys_path_init.html#embedded-python |
Have we considered some sort of virtual environment management tool? It is very problematic to mess with the system python or install libraries there. Two possible tools to use: https://python-poetry.org/docs/ I personally prefer poetry because it is pretty straightforward to figure out and once it has created a "lock" file with all the dependencies... installation is a breeze. Also trivial to maintain multiple environments if your machine does other things than OpenRoad. |
@openroadie we do have openroad packages for conda, see https://anaconda.org/LiteX-Hub/openroad/ but this problem is a bit different as it refers to the python context embedded in the OpenROAD app executable (which would be different from the system Python). Since will eventually becomes moot once openroad starts shipping as a proper python packages (see #2308, #1812, #1424 and #2311) |
Incidentally, I'm experiencing this same issue in Conda:
Somehow, Similar to venvs, I can get it to work if I run:
|
That should already happen if you activate the conda environment. |
I've updated the bug to reflect what I believe is an issue with Python 3.10. It may be an issue for any version of Python after 3.7. This may be related to python/cpython#78189 where it seems somewhat questionable to call As an example, here is what happens if I use a venv on Linux with Python 3.10:
You can see that reloading In Conda on macos I see the exact same thing, where
When running Python by itself, the path is correct:
HOWEVER, when running
If I patch I beleive what is happening is this:
This is probably an issue in newer pythons, but I can't be sure. |
Here's an example showing that
|
We might be able to get python to reuse the existing initialized environment by using https://docs.python.org/3/c-api/init_config.html#c.Py_RunMain on >= 3.8. |
Describe the bug
The OpenLane project contains scripts that require external python modules. For example, lefutil.py requires a module called
click
.openroad includes a python interpreter, but does not appear to include support for installing 3rd party modules. As a result, openlane fails to run:
The build steps at https://github.com/The-OpenROAD-Project/OpenROAD#build do not document how to install these modules, and since the interactive interpreter does not support
pip
it is unclear how to proceed.Expected Behavior
Openroad should be usable with the scripts from openlane
Environment
To Reproduce
Run the following:
Relevant log output
No response
Screenshots
No response
Additional Context
I have tried the following, none of which have worked:
lib
directory from the venv to/opt/Si/
which is the prefix used by openroadThe text was updated successfully, but these errors were encountered: