# How to run ansible 2.10 in a tox venv?

**URL:** <https://forum.ansible.com/t/how-to-run-ansible-2-10-in-a-tox-venv/32348>\
**Category:** Ansible Developer\
**Tags:** windows, galaxy-ng\
**Created:** [February 28, 2020, 12:58am UTC](https://forum.ansible.com/t/how-to-run-ansible-2-10-in-a-tox-venv/32348 "2020-02-28T00:58:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richard\_Megginson](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/richard_megginson/32/4540_2.png) [@Richard\_Megginson](https://forum.ansible.com/u/Richard_Megginson)\
**Post date:** [February 28, 2020, 12:58am UTC](https://forum.ansible.com/t/how-to-run-ansible-2-10-in-a-tox-venv/32348/1 "2020-02-28T00:58:47Z")

</div>

[https://github.com/ansible-collections/overview/blob/master/README.rst#pre-release-versions-of-ansible-base](https://github.com/ansible-collections/overview/blob/master/README.rst#pre-release-versions-of-ansible-base)

I think this should work?  
"Checkout and run the source [https://github.com/ansible-collection-migration/ansible-base](https://github.com/ansible-collection-migration/ansible-base) (pip install in a Python virtual environment, or do source hacking/env-setup)"

So something like this in my tox.ini?

deps =  
git+[https://github.com/ansible-collection-migration/ansible-base.git@devel#egg=pkg](https://github.com/ansible-collection-migration/ansible-base.git@devel#egg=pkg)

However, there are no modules installed - I think it is because the MANIFEST.in excludes them? [https://github.com/ansible-collection-migration/ansible-base/blob/devel/MANIFEST.in](https://github.com/ansible-collection-migration/ansible-base/blob/devel/MANIFEST.in)

recursive-include lib/ansible/module\_utils/powershell \*.psm1  
recursive-include lib/ansible/modules/windows \*.ps1  
recursive-include lib/ansible/galaxy/data \*.yml \*.j2 README.md ansible.cfg inventory .git\_keep

because that's exactly what I see in .tox/env-py38-ansible210/lib/python3.8/site-packages/ansible/modules/

Will I have to use the `source hacking/env-setup` method to use ansible2.10 in my tox env? If so, does anyone have any examples about how to do this?

---

<div class="post-metadata">

**Author:** ![Chris\_Church1](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Church1](https://forum.ansible.com/u/Chris_Church1)\
**Post date:** [February 28, 2020, 3:11am UTC](https://forum.ansible.com/t/how-to-run-ansible-2-10-in-a-tox-venv/32348/2 "2020-02-28T03:11:13Z")

</div>

Hi Rich,

You can install from git+[https://github.com/ansible/ansible.git@devel](https://github.com/ansible/ansible.git@devel) as a dep in your tox.ini. At least it works for me to test Ansible roles against devel ([https://github.com/cchurch/ansible-role-testing/blob/master/tox.ini#L21](https://github.com/cchurch/ansible-role-testing/blob/master/tox.ini#L21)).

---

<div class="post-metadata">

**Author:** ![Richard\_Megginson](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/richard_megginson/32/4540_2.png) [@Richard\_Megginson](https://forum.ansible.com/u/Richard_Megginson)\
**Post date:** [February 28, 2020, 5:05pm UTC](https://forum.ansible.com/t/how-to-run-ansible-2-10-in-a-tox-venv/32348/3 "2020-02-28T17:05:28Z")

</div>

> Hi Rich,
> 
> You can install from git+[https://github.com/ansible/ansible.git@devel](https://github.com/ansible/ansible.git@devel) as a dep in your tox.ini. At least it works for me to test Ansible roles against devel ([https://github.com/cchurch/ansible-role-testing/blob/master/tox.ini#L21](https://github.com/cchurch/ansible-role-testing/blob/master/tox.ini#L21)).

This works. Thanks!

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [February 28, 2020, 5:08pm UTC](https://forum.ansible.com/t/how-to-run-ansible-2-10-in-a-tox-venv/32348/4 "2020-02-28T17:08:29Z")

</div>

Rich, as far as ansible-base is concerned, there is/was a bug that was errantly removing ` __ini__.py` files, which is likely the cause on python2. It’s being worked on currently.

fwiw, ansible/ansible is more similar to Ansible 2.9 at this point. ansible-base is what ansible/ansible will look like on March 23.

---

<div class="post-metadata">

**Author:** ![Richard\_Megginson](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/richard_megginson/32/4540_2.png) [@Richard\_Megginson](https://forum.ansible.com/u/Richard_Megginson)\
**Post date:** [February 28, 2020, 5:16pm UTC](https://forum.ansible.com/t/how-to-run-ansible-2-10-in-a-tox-venv/32348/5 "2020-02-28T17:16:43Z")

</div>

> Rich, as far as ansible-base is concerned, there is/was a bug that was errantly removing ` __ini__.py` files, which is likely the cause on python2. It's being worked on currently.

Is there an issue/pr that I can follow? I would like to run my tests with as close to ansible 2.10 as possible.

Also, I tested with python3, so at least for me, the problem manifested using other than python2 (or I'm running into a separate issue).

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [February 28, 2020, 5:47pm UTC](https://forum.ansible.com/t/how-to-run-ansible-2-10-in-a-tox-venv/32348/6 "2020-02-28T17:47:27Z")

</div>

I’ve tested more, and can not reproduce this. Installing ansible-base I do have modules installed.

I’ve not tested in tox, but depending if you have ansible installed in a place where tox can see, that may cause issues.

---

<div class="post-metadata">

**Author:** ![Richard\_Megginson](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/richard_megginson/32/4540_2.png) [@Richard\_Megginson](https://forum.ansible.com/u/Richard_Megginson)\
**Post date:** [February 28, 2020, 11:45pm UTC](https://forum.ansible.com/t/how-to-run-ansible-2-10-in-a-tox-venv/32348/7 "2020-02-28T23:45:11Z")

</div>

> I've tested more, and can not reproduce this. Installing ansible-base I do have modules installed.
> 
> I've not tested in tox, but depending if you have ansible installed in a place where tox can see, that may cause issues.

It's working now - not sure why it wasn't before.

Something like this:

commands\_pre =  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bash {toxinidir}/install\_ansible\_for\_testing.sh {envdir}/ansible devel  
commands =  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bash {toxinidir}/run\_ansible\_for\_testing.sh {envdir}/ansible bash {toxinidir}/run\_tests.sh

where install downloads it from github (if it doesn't already exist), and run does a `source {envdir}/ansible/hacking/env-setup` before running the rest of the command line.
