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
ansible-test - prefer venv over virtualenv on Python 3 #73000
ansible-test - prefer venv over virtualenv on Python 3 #73000
Conversation
Also pin virtualenv to 16.7.10 for older Mac OS X systems. This was the version being installed anway with the previous constraint (<20). On systems with Python 3, now prefer venv over virtualenv. Test to see if venv is functional since some systems have a non-functional venv installation (such as Debian).
f214fda
to
b20b044
Compare
@felixfontein @dmsimard Can you try out this change and see if it resolves the problems you were having with |
@samdoran what is the rationale for this change? Third-party virtualenv is often better for py3 too: it's faster starting v20. |
@webknjaz |
Oh, I thought it'd be nice to make use of the new plugin APIs virtualenv now provides one day. Like having custom seeders. |
@samdoran seems to work, at least I was able to use your branch and remove the installation of virtualenv in community.hashi_vault and CI still passes: ansible-collections/community.hashi_vault#30 |
@webknjaz For Python 3.9, we need to move to a new version of All that is why we would rather just use |
@samdoran any chance of this being backported to stable-2.9 and stable-2.10? (We'd need that to get rid of the hack :) ) |
I don't think so since this is a change in behavior. |
@felixfontein @samdoran Perhaps we could do one of the following to improve the transition while maintaining backwards compatibility?
I think the first option is the most appealing, since it wouldn't require a separate script and the additional logic would only be needed for the backports. |
The more I think about this, the more I'm wondering if there really is much of a backwards compatibility concern here. Yes, we're using a different tool to create the virtual environment, but it should provide the same behavior in the end. If a virtual environment was created before, it should still be. If it was failing to create a virtual environment before, then the test would already be failing -- making it pass shouldn't be a problem. |
As long as it suffices to set the env variable in the test scripts (and not when calling ansible-test), that's fine for me. But your new argument sounds reasonable to me as well. |
Also pin virtualenv to 16.7.10 for older Mac OS X systems. This was the version being installed anway with the previous constraint (<20). On systems with Python 3, now prefer venv over virtualenv. Test to see if venv is functional since some systems have a non-functional venv installation (such as Debian). (cherry picked from commit 850a77f)
Also pin virtualenv to 16.7.10 for older Mac OS X systems. This was the version being installed anway with the previous constraint (<20). On systems with Python 3, now prefer venv over virtualenv. Test to see if venv is functional since some systems have a non-functional venv installation (such as Debian). (cherry picked from commit 850a77f) (cherry picked from commit a48b3d2)
@felixfontein I've opened backports for stable-2.10 and stable-2.9:
After discussing with @relrod we decided to go with opt-in behavior, just to be safe. To opt-in to the new behavior in those branches, tests will need to set the export ANSIBLE_TEST_PREFER_VENV=1
source virtualenv.sh Whereas before the tests simply used: source virtualenv.sh This should allow a single test configuration to work across 2.9, 2.10 and devel once the backports are merged. |
* ansible-test - prefer venv over virtualenv on Python 3 (#73000) Also pin virtualenv to 16.7.10 for older Mac OS X systems. This was the version being installed anway with the previous constraint (<20). On systems with Python 3, now prefer venv over virtualenv. Test to see if venv is functional since some systems have a non-functional venv installation (such as Debian). (cherry picked from commit 850a77f) * Make the new ansible-test venv behavior opt-in Co-authored-by: Sam Doooran <sdoran@redhat.com>
* ansible-test - prefer venv over virtualenv on Python 3 (#73000) Also pin virtualenv to 16.7.10 for older Mac OS X systems. This was the version being installed anway with the previous constraint (<20). On systems with Python 3, now prefer venv over virtualenv. Test to see if venv is functional since some systems have a non-functional venv installation (such as Debian). (cherry picked from commit 850a77f) (cherry picked from commit a48b3d2) * Make the new ansible-test venv behavior opt-in Co-authored-by: Sam Doooran <sdoran@redhat.com>
@mattclay great, thanks! I've tried it out in ansible-collections/community.hashi_vault#45, works perfectly! |
@felixfontein Looks good. I recommend including a comment when setting the env var that it is only needed while supporting 2.9 and 2.10, so that it will be more obvious in the future when it can be removed. |
SUMMARY
Also pin
virtualenv
to 16.7.10 for older Mac OS X systems. This was the version being installed anway with the previous constraint (<20).On systems with Python 3, now prefer
venv
overvirtualenv
. Test to see ifvenv
is functional since some systems have a non-functionalvenv
installation (such as Debian).Supersedes #72778
Fixes: #72738
ISSUE TYPE
COMPONENT NAME
changelogs/fragments/ansible-test-venv-virtualenv-fallback.yml
test/lib/ansible_test/_data/injector/virtualenv-isolated.sh
test/lib/ansible_test/_data/injector/virtualenv.sh
test/lib/ansible_test/_data/setup/remote.sh