https://pantsbuild.org/ logo
l

lively-gpu-26436

02/15/2023, 3:07 PM
Hi all, does anyone know if there’s already a Pants plugin for Python’s futurize? I’m working on moving some Python2 into my brand new monorepo and I’m missing that piece. Otherwise I will try to create one
e

enough-analyst-54434

02/15/2023, 3:17 PM
I don't think so. @hundreds-father-404 did almost all of the Pants futurization work (I.E.: futurize the Pants codebase itself) in the Pants v1 days:
Copy code
$ git grep futurize
src/python/pants/notes/1.10.x.rst:* futurize confluence (#6115)
src/python/pants/notes/1.9.x.rst:* Run `futurize --stage1` to make safe changes for python 3 compatibility. (#6063)
I thought there were blogs or docs about this general task of migrating 2 to 3 and how to do it but failed to find them. You can start with an in-repo plugin. I'm not sure how the community would feel about migrating that into core Pants since it will require setting up Python 2.7 in CI at the very least to test and skip on Pants developer machines that do not have 2.7.
l

lively-gpu-26436

02/15/2023, 3:18 PM
thanks @enough-analyst-54434
h

hundreds-father-404

02/15/2023, 4:52 PM
If the repo is small enough, then I don't think futurize is very necessary. But for both Pantsbuild and Foursquare, the repos were way too big to be able to safely migrate in a few PRs. So I found futurize incredibly helpful to make incremental progress
l

lively-gpu-26436

02/15/2023, 4:53 PM
I’ll take a look @hundreds-father-404
❤️ 1
h

hundreds-father-404

02/15/2023, 4:53 PM
(wrong Eric hah)
l

lively-gpu-26436

02/15/2023, 4:54 PM
oops fixed! 😅
Yes my repo is medium size
h

hundreds-father-404

02/15/2023, 4:55 PM
Also check out this blog: https://blog.pantsbuild.org/python-3-migrations. Although, it's somewhat out of date in that we changed the semantics of interpreter constraints: now, when you set interpreter constraints for a file, it needs to consider the compatibility of all of its dependees. Before, you could claim a file was Python 3 even if it's dependency was Python 2 only. Most of the blog is still relevant, though
l

lively-gpu-26436

02/16/2023, 5:42 PM
Thanks @hundreds-father-404! will do
❤️ 1
5 Views