benfogle / crossenv

Cross-compiling virtualenv for Python
MIT License
112 stars 22 forks source link

Can't create venv #6

Closed thomascatlee closed 5 years ago

thomascatlee commented 5 years ago

python -m crossenv /home/lx/platform3798C/pub/hi3798cv200/rootbox/usr/bin/python3.5 hisi_python --system-site-packages

Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 174, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.5/runpy.py", line 133, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib/python3.5/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 14, in <module>
    from pip.utils import get_installed_distributions, get_prog
  File "/usr/lib/python3/dist-packages/pip/utils/__init__.py", line 30, in <module>
    from pip._vendor.retrying import retry
ImportError: No module named 'pip._vendor.retrying'
ERROR: Command '['/home/lx/hisi_python/cross/bin/python', '-m', 'pip', '--disable-pip-version-check', 'install', '--ignore-installed', '--prefix=/home/lx/hisi_python/cross', 'pip==8.1.1', 'setuptools==20.7.0']' returned non-zero exit status 1

the cross/bin/python is a py file, that convert PATH between BUILD and HOST, I tested with test.py

import sys
print(sys.path)

it works. But when I use crosspython as a Interpreter and just import pip, the ImportError message was the same. And crosspython -m python error in the same way.

benfogle commented 5 years ago

Well, I was able to tinker around and reproduce something like this, but I don't have a fix yet. It seems like build-python's version of pip isn't getting installed correctly.

Depending on what you need to you, you might be able to work around it by passing --without-cross-pip to crossenv. You'll need to build packages with python setup.py ... instead of pip install ..., and you may have to build dependencies manually, but hopefully that can get you somewhere while I work on this.

benfogle commented 5 years ago

I have a lightly tested fix in the master branch. The issue stems from patches made to the system installed version of Python that aren't present in stock Python. For this reason, and to make sure that build-python and host-python are really the same, I still recommend that you build Python from source and use that rather than the system installed version.

thomascatlee commented 5 years ago

I modified init.py to bypass the error. Using context.build_env_exe rather than cross_env_exe

        subprocess.check_output([context.build_env_exe, '-m', 'pip',
            '--disable-pip-version-check',
            'install',
            '--ignore-installed',
            '--prefix='+context.cross_env_dir] + reqs)

But I don't think this is the right way.