This extension provides Python code intelligence on Sourcegraph. Ensure this extension is enabled and then try it on some examples:
- Tensorflow: tensorflow_ranking/examples/tf_ranking_libsvm.py
- Flask: flask/views.py
- Zulip: corporate/lib/stripe.py
- Trivial sample: pkg0/m0.py
This extension is configured to talk to a language server over WebSockets. If you are running a
private Sourcegraph instance, you should run your own language server. The server is available as a
Docker image sourcegraph/lang-python
from Docker Hub.
-
Run the Python language server Docker container:
docker run --rm -p 4288:4288 sourcegraph/lang-python:insiders
-
Enable this extension on your Sourcegraph https://sourcegraph.example.com/extensions/sourcegraph/lang-python
-
Add these to your Sourcegraph settings:
"python.serverUrl": "ws://localhost:4288", "python.sourcegraphUrl": "http://host.docker.internal:7080",
If you're running on Linux, change
python.sourcegraphUrl
to the IP given by:ip addr show docker0 | grep -Po 'inet \K[\d.]+'
Some customers deploy Sourcegraph behind an authentication proxy or firewall. If you do this, we
recommend deploying the language server behind the proxy so that it can issue requests directly to
Sourcegraph without going through the proxy. (Otherwise, you will need to configure the language
server to authenticate through your proxy.) Make sure you set python.sourcegraphUrl
to the URL
that the language server should use to reach Sourcegraph, which is likely different from the URL
that end users use.
- Dependencies are not installed. Hovers, definitions, and references only work for sources checked into the single repository you are viewing.
- Cross-repository definitions and references are not yet supported.
- Hangs on very large repositories (e.g. django/django)