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
Broken virtualenv creation #8589
Comments
I've faced the same problem when I tried to perform an integration test of my project with another my project which is supposed to be installed in a separate virtualenv at |
I have worked around this by using a prebuilt binary for Debian from the Docker library, and changing the config to - stage: test
before_install:
- |
docker create --name pybin python:3.6
sudo docker cp "pybin:/usr/local/bin" /usr/local
sudo docker cp "pybin:/usr/local/lib/python3.6" /usr/local/lib/python3.6
sudo docker cp "pybin:/usr/local/lib/libpython3.6m.so" /usr/local/lib
sudo docker cp "pybin:/usr/local/lib/libpython3.6m.so.1.0" /usr/local/lib
sudo docker cp "pybin:/usr/local/lib/libpython3.so" /usr/local/lib
sudo docker cp "pybin:/usr/local/include/python3.6m" /usr/local/include
docker rm pybin
sudo ldconfig
rm -rf ~/virtualenv/python*
/usr/local/bin/python -c 'import sys; print(sys.prefix)'
/usr/local/bin/python -m venv ~/virtualenv/python3.6
source ~/virtualenv/python3.6/bin/activate
python -c 'import sys; print(sys.prefix)' With the above extra steps, all Python virtualenv functionalities work as expected. |
Maybe, Travis CI could also utilize the same method by mirroring the docker images in their infrastructure. |
My work-a-round is to use /opt/python/3.6/bin/python and create a new virtualenv with this interpreter, see: Example build: https://travis-ci.org/jedie/bootstrap_env/builds/352272422 But you can only test against Python v3.6 :( |
was this ever fixed or any other supported way of handling projects that create/require a separate virtualenv? I think I'm having the same issue on my travis setup: https://github.com/btotharye/mycroft-homeassistant/blob/master/.travis.yml |
Be aware — my workaround using docker binaries began to break due to OpenSSL incompatibilities... |
We're also running into this with pipx. I made the logs verbose in my travis build, so I can see that
|
Thanks for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue in 7 days. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please respond before the issue is closed, or open a new one after. We'll gladly take a look again! You can read more here: https://blog.travis-ci.com/2018-03-09-closing-old-issues |
Auto close... Do you find a solution ? |
That workaround works on dist: trusty but by default, Travis CI dist: xenial looks like this: |
…tage Because we only need those dependencies for our `tox` tests so we may speed up a little the overall CI tests timings. We also remove all the other apt commands performed in `before_install` because we don't need it. Note: in order to successfully pass the test `test_pythonpackage_basic.test_virtualenv`, we need to deactivate the system virtualenv See also: travis-ci/travis-ci#8589
…tage Because we only need those dependencies for our `tox` tests so we may speed up a little the overall CI tests timings. We also remove all the other apt commands performed in `before_install` because we don't need it. Note: in order to successfully pass the test `test_pythonpackage_basic.test_virtualenv`, we need to deactivate the system virtualenv See also: travis-ci/travis-ci#8589
…tage Because we only need those dependencies for our `tox` tests so we may speed up a little the overall CI tests timings. We also remove all the other apt commands performed in `before_install` because we don't need it. Note: in order to successfully pass the test `test_pythonpackage_basic.test_virtualenv`, we need to deactivate the system virtualenv See also: travis-ci/travis-ci#8589
(copied from twitter) to make venv-in-virtualenv work reliably you need to find the original python. here's code from pre-commit which does this: https://github.com/pre-commit/pre-commit/blob/183c8cbb3a74ca241d524f82f6cc482f8b361b8f/pre_commit/languages/python_venv.py#L22-L48 also note on macos you need to do some wacky things to avoid pollution from parent pythons (due to being a "framework" build) -- here's the code for that too: https://github.com/pre-commit/pre-commit/blob/183c8cbb3a74ca241d524f82f6cc482f8b361b8f/pre_commit/main.py#L32-L36 (note the macos bit is only necessary if you're using python to invoke virtualenv / pip / etc.) |
It was quite fiddly to get something which works both locally and, looking ahead, on the Travis infrastructure. See travis-ci/travis-ci#8589
It was quite fiddly to get something which works both locally and, looking ahead, on the Travis infrastructure. See travis-ci/travis-ci#8589
I've got a problem with creating a virtualenv in travis. Or, more specifically, how the created virtualenv behaves after it's created.
runs without error and doesn't print anything. A virtualenv is actually created, however it's almost empty. When you run venv creation from normal python installation or correctly working virtualenvs,
pip
andsetuptools
are usually installed.However the actual problem is with installing packages to the created virtualenv:
outputs the expected result - it downloads the package and installs it, however, it's not actually installed in the virtualenv, it's installed in the python the virtualenv was created from. You can see that when you run
python -m pip freeze
.That is not standard behaviour.
I made an example travis script for this at https://github.com/mikicz/travis-venv-test/blob/af47e2f5143fab04054a9f75fbacaec9dbc4c404/.travis.yml (build https://travis-ci.org/mikicz/travis-venv-test/builds/287923885)
As a small sidenote, I checked the travis python installation and found that there is a python installation in
/opt/python
which requiressudo: required
to be set for it to be accessed. When I tried creating a virtualenv from that python, it worked as expected (https://github.com/mikicz/travis-venv-test/blob/d5c589893ec7047b8eef5dbedd4f85da39b342c9/.travis.yml, build https://travis-ci.org/mikicz/travis-venv-test/builds/287923321). However I don't like this solution because it says in the documentation to not rely on this python, I don't actually need the sudo permissions and I don't want the extra boot time.Am I doing something wrong? Is there a way to create a virtualenv without using the
/opt/
python and the sudo permissions? I am targeting Python 3.6 and higher.The text was updated successfully, but these errors were encountered: