Skip to content

Commit dbf3dae

Browse files
authored
[py] Update Python development instructions in README.md (#15424)
1 parent 9e5c9b8 commit dbf3dae

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

README.md

+34-3
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,47 @@ To automatically update and pin new dependencies, run:
210210

211211
### Python
212212

213-
You can run Python code locally by updating generated files in the python directory using:
213+
#### Linting
214+
215+
We follow the [PEP8 Style Guide for Python Code](https://peps.python.org/pep-0008) (except we use a 120 character line length).
216+
This is checked and enforced with several linting tools, including
217+
[black](https://pypi.org/project/black),
218+
[docformatter](https://pypi.org/project/docformatter),
219+
[flake8](https://flake8.pycqa.org),
220+
and [isort](https://pycqa.github.io/isort).
221+
222+
To run all of the linting tools:
214223
```shell
215-
./go py:update
224+
./go py:lint
216225
```
217226

218-
To install Selenium locally based on a specific commit, you can use:
227+
You need `tox` installed to run the linting tools (`pip install tox`).
228+
229+
#### Local Installation
230+
231+
To run Python code locally without building/installing the package, you must first install the dependencies:
232+
```shell
233+
pip install -r py/requirements.txt
234+
```
235+
236+
Then, build the generated files and copy them into your local source tree:
237+
```shell
238+
./go py:local_dev
239+
```
240+
241+
After that, you can import the selenium package directly from source from the `py` directory.
242+
243+
Instead of running from source, you can build and install the selenium package (wheel) locally:
219244
```shell
220245
./go py:install
221246
```
222247

248+
This will attempt to install into the global Python `site-packages` directory,
249+
which might not be writable. To avoid this, you should create and activate a
250+
[virtual environment](https://packaging.python.org/en/latest/tutorials/installing-packages/#creating-virtual-environments)
251+
before installing.
252+
253+
223254
### Ruby
224255

225256
Instead of using `irb`, you can create an interactive REPL with all gems loaded using: `bazel run //rb:console`

0 commit comments

Comments
 (0)