diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9d2b5d355391..4c46077f9db7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -81,7 +81,7 @@ git remote add upstream git@github.com:pytorch/pytorch.git make setup-env # Or run `make setup-env-cuda` for pre-built CUDA binaries # Or run `make setup-env-rocm` for pre-built ROCm binaries -source venv/bin/activate # or `& .\venv\Scripts\Activate.ps1` on Windows +source venv/bin/activate # or `. .\venv\Scripts\activate` on Windows ``` ### Tips and Debugging @@ -182,28 +182,36 @@ You can use this script to check out a new nightly branch with the following: ```bash ./tools/nightly.py checkout -b my-nightly-branch -source venv/bin/activate # or `& .\venv\Scripts\Activate.ps1` on Windows +source venv/bin/activate # or `. .\venv\Scripts\activate` on Windows ``` To install the nightly binaries built with CUDA, you can pass in the flag `--cuda`: ```bash ./tools/nightly.py checkout -b my-nightly-branch --cuda -source venv/bin/activate # or `& .\venv\Scripts\Activate.ps1` on Windows +source venv/bin/activate # or `. .\venv\Scripts\activate` on Windows ``` To install the nightly binaries built with ROCm, you can pass in the flag `--rocm`: ```bash ./tools/nightly.py checkout -b my-nightly-branch --rocm -source venv/bin/activate # or `& .\venv\Scripts\Activate.ps1` on Windows +source venv/bin/activate # or `. .\venv\Scripts\activate` on Windows ``` You can also use this tool to pull the nightly commits into the current branch: ```bash -./tools/nightly.py pull -p my-env -source my-env/bin/activate # or `& .\venv\Scripts\Activate.ps1` on Windows +./tools/nightly.py pull +source venv/bin/activate # or `. .\venv\Scripts\activate` on Windows +``` + +To create the virtual environment with a specific Python interpreter, you can +pass in the `--python` argument: + +```bash +./tools/nightly.py --python /path/to/python3.12 +source venv/bin/activate # or `. .\venv\Scripts\activate` on Windows ``` Pulling will recreate a fresh virtual environment and reinstall the development diff --git a/tools/nightly.py b/tools/nightly.py index e8d4eef8004f..c6e88974aee1 100755 --- a/tools/nightly.py +++ b/tools/nightly.py @@ -7,12 +7,12 @@ binaries into the repo. You can use this script to check out a new nightly branch with the following:: $ ./tools/nightly.py checkout -b my-nightly-branch - $ source venv/bin/activate # or `& .\venv\Scripts\Activate.ps1` on Windows + $ source venv/bin/activate # or `. .\venv\Scripts\activate` on Windows Or if you would like to check out the nightly commit in detached HEAD mode:: $ ./tools/nightly.py checkout - $ source venv/bin/activate # or `& .\venv\Scripts\Activate.ps1` on Windows + $ source venv/bin/activate # or `. .\venv\Scripts\activate` on Windows Or if you would like to reuse an existing virtual environment, you can pass in the prefix argument (--prefix):: @@ -23,18 +23,24 @@ the prefix argument (--prefix):: To install the nightly binaries built with CUDA, you can pass in the flag --cuda:: $ ./tools/nightly.py checkout -b my-nightly-branch --cuda - $ source venv/bin/activate # or `& .\venv\Scripts\Activate.ps1` on Windows + $ source venv/bin/activate # or `. .\venv\Scripts\activate` on Windows To install the nightly binaries built with ROCm, you can pass in the flag --rocm:: $ ./tools/nightly.py checkout -b my-nightly-branch --rocm - $ source venv/bin/activate # or `& .\venv\Scripts\Activate.ps1` on Windows + $ source venv/bin/activate # or `. .\venv\Scripts\activate` on Windows You can also use this tool to pull the nightly commits into the current branch as well. This can be done with:: $ ./tools/nightly.py pull - $ source venv/bin/activate # or `& .\venv\Scripts\Activate.ps1` on Windows + $ source venv/bin/activate # or `. .\venv\Scripts\activate` on Windows + +To create the virtual environment with a specific Python interpreter, you can +pass in the --python argument:: + + $ ./tools/nightly.py --python /path/to/python3.12 + $ source venv/bin/activate # or `. .\venv\Scripts\activate` on Windows Pulling will recreate a fresh virtual environment and reinstall the development dependencies as well as the nightly binaries into the repo directory. @@ -308,7 +314,7 @@ class Venv: """Get the activation script for the virtual environment.""" if WINDOWS: # Assume PowerShell - return self.prefix / "Scripts" / "Activate.ps1" + return self.prefix / "Scripts" / "activate" # Assume POSIX-compliant shell: Bash, Zsh, etc. return self.prefix / "bin" / "activate" @@ -317,7 +323,7 @@ class Venv: """Get the command to activate the virtual environment.""" if WINDOWS: # Assume PowerShell - return f'& "{self.activate_script}"' + return f'. "{self.activate_script}"' # Assume Bash, Zsh, etc. # POSIX standard should use dot `. venv/bin/activate` rather than `source` return f"source {shlex.quote(str(self.activate_script))}"