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

brave-policeman-49804

04/24/2019, 6:27 AM
my os interpreter contains only python3.7 and I want the pex to run on python3.7
h

hundreds-father-404

04/24/2019, 7:21 AM
Hey Ray, to confirm, you are trying to run Pants as a PEX? Unfortunately we only release Pants as a Python 27 PEX and a Python 36 PEX. Our wheel based setup supports python 3.7 as of 1.16.0.dev2 though! https://www.pantsbuild.org/install.html
b

brave-policeman-49804

04/24/2019, 7:50 AM
got it! How do I mention in the
python_binary( )
to run all the dependency and code with python 3.7?
I did
compatibility="python==3.7"
, and in pants.ini
pants_runtime_python_version: 3.7
. This throws me compatibility error.
@hundreds-father-404 To confirm, I am not using Pants as PEX. I installed pants in my repo using the recommended installation provided by
<https://www.pantsbuild.org/install.html>
h

hundreds-father-404

04/24/2019, 8:27 AM
Ah okay, so are you trying to run your own code with Python 3.7? It’s a bit confusing, but there’s a difference between what version Pants uses to run the tool itself, vs what version it uses for your own code like running tests As of 1.15.0, you should re-update the
./pants
script again by running the curl command from our install guide (I’m afk so cant grab specific line). And then remove
pants_runtime_python_version
from your
pants.ini
. We had people put that value as a temporary measure until we could fully support Python 3, and now it’s deprecated and not necessary.
Off to bed but can help in the morning
b

brave-policeman-49804

04/24/2019, 8:35 AM
Oh. Okay. Thanks no problem.
so, where should I mention what version pants uses for my own code? I have a
python_binary()
and few
python_library()
linked with it.
h

hundreds-father-404

04/24/2019, 11:48 AM
In your
pants.ini
, what value do you have for
pants_version
?
b

brave-policeman-49804

04/24/2019, 12:48 PM
@hundreds-father-404 Thanks for the Help, I was able to fix by doing the following changes to my project code base. -> in pants.ini
interpreter_constraints: ["Cpython>=3.6"]
and
pants_version: 1.16.0.dev1
-> in python_binary( )
compatibility=['CPython==3.7.*'],
Now my code runs with python 3.7. I want to make sure whether this is the recommended way of doing it?
h

hundreds-father-404

04/24/2019, 12:52 PM
Great! Yes, that is exactly how you’ll want to set the constraints on your own code. What you are saying here is that in general, your own code works with Python 3.6+. With that
python_binary()
, that particular target requires Python 3.7 Independent of what you are specifying your own code to use is the question of what Pants uses to run the tool itself. If you update to the newest
./pants
script by running
curl -L -O <https://pantsbuild.github.io/setup/pants>
, then you should never have to think about this question. The script will determine the supported interpreter versions for you. With Pants 1.14.0 and earlier, we required 2.7. With 1.15.0, we allow 2.7 or 3.6. With 1.16.0.dev2 and newer, we allow 2.7, 3.6, or 3.7. The script will read your
pants_version
and choose whichever of these supported versions you have on your system. It should make no impact to you as an end user which gets chosen.
b

brave-policeman-49804

04/24/2019, 1:00 PM
thanks for the great Explanation @hundreds-father-404. One thing which took me for a toss is in
python_binary( )
, I had to mention the python micro version like
['CPython==3.7.*']
, omitting it threw me an error saying that
Unable to detect a suitable interpreter for compatibilities:
found the solution only by trail and error approach.
h

hundreds-father-404

04/24/2019, 1:02 PM
You’re welcome! There’s been a lot of changes with us migrating internally to Python 3, and unfortunately some of that leaked through to you all more than necessary, like originally asking you to add
pants_runtime_python_version
even though that’s not necessary anymore. Sorry this is all confusing! Should get simpler soon. Hm, what interpreter constraints did you try before that?
b

brave-policeman-49804

04/24/2019, 1:06 PM
I Understand. I browsed through the github issues and seems like you guys did an awesome work. The
pants_runtime_python_version
was Cpython>=3.6` and the
compatibility=['CPython==3.7'],
but it gave me this error
FAILURE: Unable to detect a suitable interpreter for compatibilities: CPython==3.7 && Cpython>=3.6 (Conflicting targets: cmd/keyphrase-server:server, pkg:common-libs)
So I assumed that every python_library that I added as a dependency in python_binary needs to be explicitly mentioned as python 3.7. It again threw me off with similar error.
h

hundreds-father-404

04/24/2019, 1:09 PM
Ah yes so the issue is
==3.7
means it must be exactly
3.7
, not
3.7.1
or
3.7.2
etc. I see why that’s confusing - it’s tripped me up a few times too. To confirm, the issue is not that you have some libraries that are
>=3.6
. Those are fine and will work with
3.7.*
. The Issue is entirely the difference from
==3.7
and
==3.7.*
Also note the reason you can say
>=3.6
instead of
>=3.6.*
is that
3.6.1
ends up resolving as
> 3.6
, for example
b

brave-policeman-49804

04/24/2019, 1:12 PM
yeah. got it! Thanks for clearing up. new to pants so getting it into production is a bit extra homework for me.
❤️ 1
h

hundreds-father-404

04/24/2019, 1:14 PM
You’re welcome! Let us know if you have other questions and also if any parts of the docs have been confusing to you or things are missing that you’d like to know. For example, ideally you shouldn’t have had to go through GitHub to see all of our Python 3 migration work. We’re very interested in ways to make the user experience better for people, including through better docs
b

brave-policeman-49804

04/24/2019, 1:19 PM
There is an ample of information present in the documentation and it cleared almost all of my doubts. It was unfortunate that I was stuck with specifying minor version of the python distribution. A little info on that would be helpful.
👌 1
and If possible I would be happy with a better refined error than
FAILURE: Unable to detect a suitable interpreter for compatibilities: CPython==3.7 && Cpython>=3.6 (Conflicting targets: cmd/keyphrase-server:server, pkg:common-libs)
h

hundreds-father-404

04/24/2019, 1:32 PM
Oh that’s a great suggestion! What would you like to see in that error message? Here are some potential things I’m thinking: - “These were the interpreter versions detected on your system: CPython 2.7.12, CPython 3.6.8, PyPy 17.1” - “To fix this, you’ll need to modify either your global
python-setup.interpreter_constraints
in your
pants.ini
or this target’s
compatibility
. Refer to https://www.pantsbuild.org/python_readme.html#configure-the-python-version
b

brave-policeman-49804

04/24/2019, 1:53 PM
The later one is perfect. points me to the correct place where there is a mismatch.
👌 1
h

hundreds-father-404

04/24/2019, 1:56 PM
Would you find both useful, or would it be getting too wordy at that point and you don’t care much which Python versions Pants detects on your system?
b

brave-policeman-49804

04/24/2019, 1:59 PM
Even though this might be useful
“These were the interpreter versions detected on your system: CPython 2.7.12, CPython 3.6.8, PyPy 17.1”
I can understand this only when I know where the problem is and why it happened. Appending both of the solution would be helpful too.
h

hundreds-father-404

04/24/2019, 2:00 PM
Okay awesome. Thank you for the suggestion and the feedback. I will incorporate it into a PR today / this week to improve the message and ping you on Slack to give your feedback once ready 🙂
💯 1
Hey @brave-policeman-49804, let me know what you think of https://github.com/pantsbuild/pants/pull/7628 and ways to improve the message more!
b

brave-policeman-49804

04/26/2019, 4:37 AM
Looks good.
❤️ 1
5 Views