https://pantsbuild.org/ logo
#general
Title
# general
b

brainy-solstice-27042

05/23/2022, 7:01 PM
May be a dumb question, but in upgrading to pants 2.11 is there any way to get
python_library
(which is deprecated) and
python_sources
to co-exist? I currently have a setup that would allow me to use different version of pants in parallel while I upgrade small pieces at at time (rather than have 200+ BUILD files changed at one time and risk breaking everything in the process). Even if I told pants to ignore unknown types, that would be OK
h

hundreds-father-404

05/23/2022, 7:05 PM
Hi! I can't think of a good way to do that Instead, what you can do is stay on 2.8 for now and silence the deprecation by setting `ignore_warnings`: https://www.pantsbuild.org/docs/upgrade-tips#ignore-deprecation-messages-with-ignore_warnings. Keep using
python_library
at first Over several PRs, upgrade to
python_sources
while still on Python 2.8 Once you are fully done upgrading, you can upgrade to 2.9, which I think was the first Pants version to drop
python_library
Our deprecation policy is meant to allow you to upgrade one minor version at a time without being forced to make a change. You have at least a one-release buffer in which you can make the change over time. https://www.pantsbuild.org/docs/deprecation-policy
b

brainy-solstice-27042

05/23/2022, 7:06 PM
I'll try 2.8 and see what happens, thanks!
h

hundreds-father-404

05/23/2022, 7:06 PM
What Pants version are you on now?
b

brainy-solstice-27042

05/23/2022, 7:08 PM
1.30, but in trying to get an old plugin migrated to use engine v2, it was easiest to go to 2.X as it wasn't 2 year out of date
đź‘Ť 1
h

hundreds-father-404

05/23/2022, 7:11 PM
Cool. I'm pretty conflicted on the best way in 2022 to migrate from 1.30 to 2.x 🤷originally, we recommend going to 2.0, and then upgrade to 2.1, then 2.2 and so on And that you don't actually have to land the upgrade to 2.0 etc. But at least locally, get
./pants list ::
and stuff working, then go to the next minor version -- The plugin complicates things tho
b

brainy-solstice-27042

05/23/2022, 7:16 PM
Yeah, what I've found is that following the docs for 1.30, I can't seem to get the magic sauce right so that the plugin is recognized by engine v2, so I just bit the bullet and tried 2.11 since that is at least supported. However there are so many changes with respect to the build files that I'm having to update just about everything at once. Plus, to make matters even more entertaining, we're running python 3.6.14, but I've found that pants 2.X doesn't want to work with anything less than 3.7. If I could de-risk and get things working in 1.30 for now, then I can upgrade to python 3.7, then upgrade pants again I could verify that our code works under 3.7 first in a controlled manner
h

hundreds-father-404

05/23/2022, 7:17 PM
Plus, to make matters even more entertaining, we're running python 3.6.14, but I've found that pants 2.X doesn't want to work with anything less than 3.7.
Hm, Pants should have zero opinion on what Python version your own code uses. It only needs a 3.7 interpreter to run the tool itself There are folks running Python 2 with Pants 2.11
b

brainy-solstice-27042

05/23/2022, 7:20 PM
Oh, I must've done something wrong initially then, that's awesome! I guess that means I can upgrade to 2.11 without some of the risk. Just tested and was able to execute things with 3.6.14 using pants 2.11
w

witty-crayon-22786

05/23/2022, 7:20 PM
when making long leaps like this, it is fairly common to define `v2` macros which map from one version’s syntax to the other… we don’t really have a good library of these macros though, because it’s dependent on both versions
đź‘Ť 2
👆 1
h

hundreds-father-404

05/23/2022, 7:24 PM
May be a dumb question
Also definitely no dumb questions in this Slack 🙂 upgrading from 1.30 can be a challenge, but we think the v2 experience is dramatically better. We're very happy to help w/ questions like this!
b

brainy-solstice-27042

05/23/2022, 9:19 PM
The macros part has been really helpful so far, I was able to extend things a bit so it seems happy for the most part. Only bit that I'm still hung up on is adding the
sources
field to
pex_binary
. I'm not sure what the proper way to add that functionality back similar to what
sources
was at least in pants 1.30.
w

witty-crayon-22786

05/23/2022, 9:20 PM
create a
python_sources
target, and have the
pex_binary
target explicitly depend on it, probably…?
…oh. but it would be a name clash, i suppose.
you might be able to do something like:
Copy code
original_pex_binary = pex_binary
def pex_binary(..):
    python_sources(..)
    original_pex_binary(..)
…but haven’t tried it before.
4 Views