Commit a009067
authored
Add
### Problem
Our first-time [setup instructions](https://www.pantsbuild.org/install.html#recommended-installation) are harder than need be. Currently, before being able to do anything with Pants, you must:
1) curl `pants`
1) `chmod +x pants`
1) `touch pants.ini`
1) Copy and paste `[GLOBAL]` into the file.
1) Run `./pants -V` or decide you want to pin a different value.
1) Copy and paste that value into a new line `pants_version`.
Instead, we could simplify the instructions to:
1) curl `pants`
1) `chmod +x pants`
1) `touch pants.ini`
1) `./pants generate-pants-ini`
Once we add instructions on `pants_runtime_python_version`, this would get even more complex.
Simplifying the onboarding process should make it easier for us to retain first time users. There are a lot of new concepts they already have to learn, e.g. BUILD files, targets, and goals. The less overwhelming we can make this process, the better.
Refer to https://pantsbuild.slack.com/archives/CBNMV1LRH/p1552506655047900 for the original discussion around this idea and pantsbuild/setup#45 for the original implementation until we realized this should be a goal.
### Solution
Add new `./pants generate-pants-ini` to setup the initial value with defaults as follows:
* `pants_version` == version used during the run
* `pants_runtime_python_version` == version used during the run
We do not provide options to override these defaults, because this is meant for first time users who would not yet be familiar with options or discovering them via `--help`. Further, they can change the defaults by rewriting `pants.ini`.
We also do not allow this command to be ran on pre-existing `pants.ini`, because Python's configparser would strip all comments and mess up the indentation. Instead, users should simply modify their file.
### Result
If there is no content in `pants.ini`, we will print this and update `pants.ini` accordingly:
```
Adding sensible defaults to /Users/eric/DocsLocal/code/projects/pants/pants.ini:
* Pinning `pants_version` to `1.15.0rc0`.
* Pinning `pants_runtime_python_version` to `3.6`.
You may modify these values directly in the file at any time. The ./pants script will detect any changes the next time you run it.
You are now ready to use Pants!
```
If there is already content, we will fail the task and explain how to update, including the sensible defaults as a suggested edit.
### TODO: allow missing `pants.ini`
Currently, Pants fails to execute if there is no `pants.ini` in the buildroot. This does not seem intentional, as an empty `pants.ini` will fix the issue.
As a followup, we should allow a missing `pants.ini` and then use this command to generate the file. It will allow us to avoid having to instruct `touch pants.ini`.
### TODO: Updating docs
We cannot update the docs to reflect this new option until 1.15.0 is released. The setup repo defaults to the most stable version, and this goal will not be available in 1.14.0 so would confuse people../pants generate-pants-ini for first time users to generate pants.ini with sensible defaults (#7448)1 parent 03d0c5f commit a009067
File tree
4 files changed
+94
-0
lines changed- src/python/pants/core_tasks
- tests/python/pants_test/core_tasks
4 files changed
+94
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
38 | 50 | | |
39 | 51 | | |
40 | 52 | | |
| |||
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
0 commit comments