-
-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow Pants to run with Python 3 via
./pants3
script (#6959)
## Problem We want to be able to use Pants using either Python 2 or Python 3 under-the-hood. (Note `--setup-python-interpreter-constraints` only constrains subprocesses, not the actual main Pants process.) Further, the solution must still support Python 2. An ideal solution requires: * Allow easily running using Python 3. * Allow quickly falling back to Python 2 if Python 3 version is not working. * Be transparent to the user which interpreter they are using. ## Solution Add a new script `./pants3`, that functions identically to `./pants` beyond using Python 3 under-the-hood. The user can first attempt the command with `./pants3`, and if they're having an issue they can simply revert to `./pants` (along with filing an issue). This solution has two coexisting `venv` folders, to avoid redownloading the virtual environment every time. ### Other solutions considered * Command line flag like `--py3`. * Too much typing for user every time. Is not easy to use Python 3. * Adds substantial boilerplate to `./pants` code. * Environment variable * Not transparent which interpreter is being used. * Incorporated already into the `./pants3` solution. If the user does want to use an environment variable, they can as an alternative to `./pants3`. ## Once `./pants3` fully passes CI `./pants3` will be renamed to `./pants`, which will always use Python 3, and `./pants` will be renamed to `./pants2`. We'll make this swap once `./pants3` passes all CI.
- Loading branch information
1 parent
6c2f3f1
commit 6b9ac97
Showing
11 changed files
with
48 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
# This bootstrap script invokes Pants using a Python 3 interpreter. | ||
|
||
# Use Py3 under-the-hood | ||
export PANTS_USE_PYTHON3=true | ||
|
||
# Use Py3 for subprocesses | ||
export PANTS_PYTHON_SETUP_INTERPRETER_CONSTRAINTS='["CPython>=3.6,<4"]' | ||
|
||
./pants "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters