You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reacted by Nikolay Amiantov, vyp, Gabriel Ebner, Vladimír Čunát, Alexander Ried, Eric Sagnes, Michele Guerini Rocco, Jon Banafato, Kirill Boltaev, Langston Barrett and 15 more
Reacted by Aneesh Agrawal, MrSorcus, ajs124 and Семён Марьясин
I have used my nixpkgs config to set Python 3 as the default, and have only encountered a few packages requiring Python 2 so far. I can help put in PRs to make sure they use python2 (or python2.tiny / python2.small / python2-stripped ) instead of python3.
Maybe the python infra should automatically use the smaller version when python/python2 is a build input?
pkgs.python = pkgs.python3 instead of pkgs.python = pkgs.python2, and likely pkgs.python3 = pkgs.python35 although we could try 3.6 as well; there aren't going to be many changes from 3.5 to 3.6. This change will impact a lot of packages/services.
patchShebangs doesn't patch a #!/usr/bin/python to a Python 3.x path. We could add a symbolic link from python to python3 in the Python 3.x derivations. Any idea what other distributions do?
I think it would be best to leave patchShebangs as is, and add a symlink for python in the python3 derivation (and remove it from the python2 derivation to allow simultaneous installations). This adds less complexity, matches how most distributions handle /usr/bin/python, and is something I've been using for a few months without any issues.
Reacted by Nikolay Amiantov, Frederik Rietdijk, J Phani Mahesh and Jonas Schürmann
If I understand correctly people are against it because PEP 394 recommends to symlink python to python2 with the rationale being to preserve compatibility with existing python2 script.
But don't we patch shebang to point to a very specific python interpreter already? Also this document is from 2011: python2 EOL now is only 1.5 years away. What do people expect it will happen after this date?
PEP 394 says that for the time being the python executable should point to the python2 executable. However, because on Arch python points to python3, it is also advised that scripts that use python in their shebang are made Python 2 and 3 compatible.
In the case of Nix we're not so much talking about the executables (the python executable in Nixpkgs points to both python2 and python3, with python2 taking precedence), but more about the attributepython, and having that point to the python3 attribute instead of the current python2 attribute.
I would argue we should do the same as with the shebang but with out attributes: use the python attribute for packages that are both 2 and 3 compatible. Then it becomes easy to change at some point. Many did not like this, because it could break their expressions outside of Nixpkgs. Fair point.
Last month there was again a discussion on python-dev about PEP 394 and whether python should always point to python2, leading to revision of PEP 394 (python/peps#630). Judging from the discussion I think it is clear now that python should not and will not point to python3.
Based on that, and the earlier resistance, I am fine with not pointing the python attribute to python3, but instead update all occurrences where python3 can be used. But good luck finding volunteers for doing that.
for the time being, all distributions should ensure that python, if installed, refers to the same target as python2, unless the user deliberately overrides this or a virtual environment is active.
That PEP is about the executable and it has been like this for years in Nixpkgs (Python refers to 2 and 3 but if both present 3 takes precedence). It's also a relatively unimportant issue for us.
Anyway, there are not many Python 2 applications left and we as a project do not have project milestones, but our members may have.
Hello, I'm a bot and I thank you in the name of the community for opening this issue.
To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.
The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it.
If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them.
Default image uses Python 3 as does nearly every application. There are a couple build-time dependencies for the default image that use Python 2, that are a bit harder to get around. Aside from that there's nothing to be done, so I am closing this.
I think it would be a good idea to write down all remaining python2 packages. For instance, I would start removing old 2.x.nix expressions for packages that have python3 support.
Activity
abbradar commentedon Sep 1, 2016
I wanted to create this issue long ago and help with what I can, but hasn't found time ~_^
FRidh commentedon Sep 1, 2016
We should have for each interpreter version a
pythonwhich is the full versionpython-strippedwhich is commonly used in other packagesand package sets for each.
aneeshusa commentedon Sep 1, 2016
I have used my nixpkgs config to set Python 3 as the default, and have only encountered a few packages requiring Python 2 so far. I can help put in PRs to make sure they use
python2(orpython2.tiny/python2.small/python2-stripped) instead ofpython3.Maybe the python infra should automatically use the smaller version when
python/python2is a build input?edolstra commentedon Sep 1, 2016
Regarding
systemd-boot, I started rewriting it in Perl a while back, but it's not entirely finished yet. I can pick that up.Other than that, what exactly does it mean to have Python 3 as the "default install" given that NixOS doesn't install Python by default (AFAIK)?
FRidh commentedon Sep 1, 2016
pkgs.python = pkgs.python3instead ofpkgs.python = pkgs.python2, and likelypkgs.python3 = pkgs.python35although we could try 3.6 as well; there aren't going to be many changes from 3.5 to 3.6. This change will impact a lot of packages/services.domenkozar commentedon Sep 2, 2016
@edolstra it means that for graphical stacks we have only python3 in the closure. So Python 3 should be the default interpreter used in applications.
domenkozar commentedon Sep 2, 2016
nixos/modules/system/boot/loader/systemd-bootcan be easily ported to python3, unless you want to maintain it in perl @edolstraFRidh commentedon Sep 2, 2016
is there a test for systemd-boot?
vcunat commentedon Sep 2, 2016
Many packages use python in their build system. I don't know how well
python3is supported for that, generally.dezgeg commentedon Sep 2, 2016
There is
tests.boot.simpleUefiGummiboot. It's not a release blocker currently though.FRidh commentedon Sep 30, 2016
patchShebangsdoesn't patch a#!/usr/bin/pythonto a Python 3.x path. We could add a symbolic link frompythontopython3in the Python 3.x derivations. Any idea what other distributions do?aneeshusa commentedon Sep 30, 2016
I think it would be best to leave patchShebangs as is, and add a symlink for
pythonin thepython3derivation (and remove it from thepython2derivation to allow simultaneous installations). This adds less complexity, matches how most distributions handle/usr/bin/python, and is something I've been using for a few months without any issues.systemd-boot: port builder to python3
14 remaining items
FRidh commentedon May 12, 2018
PEP 394 says that for the time being the
pythonexecutable should point to thepython2executable. However, because on Archpythonpoints topython3, it is also advised that scripts that usepythonin their shebang are made Python 2 and 3 compatible.In the case of Nix we're not so much talking about the executables (the
pythonexecutable in Nixpkgs points to bothpython2andpython3, withpython2taking precedence), but more about the attributepython, and having that point to thepython3attribute instead of the currentpython2attribute.I would argue we should do the same as with the shebang but with out attributes: use the
pythonattribute for packages that are both 2 and 3 compatible. Then it becomes easy to change at some point. Many did not like this, because it could break their expressions outside of Nixpkgs. Fair point.Last month there was again a discussion on
python-devabout PEP 394 and whetherpythonshould always point topython2, leading to revision of PEP 394 (python/peps#630). Judging from the discussion I think it is clear now thatpythonshould not and will not point topython3.Based on that, and the earlier resistance, I am fine with not pointing the
pythonattribute topython3, but instead update all occurrences wherepython3can be used. But good luck finding volunteers for doing that.dotlambda commentedon Aug 3, 2018
Besides using
python3where possible, do we also want to explicitly usepython2instead ofpythonas I did in #44400?dotlambda commentedon Aug 3, 2018
I think that, in the long run, we might want to remove the
pythonandpythonPackagesattributes fromall-packages.nix.grahamc commentedon Sep 20, 2018
https://www.python.org/dev/peps/pep-0394/
ryneeverett commentedon Mar 6, 2020
pep394 has been changed since this discussion dropped off. I'm surprised this isn't a 20.03 milestone.
FRidh commentedon Mar 7, 2020
That PEP is about the executable and it has been like this for years in Nixpkgs (Python refers to 2 and 3 but if both present 3 takes precedence). It's also a relatively unimportant issue for us.
Anyway, there are not many Python 2 applications left and we as a project do not have project milestones, but our members may have.
stale commentedon Sep 3, 2020
Hello, I'm a bot and I thank you in the name of the community for opening this issue.
To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.
The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it.
If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them.
Lastly, you can always ask for help at our Discourse Forum or at #nixos' IRC channel.
doronbehar commentedon Sep 11, 2020
That's still important.
FRidh commentedon Sep 11, 2020
Default image uses Python 3 as does nearly every application. There are a couple build-time dependencies for the default image that use Python 2, that are a bit harder to get around. Aside from that there's nothing to be done, so I am closing this.
doronbehar commentedon Sep 11, 2020
@FRidh what about renaming the attributes? Making
python = python3?rnhmjoj commentedon Sep 11, 2020
I think it would be a good idea to write down all remaining python2 packages. For instance, I would start removing old
2.x.nixexpressions for packages that have python3 support.