pypa / virtualenv

Virtual Python Environment builder
https://virtualenv.pypa.io
MIT License
4.84k stars 1.03k forks source link

python3-32 -m virtualenv .venv creates a 64-bit virtual environment #1437

Closed mayeut closed 4 years ago

mayeut commented 5 years ago

The venv module works on 3.7 but does not exist on python 2.7 and so, is not an option at the moment

Matt$ python3.7-32 -m venv ../cibuildwheel-venv-32
Matt$ source ../cibuildwheel-venv-32/bin/activate
(cibuildwheel-venv-32) Matt$ python -V
Python 3.7.5
(cibuildwheel-venv-32) Matt$ python -c 'import sys; print(sys.maxsize)'
2147483647

One difference I can see between the 2 modules is that venv creates symlinks while virtualenv creates a copy. The copy seems to be from the dual-architecture python instead of the single i386 python.

mayeut commented 5 years ago

Replacing https://github.com/pypa/virtualenv/blob/43ccf4a14bb74b0119b49d025d200d927151e229/virtualenv.py#L1623

By :

        if '-32' in os.path.basename(py_executable):
            try:
                call_subprocess(["lipo", original_python, "-thin", "i386", "-output", py_executable])
            except Exception:
                logger.fatal("Could not call lipo -- you must " "have Apple's development tools installed")
                raise
        else:
            shutil.copy(original_python, py_executable)

after macOS framework detection seems to do the trick.

mayeut commented 5 years ago

The trick does not seem to work for python2.

gaborbernat commented 4 years ago

I don't think this is an issue anymore, and if so please check if with the rewrite branch it still is.

mayeut commented 4 years ago

Still an issue on master branch, not on rewrite branch.

gaborbernat commented 4 years ago

Then will be fixed once the rewrite lands.