Python 3 support for fabric
Asked Answered
C

7

56

Does fabric (http://docs.fabfile.org/en/1.7/) support Python 3 yet. As per Python 3 Wall of Superpowers it does not yet. If not what is the best alternative if using Django 1.5 with Python 3.

Congruent answered 11/9, 2013 at 8:31 Comment(2)
GitHub user @pashinin has made a Python 3 compatible fork of Fabric. Some tests were disabled, but it seems to be working fine for a lot of use cases.Inhaler
There is also an answer below mentioning package fabric3 (pypi.python.org/pypi/Fabric3) that should be upvoted moreCavitation
F
36

Current Answer which has already been done by @miso.belica

pip install -U "fabric>2.0.0"

OLD Answer (as of 2013)

From the docs:

Please note that all documentation is currently written with Python 2.5 users in mind, but with an eye for eventual Python 3.x compatibility

Or to be more specific:

eventual Python 3.x compatibility

It looks like Python3 support for fabric is a little sticky and depends upon another open source library, paramiko being compatible with python3. As of now, the master version supports python 3.

It might be worth messing around with and then building your fabric instance on top of that instead of getting it from pip.

Forequarter answered 11/9, 2013 at 19:22 Comment(7)
Has the situation changed at all since the answer was posted?Sanjiv
Gregory Goltsov, click the 'open issue in github' link that Gregory posted. The temporary answer is no, not now, but that's not what you want to know... you want to track that issue (and see what you can do to help, maybe test).Seduce
Paramiko now supports python 3. Presumably, fabric won't be far behind.Brett
That's good news, but it looks like fabric won't use paramiko 1.13 because it drops support for python 2.5 link, I don't know if python3 is fully supported in paramiko 1.12 though.Misplace
@Pedru, dropping support for python 2.5 makes senseLeonialeonid
"PYTHON 3 WALL OF SUPERPOWERS" python3wos.appspot.com says no at the moment.Appointive
@Pere, I agree, but it looks like Fabric doesn't want to drop 2.5 but I guess they will have to choose between 2.5 and 3Misplace
L
99

Current advice

It seems there is already official support for Python 3.4+ in Fabric v2+ and I guess it should be preferred although there may be some incompatible changes. So in an ideal world, nobody should have this problem anymore :)

pip3 install -U "fabric>2.0"

Maintained old API in Python 3

Because some people were happy with the old API of the Fabric, there is a maintained fork supporting Python 3 called fab-classic. See also discussion in the Github issue Recreating the Fabric 1 API in Fabric 2?


The previous advice

There is Python3 port of Fabric named Fabric3 which supports Python 2.7 and 3.4+ (dropped support for Python <2.7). I use it some time as a replacement and it works for me without any issues.

pip3 install fabric3
Legitimist answered 24/1, 2016 at 10:56 Comment(3)
Should add sudo if needed: sudo pip3 install fabric3Mercedes
It is also worth noting that if pip3 install is complaining about not being able to run C code then you should also do sudo apt-get install gcc-multilib g++-multilibOyler
@quasoft, well okay. But only because it helped me. ;)Mechanize
F
36

Current Answer which has already been done by @miso.belica

pip install -U "fabric>2.0.0"

OLD Answer (as of 2013)

From the docs:

Please note that all documentation is currently written with Python 2.5 users in mind, but with an eye for eventual Python 3.x compatibility

Or to be more specific:

eventual Python 3.x compatibility

It looks like Python3 support for fabric is a little sticky and depends upon another open source library, paramiko being compatible with python3. As of now, the master version supports python 3.

It might be worth messing around with and then building your fabric instance on top of that instead of getting it from pip.

Forequarter answered 11/9, 2013 at 19:22 Comment(7)
Has the situation changed at all since the answer was posted?Sanjiv
Gregory Goltsov, click the 'open issue in github' link that Gregory posted. The temporary answer is no, not now, but that's not what you want to know... you want to track that issue (and see what you can do to help, maybe test).Seduce
Paramiko now supports python 3. Presumably, fabric won't be far behind.Brett
That's good news, but it looks like fabric won't use paramiko 1.13 because it drops support for python 2.5 link, I don't know if python3 is fully supported in paramiko 1.12 though.Misplace
@Pedru, dropping support for python 2.5 makes senseLeonialeonid
"PYTHON 3 WALL OF SUPERPOWERS" python3wos.appspot.com says no at the moment.Appointive
@Pere, I agree, but it looks like Fabric doesn't want to drop 2.5 but I guess they will have to choose between 2.5 and 3Misplace
S
17

You could also create a separate python2.7 virtualenv just for fabric:

sudo virtualenv --no-site-packages -p /usr/bin/python fabric-env
source /var/www/APPNAME/fabric-env/bin/activate
sudo /var/www/APPNAME/fabric-env/bin/pip install fabric
deactivate

Then:

/var/www/APPNAME/fabric-env/bin/fab -f /var/www/APPNAME/fabfile.py FAB_COMMAND
Squiggle answered 19/6, 2014 at 2:39 Comment(0)
S
7

It seems that Fabric is going through a rewrite and that Fabric 2.0 will be python 3.x compatible. At least this is what I read between the line of the roadmap below. However, I cannot find the Fabric 2.0 repository or branch, so, hard to fully confirm.

http://www.fabfile.org/roadmap.html

Speedway answered 29/9, 2014 at 16:2 Comment(0)
R
3

For those looking for a supported version of Fabric 1.x, there's a fork which is maintained: https://github.com/ploxiln/fab-classic

I recommend using it in case you don't want to rewrite all the existing code. And it works with Python 3.7.

We've switched from fabric3==1.14.post1 to fab-classic==1.15.2 without any problems.

Ravi answered 16/3, 2020 at 18:7 Comment(0)
R
2

It is actually possible to get Fabric to work with Python 3. You can see how I did it in this gist.

In the comments above, @rnevius suggests that invoke is meant as a successor of Fabric 1.x, however that is not completely correct. From the invoke docs:

Thus, Invoke was created to focus exclusively on local and abstract concerns, leaving Fabric 2.x concerned only with servers and network commands.

It thus seems that Fabric 2.x will be built on top of invoke. Hopefully, Fabric 2.x will be available soon, so Python2 can die as quickly as possible.

Rust answered 2/5, 2015 at 18:32 Comment(0)
M
2

By this day "fabric 2" is awailable to work with python 3+.

"fabric 3" is unofficial fork.

To install "fabric 2" from https://pypi.org/project/Fabric/ :

pip install Fabric
Merman answered 2/8, 2018 at 13:27 Comment(1)
A lot of the documentation makes it seem that both Fabric 2 is not quite fully-baked yet and that the porting effort from Fabric 1 to Fabric 2 is not trivial. Anybody have any advice regarding that?Whipcord

© 2022 - 2024 — McMap. All rights reserved.