Repository: Lightning-AI/pytorch-lightning
Pull request: Add dev env setup guide
## What does this PR do?

<!--
Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context.
List any dependencies that are required for this change.

If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

The following links the related issue to the PR (https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword)
-->

Fixes #20954 

<!-- Does your PR introduce any breaking changes? If yes, please list them. -->

<details>
  <summary><b>Before submitting</b></summary>

- Was this **discussed/agreed** via a GitHub issue? (not for typos and docs)
- [x] Did you read the [contributor guideline](https://github.com/Lightning-AI/pytorch-lightning/blob/master/.github/CONTRIBUTING.md), **Pull Request** section?
- [x] Did you make sure your **PR does only one thing**, instead of bundling different changes together?
- Did you make sure to **update the documentation** with your changes? (if necessary)
- Did you write any **new necessary tests**? (not for typos and docs)
- [ ] Did you verify new and **existing tests pass** locally with your changes?
- Did you list all the **breaking changes** introduced by this pull request?
- Did you **update the CHANGELOG**? (not for typos, docs, test updates, or minor internal changes/refactors)

<!-- In the CHANGELOG, separate each item in the unreleased section by a blank line to reduce collisions -->

</details>

## PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the [review guidelines](https://github.com/Lightning-AI/lightning/wiki/Review-guidelines). In short, see the following bullet-list:

<details>
  <summary>Reviewer checklist</summary>

- [ ] Is this pull request ready for review? (if not, please submit in draft mode)
- [ ] Check that all items from **Before submitting** are resolved
- [ ] Make sure the title is self-explanatory and the description concisely explains the PR
- [ ] Add labels and milestones (and optionally projects) to the PR so it can be classified

</details>

<!--

Did you have fun?

Make sure you had fun coding 🙃

-->


<!-- readthedocs-preview pytorch-lightning start -->
----
📚 Documentation preview 📚: https://pytorch-lightning--20961.org.readthedocs.build/en/20961/

<!-- readthedocs-preview pytorch-lightning end -->

Problem statement:
Recommend dev setup / support uv
### 📚 Documentation

I read the CONTRIBUTING docs but I did not a see a recommended path to (a) get lightning with the right deps etc venv for devel or the recommended way to run the linter.

there is a pyproject.toml but it does not work with uv.

My ideal solution would be that e.g.
`uv run pytest ` just works (by modifying pyproject.toml) and `uv run ruff` lints as recommended?

Alternatively, it would be helpful (to me at least) if there was clear instructions on how to go from `git clone` to tests passing / linting.

cc @lantiga @borda

Hints from issue discussion:
hello, you maybe looking for https://github.com/Lightning-AI/pytorch-lightning/blob/e91541894b83373e7e3c4963d16137c2af7bd0d1/Makefile#L31 so to run `make test`

and you are right we shall improve instruction in the Contributing guide
@jjh42 You can use the Lightning Studio for [development](https://www.youtube.com/watch?v=YcW-2Zt_bFg&ab_channel=LightningAI), or alternatively follow the instructions [here](https://github.com/Lightning-AI/pytorch-lightning/blob/master/tests/README.md) to get started with setting up a local dev environment. The latter also shows you how you'd go from cloning the repo to running tests/linting locally.

As for uv, the project uses pip right now, so you can use uv's pip interface for any pip-related commands.

Commit message: fix venv path

Patch to review:
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index cfb03d220c99c..b09b3f646061a 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -109,6 +109,42 @@ ______________________________________________________________________
 
 ## Guidelines
 
+### Development environment
+
+To set up a local development environment, begin by cloning the repository:
+
+```bash
+git clone https://github.com/Lightning-AI/pytorch-lightning.git
+cd pytorch-lightning
+```
+
+Once in root level of the repository, install the dependencies using a package manager of your choice:
+
+```bash
+# pip
+python -m venv .venv
+source .venv/bin/activate
+pip install ".[dev, examples]"
+
+# uv
+uv venv
+source .venv/bin/activate
+uv pip install ".[dev, examples]"
+```
+
+Once the dependencies have been installed, install pre-commit and set up the git hook scripts:
+
+```bash
+# pip
+pip install pre-commit
+
+# uv
+uv pip install pre-commit
+
+# Install git hook scripts
+pre-commit install
+```
+
 ### Developments scripts
 
 To build the documentation locally, simply execute the following commands from project root (only for Unix):
diff --git a/tests/README.md b/tests/README.md
index 26e49c4f5751f..98c67f06ae2de 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -9,8 +9,8 @@ To setup a local development environment, install both local and test dependenci
 
 ```bash
 # clone the repo
-git clone https://github.com/Lightning-AI/lightning.git
-cd lightning
+git clone https://github.com/Lightning-AI/pytorch-lightning.git
+cd pytorch-lightning
 
 # install required dependencies
 export PACKAGE_NAME=pytorch


Code review comments:
diff_hunk: @@ -9,8 +9,8 @@ To setup a local development environment, install both local and test dependenci
 
 ```bash
 # clone the repo
-git clone https://github.com/Lightning-AI/lightning.git
-cd lightning
+git clone https://github.com/Lightning-AI/pytorch-lightning.git
+cd pytorch-lightning
path: tests/README.md
text: @user1:
Not sure how, but the `lightning` repo link also works. 
Might be good to update it to `pytorch-lightning` to other places as well for consistency and to avoid confusion.


@author:
@user1 Interesting, I must have used this link in the past as well initially.

@user2 I'm guessing we should stick with the `lightning.git` version.