Skip to content

Commit

Permalink
No longer pin pants_runtime_python_version with `./pants generate-p…
Browse files Browse the repository at this point in the history
…ants-ini` (#7469)

In pantsbuild/setup#49, we're changing the setup repo's `./pants` script to default to Python 3.6, and then fall back to Python 2.7. Thanks to that, we no longer need to use `pants_runtime_python_version` to get the script to use Python 3.

In fact, we should not set `pants_runtime_python_version`. The Python version used is an implementation detail we don't want users to have to worry about, and we will be deprecating the option in 1.17.0.dev0. So, us auto-generating the option when it is not even necessary is asking for confusion and a worse experience for users.
  • Loading branch information
Eric-Arellano authored and stuhood committed Apr 1, 2019
1 parent 8dc1c3b commit f056225
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
8 changes: 2 additions & 6 deletions src/python/pants/core_tasks/generate_pants_ini.py
Expand Up @@ -5,7 +5,6 @@
from __future__ import absolute_import, division, print_function, unicode_literals

import os.path
import sys
from textwrap import dedent

from pants.base.build_environment import get_default_pants_config_file
Expand All @@ -19,12 +18,10 @@ class GeneratePantsIni(ConsoleTask):

def console_output(self, _targets):
pants_ini_path = get_default_pants_config_file()
python_version = ".".join(str(v) for v in sys.version_info[:2])
pants_ini_content = dedent("""\
[GLOBAL]
pants_version: {}
pants_runtime_python_version: {}
""".format(pants_version, python_version)
""".format(pants_version)
)

if os.path.isfile(pants_ini_path):
Expand All @@ -34,8 +31,7 @@ def console_output(self, _targets):
yield dedent("""\
Adding sensible defaults to {}:
* Pinning `pants_version` to `{}`.
* Pinning `pants_runtime_python_version` to `{}`.
""".format(pants_ini_path, pants_version, python_version)
""".format(pants_ini_path, pants_version)
)

with open(pants_ini_path, "w") as f:
Expand Down
Expand Up @@ -24,7 +24,6 @@ def test_pants_ini_generated_when_missing(self):
config = configparser.ConfigParser()
config.read(get_default_pants_config_file())
self.assertEqual(config["GLOBAL"]["pants_version"], VERSION)
self.assertIn(config["GLOBAL"]["pants_runtime_python_version"], {"2.7", "3.6", "3.7"})

def test_fails_when_pants_ini_already_exists(self):
temp_pants_ini_path = self.create_file("pants.ini")
Expand Down

0 comments on commit f056225

Please sign in to comment.