Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added instructions on vscode intellisense #104

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"python.formatting.provider": "black",
"python.analysis.packageIndexDepths": [
{ "name": "pants", "depth": 5, "includeAllSymbols": true }
]
Expand Down
66 changes: 65 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ A small selection of custom PantsBuild plugins.

Install Pants via [PantsBuild's instructions](https://www.pantsbuild.org/docs/installation), or use `brew` via `brew install pantsbuild/tap/pants`.


## Plugins

- [ansible](https://github.com/sureshjoshi/pants-plugins/blob/main/pants-plugins/experimental/ansible/README.md)
Expand All @@ -19,3 +18,68 @@ Install Pants via [PantsBuild's instructions](https://www.pantsbuild.org/docs/in
- Examples removed from repo as of May 20, 2023 (last commit with examples: [ea2b275](https://github.com/sureshjoshi/pants-plugins/commit/ea2b2755e6d1ffc8b3222f0b03a222a036f1e65a))
- [Issue #90](https://github.com/sureshjoshi/pants-plugins/issues/90) for rationale
- [scie](https://github.com/sureshjoshi/pants-plugins/blob/main/pants-plugins/experimental/scie/README.md)

## VS Code Configuration

In order to get intellisense working correctly in VS Code, here are the relevant items to look at:

### pants.toml

Ensure the following:

- `pants.backend.plugin_development` setup inside `backend_packages`
- There is a separate resolve for your plugin directory, matching the Pants required interpreter (3.9 right now)

```toml
backend_packages = [
"pants.backend.plugin_development",
...

[python]
enable_resolves = true
interpreter_constraints = ["==3.9.*"]
tailor_pex_binary_targets = false

[python.resolves]
pants-plugins = "build-support/lockfiles/pants-plugins.lock"
python-default = "build-support/lockfiles/python-default.lock"

[python.resolves_to_interpreter_constraints]
pants-plugins = [">=3.9,<3.10"]
```

### requirements

In the plugin root folder, there is a BUILD file containing the following (where the resolve is the same name that you setup in pants.toml):

```python
pants_requirements(name="pants", resolve="pants-plugins")
```

### .vscode/settings.json

In the past, this setting appears to help the VS Code intellisense auto-complete.

```json
{
"python.analysis.packageIndexDepths": [
{ "name": "pants", "depth": 5, "includeAllSymbols": true }
]
}
```

### venv

Generate the lockfile (very important if `pants_version` changes, so you're using the updated pants wheel). Then, export the resolve and setup VS Code to use that venv.

```bash
pants generate-lockfiles --resolve=pants-plugins # This is important if you've upgraded your pants version
pants export --resolve=pants-plugins

# Use this venv in VS Code
Wrote mutable virtualenv for pants-plugins (using Python 3.9.19) to dist/export/python/virtualenvs/pants-plugins/3.9.19
```

You can also symlink the exported directory to `.venv` or similar, as VS Code tends to automatically pick those up.

Important: Do not activate the `venv` and run commands, or you'll get a complaint about using the `pants launcher binary`.
Loading
Loading