{"thread":{"id":"63191","subject":"[Question] Moving from Python2 to Python3","startedAt":"2025-03-25T15:23:46Z","lastAt":"2025-03-26T01:56:25Z","messageCount":7,"participants":["rsbecker@nexbridge.com","brian m. carlson","Nikolay Shustov","Junio C Hamano","Todd Zullinger"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"515028","messageId":"022b01db9d99$e68785c0$b3969140$@nexbridge.com","threadId":"63191","inReplyTo":null,"subject":"[Question] Moving from Python2 to Python3","fromName":"","fromEmail":"rsbecker@nexbridge.com","sentAt":"2025-03-25T15:23:40Z","receivedAt":"2025-03-25T15:23:46Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"Hi Git Team,\n\nI have Python2 and Python3 on my system. We are deprecating Python2 ASAP. Is\nthere an easy way to force git\nto use Python3 only? Both are in /usr/bin. python has a symbolic link to\npython2 right now, but we are probably\ngoing to change that. I already have modified settings in config.mak.uname\nPYTHON_PATH = /usr/bin/python3.\n\nThanks,\nRandall\n\n--\nBrief whoami: NonStop&UNIX developer since approximately\nUNIX(421664400)\nNonStop(211288444200000000)\n-- In real life, I talk too much.\n\n\n"},{"id":"515039","messageId":"Z-MgpuxFQ3xEgvsU@tapette.crustytoothpaste.net","threadId":"63191","inReplyTo":"022b01db9d99$e68785c0$b3969140$@nexbridge.com","subject":"Re: [Question] Moving from Python2 to Python3","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2025-03-25T21:31:18Z","receivedAt":"2025-03-25T21:31:27Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2025-03-25 at 15:23:40, rsbecker@nexbridge.com wrote:\n> Hi Git Team,\n> \n> I have Python2 and Python3 on my system. We are deprecating Python2 ASAP. Is\n> there an easy way to force git\n> to use Python3 only? Both are in /usr/bin. python has a symbolic link to\n> python2 right now, but we are probably\n> going to change that. I already have modified settings in config.mak.uname\n> PYTHON_PATH = /usr/bin/python3.\n\nI think only git-p4 uses Python in our codebase, so changing `PYTHON_PATH`\nshould be sufficient to fix it.  As far as I know, git-p4 currently\nsupports both, so things should just work.\n\nOf course, I might be mistaken, since I don't use git-p4.\n-- \nbrian m. carlson (they/them)\nToronto, Ontario, CA\n"},{"id":"515044","messageId":"66e39a95-09a3-44dc-ac71-a6c02b5949c9@gmail.com","threadId":"63191","inReplyTo":"Z-MgpuxFQ3xEgvsU@tapette.crustytoothpaste.net","subject":"Re: [Question] Moving from Python2 to Python3","fromName":"Nikolay Shustov","fromEmail":"nikolay.shustov@gmail.com","sentAt":"2025-03-25T22:40:56Z","receivedAt":"2025-03-25T22:41:00Z","isPatch":false,"sender":{"key":"nikolay.shustov@gmail.com","avatar":null},"body":"git-p4 is designed to work both with Python 2 and Python 3.\n\nHowever, changing just PYTHONPATH may not to be good enough.\n\nIn general, it is necessary to make having PYTHONPATH value and the \nversion of Python executable which application is run by, to be \ncoherent: Python executable has to be able to work correctly with the \nlibraries PYTHONPATH points to.\n\nHow to achieve it - depends on the OS where git-p4 is run.\n\nIf used from *nix like shells, git-p4 would be using Python executable \nfrom the shebang in the beginning of the file: #!/usr/bin/python .\nOn Windows, it is possible that the specific Python executable could be \nassociated with .py files so that shebang maybe not in play at all.\n\nSome OSes may require manual adjustments such as setting PYTHONPATH \nshell profile (environment variables, for Windows) and ensuring proper \nPython executable will be put in PATH. Some (Linux) may use \nupdate-alternatives commands to switch between Python (and other \napplications) versions easier. If it is desired to keep default Python \nof one version and run git-p4 with another, more tweaks/hackery may be \nneeded.\n\nI would recommend to refer to the documentation on the specific OS and \nalso look for hints in Python related online documentation/forums.\n\nOn 3/25/25 17:31, brian m. carlson wrote:\n> On 2025-03-25 at 15:23:40, rsbecker@nexbridge.com wrote:\n>> Hi Git Team,\n>>\n>> I have Python2 and Python3 on my system. We are deprecating Python2 ASAP. Is\n>> there an easy way to force git\n>> to use Python3 only? Both are in /usr/bin. python has a symbolic link to\n>> python2 right now, but we are probably\n>> going to change that. I already have modified settings in config.mak.uname\n>> PYTHON_PATH = /usr/bin/python3.\n> I think only git-p4 uses Python in our codebase, so changing `PYTHON_PATH`\n> should be sufficient to fix it.  As far as I know, git-p4 currently\n> supports both, so things should just work.\n>\n> Of course, I might be mistaken, since I don't use git-p4.\n"},{"id":"515049","messageId":"xmqqtt7glmut.fsf@gitster.g","threadId":"63191","inReplyTo":"66e39a95-09a3-44dc-ac71-a6c02b5949c9@gmail.com","subject":"Re: [Question] Moving from Python2 to Python3","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-03-25T23:19:38Z","receivedAt":"2025-03-25T23:19:40Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nikolay Shustov <nikolay.shustov@gmail.com> writes:\n\n> git-p4 is designed to work both with Python 2 and Python 3.\n>\n> However, changing just PYTHONPATH may not to be good enough.\n>\n> In general, it is necessary to make having PYTHONPATH value and the\n> version of Python executable which application is run by, to be\n> coherent: Python executable has to be able to work correctly with the\n> libraries PYTHONPATH points to.\n\nHmph, but isn't that the core competence of those who package Python\nto their target system?  If we run something with /usr/bin/python3,\nwithout any strange customization, that binary ought to know where\nit should pull its associated standard library files from, and we as\nthe language users do not have to worry about it, no?\n\n"},{"id":"515063","messageId":"6977f08e-3c49-4bcc-9ab7-e3cc61a78396@gmail.com","threadId":"63191","inReplyTo":"xmqqtt7glmut.fsf@gitster.g","subject":"Re: [Question] Moving from Python2 to Python3","fromName":"Nikolay Shustov","fromEmail":"nikolay.shustov@gmail.com","sentAt":"2025-03-25T23:54:55Z","receivedAt":"2025-03-25T23:54:58Z","isPatch":false,"sender":{"key":"nikolay.shustov@gmail.com","avatar":null},"body":"You are right, my answer was over-engineered.\nInstead of speculating about what else needs to be done if one decides \nto set PYTHONPATH, I should have just advised to use the OS specific \nmethod on setting up the \"default\" Python as Python3 and be with it.\nWell, unless the dual Python is needed (git-p4 running with the Python \ndifferent from system \"default\").\n\nOn 3/25/25 19:19, Junio C Hamano wrote:\n> Nikolay Shustov <nikolay.shustov@gmail.com> writes:\n>\n>> git-p4 is designed to work both with Python 2 and Python 3.\n>>\n>> However, changing just PYTHONPATH may not to be good enough.\n>>\n>> In general, it is necessary to make having PYTHONPATH value and the\n>> version of Python executable which application is run by, to be\n>> coherent: Python executable has to be able to work correctly with the\n>> libraries PYTHONPATH points to.\n> Hmph, but isn't that the core competence of those who package Python\n> to their target system?  If we run something with /usr/bin/python3,\n> without any strange customization, that binary ought to know where\n> it should pull its associated standard library files from, and we as\n> the language users do not have to worry about it, no?\n>\n"},{"id":"515065","messageId":"Z-NSGtV06NPE_C9D@teonanacatl.net","threadId":"63191","inReplyTo":"6977f08e-3c49-4bcc-9ab7-e3cc61a78396@gmail.com","subject":"Re: [Question] Moving from Python2 to Python3","fromName":"Todd Zullinger","fromEmail":"tmz@pobox.com","sentAt":"2025-03-26T01:02:18Z","receivedAt":"2025-03-26T01:02:20Z","isPatch":false,"sender":{"key":"tmz@pobox.com","avatar":"https://avatars.githubusercontent.com/u/806319?v=4"},"body":"Nikolay Shustov wrote:\n> You are right, my answer was over-engineered.\n>\n> Instead of speculating about what else needs to be done if\n> one decides to set PYTHONPATH, I should have just advised\n> to use the OS specific method on setting up the \"default\"\n> Python as Python3 and be with it.\n>\n> Well, unless the dual Python is needed (git-p4 running\n> with the Python different from system \"default\").\n\nPerhaps you were conflating PYTHON_PATH, which brian\nsuggested, with PYTHONPATH?\n\nPYTHON_PATH is used by the git build system to set the path\nto the python executable, e.g.: /usr/bin/python2,\n/usr/bin/python3, etc.\n\nPYTHONPATH is used by python itself to point to the\nlocation(s) of module files, similar to PATH, as you\nmentioned.\n\nThe Fedora distribution packaging set PYTHON_PATH to python2\nor python3 while both were available and things worked well.\nOnly python3 is supported now, and PYTHON_PATH is set\naccordingly.\n\nThat ought to work just as well for NonStop.  If it doesn't,\nthat would most likely be something to take up with the OS\nfolks handling python3. :)\n\n-- \nTodd\n"},{"id":"515066","messageId":"77b5fa59-a8a1-4859-8f3d-41f94fa8120d@gmail.com","threadId":"63191","inReplyTo":"Z-NSGtV06NPE_C9D@teonanacatl.net","subject":"Re: [Question] Moving from Python2 to Python3","fromName":"Nikolay Shustov","fromEmail":"nikolay.shustov@gmail.com","sentAt":"2025-03-26T01:56:23Z","receivedAt":"2025-03-26T01:56:25Z","isPatch":false,"sender":{"key":"nikolay.shustov@gmail.com","avatar":null},"body":"Doh! Of course I thought of PYTHONPATH not of PYTHON_PATH.\nMy apologies for the noise.\n\nOn 3/25/25 21:02, Todd Zullinger wrote:\n> Nikolay Shustov wrote:\n>> You are right, my answer was over-engineered.\n>>\n>> Instead of speculating about what else needs to be done if\n>> one decides to set PYTHONPATH, I should have just advised\n>> to use the OS specific method on setting up the \"default\"\n>> Python as Python3 and be with it.\n>>\n>> Well, unless the dual Python is needed (git-p4 running\n>> with the Python different from system \"default\").\n> Perhaps you were conflating PYTHON_PATH, which brian\n> suggested, with PYTHONPATH?\n>\n> PYTHON_PATH is used by the git build system to set the path\n> to the python executable, e.g.: /usr/bin/python2,\n> /usr/bin/python3, etc.\n>\n> PYTHONPATH is used by python itself to point to the\n> location(s) of module files, similar to PATH, as you\n> mentioned.\n>\n> The Fedora distribution packaging set PYTHON_PATH to python2\n> or python3 while both were available and things worked well.\n> Only python3 is supported now, and PYTHON_PATH is set\n> accordingly.\n>\n> That ought to work just as well for NonStop.  If it doesn't,\n> that would most likely be something to take up with the OS\n> folks handling python3. :)\n>\n"}]}