# FYI Python 3 stuffs

**URL:** <https://forum.ansible.com/t/fyi-python-3-stuffs/15797>\
**Category:** Ansible Developer\
**Created:** [July 29, 2014, 12:46am UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797 "2014-07-29T00:46:13Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Latham](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Andrew\_Latham](https://forum.ansible.com/u/Andrew_Latham)\
**Post date:** [July 29, 2014, 12:46am UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/1 "2014-07-29T00:46:13Z")

</div>

To the few, the proud and the brave.

I have worked on and have a working(99%) Ansible + Python3 setup. I  
am currently in the process of getting the PR into sane order. Testing  
and validation have sucked up most of my time. Not a lot of pure  
Python3 systems out there so value is still low. No impact on the  
Python2x support at all save for some massive unicode hacks that will  
have to be pared down into something sane.

that is all for today.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 29, 2014, 12:56am UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/2 "2014-07-29T00:56:17Z")

</div>

Hi.

Also, dammit 🙂

There are various refactoring things we need to do over time which may prove such a patch extremely … non-timely, and I feel we need to get to many other PRs first, and this would also likely invalidate (and require update) of most PRs in queue.

I don’t want to say I’m disinterested in python 3 support for core – Luke Sneeringer has done some great work using “six” for the ansible-tower-CLI, though I think the answer here is a _not now_.

[https://github.com/ansible/tower-cli](https://github.com/ansible/tower-cli)

I don’t want to see a fork exist, that would be a disaster - and there will be a time for this, but that time will likely coincide with a point where python 3 is the default for more distros and it’s not easy to install python 2, and we need to update lots of modules.

So yeah, I don’t want to be that guy saying “hold off! We’re not ready to merge these things!” but yeah, I suspect we totally are not, and this would just complicate our workflow.

That time will come, and I am happy to see things like six available that should allow easy portability so we can run on both platforms (and in which case, yes, a tox.ini will be involved).

–Michael

---

<div class="post-metadata">

**Author:** ![Andrew\_Latham](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Andrew\_Latham](https://forum.ansible.com/u/Andrew_Latham)\
**Post date:** [July 29, 2014, 1:48am UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/3 "2014-07-29T01:48:58Z")

</div>

A simple PR [https://github.com/ansible/ansible/pull/8322](https://github.com/ansible/ansible/pull/8322)

Text reads as"

"""  
In an effort to understand Ansible code better I started to work on  
adding Python3 support. Many projects like Apache's libcloud have  
found the conversion to be much easier than they had feared. This pull  
request only changes the print to be a function. Many stderr calls  
were also addressed in a proper way and all tests pass fine. This is  
me jumping into the development cycle to swallow yet another OSS  
project process so point out my failures as they happen. I may have  
softened at least one "wtf" found in print output, sorry about that.  
"""  
Ran 165 tests in 6.667s

OK  
"""

"""

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 29, 2014, 1:42pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/4 "2014-07-29T13:42:04Z")

</div>

There will be a time for this later, but I’m afraid this is still jumping the gun and would complicate merging a lot of outstanding pull requests I think need to be addressed first.

Replied more formally to the ticket than I normally would have, since people tend to link to such things.

---

<div class="post-metadata">

**Author:** ![Andrew\_Latham](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Andrew\_Latham](https://forum.ansible.com/u/Andrew_Latham)\
**Post date:** [July 29, 2014, 2:02pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/5 "2014-07-29T14:02:56Z")

</div>

No worries. I guess I am missing what actually needs done on the PRs.  
I can add more pull requests for other non-Python3 fixes but I do not  
understand how I can reduce the number of pull requests currently.  
Please advise in case I am missing some obvious action.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 29, 2014, 2:58pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/6 "2014-07-29T14:58:48Z")

</div>

Lots of testing, review, mentoring, deciding if they are appropriate, fixing bugs that no one has fixed, implementing features that no one has fixed, answering questions, triaging issues, and lots of code review.

The time for python 3 can come later, but right now, I feel loyalty to dealing with all the other stuff first until the time comes.

There’s a bit of the “tragedy of github” in that it encourages code contribution and lots of extra work before asking if a project is wanting to go a certain way, so we do feel like we have to help out most of these PRs and try to negotiate reasonable compromises and implementations, and that takes a lot of time.

For this reason it’s almost always easier when someone has a feature proposal, if we discuss “what should we do for X” somewhat in advance, as otherwise we spend a lot of time trying to massage those things in.

Not so much a discussion of Python 3, but why the queue takes as much time as it does.

---

<div class="post-metadata">

**Author:** ![Michal\_Marzuchowski](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@Michal\_Marzuchowski](https://forum.ansible.com/u/Michal_Marzuchowski)\
**Post date:** [March 12, 2015, 4:46pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/7 "2015-03-12T16:46:34Z")

</div>

It’s been over 8 months since discussion about python 3, I think it’s time to start it once again. It shouldn’t be hard to keep code both 2-and-3 compatible ([http://python-future.org/compatible\_idioms.html](http://python-future.org/compatible_idioms.html)). Python 3 is already 7 years old ([https://www.python.org/download/releases/3.0/](https://www.python.org/download/releases/3.0/)) it is widely, and can be easily installed on any distro not having it by default.

I’m not talking about abandoning python 2 support, but adding ability to run ansible with python 3. Well let’s say supporting python 2.6+ (sorry rhel 5.11 no new features for you) or 2.7+ (it may or may not work on rhel6).

If ansible resists to supporting python 3 and focues on 2.4 compability, it means that developers has to focus on archaic platforms that are no longer developed by anyone and receives only bugfixes.

BR,  
Michal

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [March 12, 2015, 4:48pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/8 "2015-03-12T16:48:43Z")

</div>

Take a look at the v2 code (planned to be released as 2.0), Python3 compatibility is being worked on there.

---

<div class="post-metadata">

**Author:** ![Michal\_Marzuchowski](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@Michal\_Marzuchowski](https://forum.ansible.com/u/Michal_Marzuchowski)\
**Post date:** [March 12, 2015, 4:59pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/9 "2015-03-12T16:59:09Z")

</div>

Oh, great! But, shouldn’t v2 be kinda branch or something? Anyway, it’s great that work is already ongoing. If I wanted to contribute, where could I find resources, issues or whatever related to v2 project?

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [March 12, 2015, 5:05pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/10 "2015-03-12T17:05:05Z")

</div>

> Oh, great! But, shouldn't v2 be kinda branch or something?

​I have been wondering the same thing.  
​

> Anyway, it's great that work is already ongoing. If I wanted to  
> contribute, where could I find resources, issues or whatever related to v2  
> project?  
> ​​

​v​2 is a subdir in the repo; besides that afaik, there is no documentation

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [March 12, 2015, 5:41pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/11 "2015-03-12T17:41:49Z")

</div>

Yeah, not too much in the way of documentation yet -- you should be  
able to checkout the git repo and the submodules as usual for hacking  
on ansible from a git checkout. Then, instead of doing source  
./hacking/env-setup do source ./v2/hacking/env-setup . That will set  
the PATH and PYTHONPATH to use the code in the v2 subdirectory.

-Toshio

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [March 12, 2015, 5:53pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/12 "2015-03-12T17:53:28Z")

</div>

Hi,

Python 3 compatibility is something we want, but let me be clear, our  
main user base is 2.4-2.7 by far, very few servers have python 3 by  
default and we do not want to force an upgrade, but work with existing  
infrastructure. As things change on the server side we will try to  
keep the code 2-3 compatible as this is the trend we are seeing. At  
some point, when python2 is less widely installed by default we'll  
switch this portion of the code to be python3-only. We'll just have  
to watch the ecosystems evolve to determine when to do this.

If you have ideas about how we can satisfy all consumers of modules we  
will definitely listen.

So core ansible will probably make big strides to v3 compatibility but  
task plugins/library modules will probably keep 2.4 compatibility for  
a while. Our user base determines this, you would be surprised how  
fast 2.4(modules) or even 2.6(core) incompatible code gets flagged by  
them.

Please note that programmers will still be limited by v2  
compatibility, so you will be able to execute under python 3 but not  
add python 3 features to the code.

v2 will become devel after 1.9 is released so there should be no  
changes in contribution methods.

---

<div class="post-metadata">

**Author:** ![Michal\_Marzuchowski](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@Michal\_Marzuchowski](https://forum.ansible.com/u/Michal_Marzuchowski)\
**Post date:** [March 12, 2015, 6:07pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/13 "2015-03-12T18:07:22Z")

</div>

Hi,

What do you think about “sorry, now new features for you, only bugfixes” attitude to 2.4-2.6 (or 2.4-2.5) versions, so potential developer won’t be limited by versions that it may be hard to get on modern distro?

Michal

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [March 12, 2015, 6:41pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/14 "2015-03-12T18:41:56Z")

</div>

That will happen when the majority of users have transitioned their  
systems away from 2.4, as it stands now, not an option.

Ansible is a tool to serve the users, so they take priority over us  
developers wanting to use features or syntax not readily available to  
them.

---

<div class="post-metadata">

**Author:** ![Michal\_Marzuchowski](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@Michal\_Marzuchowski](https://forum.ansible.com/u/Michal_Marzuchowski)\
**Post date:** [March 12, 2015, 6:58pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/15 "2015-03-12T18:58:38Z")

</div>

I’m more of an user than developer, but I guess that you by user you mean business, user that pays for software, rather than hacker like me, and I’m okay with that. Anyway I’m happy that it’ll be possible to run ansible with py3.

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [March 12, 2015, 7:00pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/16 "2015-03-12T19:00:04Z")

</div>

​I think this is more about supporting users that choose to use 'stable'  
'enterprise' distributions, and are stuck with e.g. RHEL 5.x

​

---

<div class="post-metadata">

**Author:** ![Jesse\_Keating](https://avatars.discourse-cdn.com/v4/letter/j/3bc359/32.png) [@Jesse\_Keating](https://forum.ansible.com/u/Jesse_Keating)\
**Post date:** [March 12, 2015, 7:04pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/17 "2015-03-12T19:04:20Z")

</div>

Many users have no real choice in the matter. Bottom line, it should not be necessary to change your (supported) platform in order to use a config management / orchestration engine.

For hackers/developers, it's trivially simple to gain access to a python2.x environment to use. Its far more onerous to try and introduce a new python3 platform into an existing fleet of infrastructure, just to be able to keep up with new Ansible releases.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [March 12, 2015, 7:07pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/18 "2015-03-12T19:07:19Z")

</div>

@Michal, no, by user i mean people using ansible, it does not matter  
if they pay or not (ansible itself is free both as beer and as  
speech).

Most people using a tool care more about how easy it is to install and  
use than about the internal style or code features available, that  
appeals to programmers that want to modify the tool (which is a small  
subset of those using the tool).

Most of our users don't have an easy way to change other things they  
run, we want to make ansible the easy choice and make it run w/o  
causing them pain, much less forcing them to change their  
infrastructure (hopefully we do make this easy once you start using  
it!).

---

<div class="post-metadata">

**Author:** ![Michal\_Marzuchowski](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@Michal\_Marzuchowski](https://forum.ansible.com/u/Michal_Marzuchowski)\
**Post date:** [March 12, 2015, 7:09pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/19 "2015-03-12T19:09:42Z")

</div>

I’ve been stuck with rhel 5, I know their pain. I would say that “no new features” would be fair on platforms that are not going to get new features anyway, but discussion in this matter is going to be counterproductive. I’m not sure if and how I could contribute to v2 subdir-branch.

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [March 12, 2015, 8:39pm UTC](https://forum.ansible.com/t/fyi-python-3-stuffs/15797/20 "2015-03-12T20:39:20Z")

</div>

Follow instructions from here on how to get a git checkout:  
[http://docs.ansible.com/intro\_installation.html#running-from-source](http://docs.ansible.com/intro_installation.html#running-from-source)

Where the instructions say to run source ./hacking/env-setup instead  
do source ./v2/hacking/env-setup

That will setup up PATH and PYTHONPATH to use the code in ./v2/ansible .

-Toshio

[Next page](https://forum.ansible.com/t/fyi-python-3-stuffs/15797.md?page=2)
