Skip to content

Commit 425e1ea

Browse files
authored
Merge 35d4fe8 into cb7258a
2 parents cb7258a + 35d4fe8 commit 425e1ea

27 files changed

Lines changed: 1358 additions & 429 deletions

.github/workflows/testAndPublish.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ jobs:
4545
uses: actions/checkout@v4
4646
with:
4747
submodules: true
48-
- name: Install dependencies
48+
- name: Install Python
4949
uses: actions/setup-python@v5
5050
with:
5151
python-version: '3.11'
5252
architecture: x86
53+
- name: Install the latest version of uv
54+
uses: astral-sh/setup-uv@v5
5355
- name: Set version variables
5456
run: ci/scripts/setBuildVersionVars.ps1
5557
- name: Set scons args
@@ -76,6 +78,8 @@ jobs:
7678
path: ${{ github.workspace }}
7779
key: ${{ github.ref }}-${{ github.run_id }}
7880
fail-on-cache-miss: true
81+
- name: Install the latest version of uv
82+
uses: astral-sh/setup-uv@v5
7983
- name: Check comments for translators
8084
run: ci/scripts/tests/translationCheck.ps1
8185
- name: Upload artifact
@@ -98,6 +102,8 @@ jobs:
98102
path: ${{ github.workspace }}
99103
key: ${{ github.ref }}-${{ github.run_id }}
100104
fail-on-cache-miss: true
105+
- name: Install the latest version of uv
106+
uses: astral-sh/setup-uv@v5
101107
- name: License check
102108
run: ci/scripts/tests/licenseCheck.ps1
103109

@@ -112,6 +118,8 @@ jobs:
112118
path: ${{ github.workspace }}
113119
key: ${{ github.ref }}-${{ github.run_id }}
114120
fail-on-cache-miss: true
121+
- name: Install the latest version of uv
122+
uses: astral-sh/setup-uv@v5
115123
- name: Run unit tests
116124
run: ci/scripts/tests/unitTests.ps1
117125
- name: Replace relative paths in unit test results
@@ -145,6 +153,8 @@ jobs:
145153
path: ${{ github.workspace }}
146154
key: ${{ github.ref }}-${{ github.run_id }}
147155
fail-on-cache-miss: true
156+
- name: Install the latest version of uv
157+
uses: astral-sh/setup-uv@v5
148158
- name: Set version variables
149159
run: ci/scripts/setBuildVersionVars.ps1
150160
- name: Set scons args
@@ -154,7 +164,7 @@ jobs:
154164
run: scons %sconsOutTargets% %sconsArgs% ${{ !runner.debug && '--all-cores' || '-j1'}}
155165
- name: Export package list
156166
shell: cmd
157-
run: .\venvUtils\exportPackageList.bat output\installed_python_packages.txt
167+
run: uv export > output\installed_python_packages.txt
158168
- name: Upload launcher
159169
id: uploadLauncher
160170
uses: actions/upload-artifact@v4
@@ -199,6 +209,8 @@ jobs:
199209
path: ${{ github.workspace }}
200210
key: ${{ github.ref }}-${{ github.run_id }}
201211
fail-on-cache-miss: true
212+
- name: Install the latest version of uv
213+
uses: astral-sh/setup-uv@v5
202214
- name: Get NVDA launcher
203215
id: getLauncher
204216
uses: actions/download-artifact@v4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ source/locale/*/cldr.dic
4949
nvdaHelper/docs/
5050
*.pfx
5151
appveyor-tools/
52+
*.egg-info

.pre-commit-config.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ repos:
9898
- id: add-trailing-comma
9999

100100
- repo: https://github.com/astral-sh/ruff-pre-commit
101-
# Matches Ruff version in requirements.
101+
# Matches Ruff version in pyproject.
102102
rev: v0.8.1
103103
hooks:
104104
- id: ruff
@@ -120,10 +120,17 @@ repos:
120120
- id: pyright
121121
alias: pyrightCI
122122
name: Check types with pyright
123-
# use nodejs version of pyright and install requirements.txt for CI
124-
additional_dependencies: ["-rrequirements.txt", "pyright[nodejs]"]
123+
# use nodejs version of pyright and install pyproject.toml for CI
124+
additional_dependencies: [".", "pyright[nodejs]"]
125125
stages: [manual] # Only run from CI manually
126126

127+
- repo: https://github.com/astral-sh/uv-pre-commit
128+
rev: 0.6.14
129+
hooks:
130+
- id: uv-lock
131+
# Override python interpretter from .python-version as that is too strict for pre-commit.ci
132+
args: ["-p3.11"]
133+
127134
- repo: local
128135
hooks:
129136
- id: scons-source
@@ -147,7 +154,7 @@ repos:
147154
types_or: [python, c, c++, batch]
148155
- id: licenseCheck
149156
name: Check license compatibility of pip dependencies
150-
files: ^(requirements\.txt|runlicensecheck\.bat|pyproject\.toml)$
157+
files: ^(runlicensecheck\.bat|pyproject\.toml)$
151158
entry: ./runlicensecheck.bat
152159
language: script
153160
pass_filenames: false

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cpython-3.11-windows-x86-none

appveyor.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ install:
4747
"INSTALL_START, $(Get-Date -Format 'o')"| Out-File ../timing.csv -Append
4848
- ps: appveyor\scripts\setBuildVersionVars.ps1
4949
- ps: appveyor\scripts\decryptFilesForSigning.ps1
50-
- py -m pip install --upgrade --no-warn-script-location pip
50+
- ps: irm https://astral.sh/uv/install.ps1 | iex
51+
- set Path=%userprofile%\.local\bin;%Path%
5152
- git submodule update --init
5253
- ps: |
5354
"INSTALL_END, $(Get-Date -Format 'o')"| Out-File ../timing.csv -Append

appveyor/scripts/pushPackagingInfo.ps1

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@ if (!$env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:versionType) {
33
# Not a pr build
44
if ($env:APPVEYOR_REPO_BRANCH -eq "beta" -and $env:feature_crowdinSync) {
55
# Upload files to Crowdin for translation
6-
py -m pip install --no-warn-script-location requests
7-
py appveyor\crowdinSync.py uploadSourceFile 2 output\nvda.pot 2>&1
6+
uv run --with requests --directory appveyor crowdinSync.py uploadSourceFile 2 output\nvda.pot 2>&1
87
}
98
# Upload symbols to Mozilla if feature enabled.
109
if ($env:feature_buildSymbols -and $env:feature_uploadSymbolsToMozilla) {
11-
py -m pip install --upgrade --no-warn-script-location pip
12-
py -m pip install --no-warn-script-location requests
1310
Try {
14-
py appveyor\mozillaSyms.py
11+
uv run --with requests --directory appveyor mozillaSyms.py
1512
}
1613
Catch {
1714
Add-AppveyorMessage "Unable to upload symbols to Mozilla"
@@ -20,7 +17,7 @@ if (!$env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:versionType) {
2017
}
2118

2219
# Save an exact list of the actual Python packages and their versions that got installed, to aide in reproducing a build
23-
.\venvUtils\exportPackageList.bat installed_python_packages.txt
20+
uv export > installed_python_packages.txt
2421
Push-AppveyorArtifact installed_python_packages.txt
2522
$appVeyorUrl = "https://ci.appveyor.com"
2623
$exe = Get-ChildItem -Name output\nvda_*.exe

ensureuv.bat

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@echo off
2+
rem Check if 'uv' is available
3+
where uv >nul 2>&1
4+
if %ERRORLEVEL%==0 (
5+
goto :runUv
6+
)
7+
8+
rem Check if WinGet is available
9+
where winget >nul 2>&1
10+
set hasWinGet=%ERRORLEVEL%
11+
12+
:prompt
13+
echo uv is not installed.
14+
echo.
15+
echo Choose how to install uv:
16+
if "%hasWinGet%"=="0" (
17+
echo [1] Install using WinGet, recommended
18+
) else (
19+
echo WinGet is NOT available.
20+
)
21+
echo [2] Install using the official uv install script
22+
echo [0] Exit
23+
24+
set /p "choice=Enter your choice: "
25+
26+
if "%choice%"=="0" (
27+
exit /B 0
28+
) else if "%choice%"=="1" (
29+
if "%hasWinGet%"=="0" (
30+
echo Installing uv using WinGet...
31+
winget install --accept-source-agreements --disable-interactivity -e astral-sh.uv
32+
goto :runUv
33+
) else (
34+
echo Invalid option: WinGet is not available.
35+
goto :prompt
36+
)
37+
) else if "%choice%"=="2" (
38+
echo Installing uv using the official script...
39+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
40+
goto :runUv
41+
) else (
42+
echo Invalid choice: "%choice%". Exiting.
43+
exit /B 1
44+
)
45+
46+
:runUv
47+
if "%choice%"=="2" (
48+
set "UV_BIN=%UserProfile%\.local\bin"
49+
set "Path=%UV_BIN%;%Path%"
50+
)
51+
uv %*

projectDocs/dev/buildSystemNotes.md

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
11
# Build System Notes
2-
A Python virtual environment is used transparently by the NVDA build system,
3-
and all Python dependencies are installed into this environment using `pip`.
2+
The NVDA build system uses [uv](https://docs.astral.sh/uv/) to manage a Python virtual environment.
3+
All Python dependencies are installed into this environment.
44

5-
NVDA's build system commands will handle all aspects of the virtual environment.
6-
Developers should not create or activate the virtual environment manually, unless
7-
working on the build system itself.
5+
All aspects of the virtual environment are either handled by NVDA's build system commands, or by uv.
6+
Developers should not create or activate the virtual environment manually.
87

98
For the documentation on how to _use_ the build system (E.G. building,
109
running NVDA or tests) see the main repository readme file.
1110

1211
## How the build system works
1312

14-
The virtual environment system used is `venv`.
15-
Dependencies are installed with `pip` via the `requirements.txt` file.
16-
Version numbers for dependencies should be used to lock in a version.
17-
18-
The virtual environment is recreated if it is outdated, either due to:
19-
- Python version.
20-
- `pip` requirements.
21-
22-
The user is consulted before modifying / removing a virtual environment that can't be identified
23-
as having been created by NVDA's build system.
13+
Dependencies are managed in the `pyproject.toml` file.
14+
Ideally, version numbers for dependencies should be used to lock in a version.
2415

2516
### Entry points to the build system
2617

@@ -32,42 +23,26 @@ These are the only files expected to be executed directly by a user/developer:
3223
- `runlint.bat`
3324
- `runlicensecheck.bat`
3425

35-
**Note:** The `runnvda.bat` script intentionally uses `pyw.exe` to run NVDA as
26+
**Note:** The `runnvda.bat` script uses `uv run`, which executes `nvda.pyw` as a GUI application by default.
3627
this is the more common and expected way to run NVDA.
37-
Run NVDA with `py.exe` in order to have standard output/error output to the console.
38-
This is particularly useful if there is an error in NVDA before logging is initialised.
28+
You can override this behavior by passing `-s` as a parameter to `uv run`.
3929
To do this, modify the `runnvda.bat` file.
30+
This allows you to have standard output/error output to the console,
31+
which is particularly useful if there is an error in NVDA before logging is initialised.
4032

41-
**Note:** Executing `source/nvda.pyw` outside of a virtual environment will produce an error message
33+
**Note:** Executing `source/nvda.pyw` Outside uv will produce an error message
4234
and early termination.
4335

44-
### Main implementation files:
45-
The following files contain the main implementation of the virtual environment setup.
46-
47-
#### `venvUtils/ensureAndActivate.bat`
48-
- Activates the virtual environment.
49-
- If necessary, creates and configures it first.
50-
- The virtual environment is left active.
51-
#### `venvUtils/venvCmd.bat`
52-
- Uses `ensureAndActivate.bat` to run a command within the context
53-
of the virtual environment.
54-
- The virtual environment is deactivated after the command
55-
completes.
56-
- All entry point scripts depend on this.
57-
#### `venvUtils/ensureVenv.py`
58-
- Does the actual work to create and configure the virtual
59-
environment.
60-
61-
## Motivation for using virtual environments
36+
## Motivation for using uv
6237

6338
Ensures the build environment is clean, and there are no conflicts with other installed packages.
6439

6540
NVDA and its build system have many Python dependencies.
66-
Using `pip` and a virtual environment means:
41+
Using `uv` means:
6742
- Updating is easier than git submodules.
6843
- Developers need to sync/update their submodules less often.
6944
- More consistency for dependencies.
70-
- IDE's can be configured more easily.
45+
- IDE's can be configured more easily, for NVDA development as well as for development of add-ons.
7146
- No conflict between NVDA dependencies and Python packages already installed globally on the
7247
developer's system.
7348
- Don't interfere with the developer's system. Installing packages globally may break things

projectDocs/dev/createDevEnvironment.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,14 @@ The NVDA source depends on several other packages to run correctly.
4747
The following dependencies need to be installed on your system:
4848

4949
#### Python
50-
5150
[Python](https://www.python.org/), version 3.11, 32 bit.
5251

5352
To replicate the production build environment, use the 3.11.x minor version of Python that [AppVeyor uses for the Visual Studio 2022 environment](https://www.appveyor.com/docs/windows-images-software/#python).
5453

54+
#### uv
55+
56+
[uv](https://docs.astral.sh/uv/) is used as package and project manager.
57+
5558
#### Microsoft Visual Studio
5659

5760
* Microsoft Visual Studio 2022
@@ -121,7 +124,7 @@ The following build time dependencies are included in the miscDeps git submodule
121124
### Python dependencies
122125

123126
NVDA and its build system also depend on an extensive list of Python packages.
124-
They are all listed with their specific versions in the `requirements.txt` file in the root of this repository.
127+
They are all listed with their specific versions in the `pyproject.toml` file in the root of this repository.
125128
However, the build system takes care of fetching these itself when needed.
126129
These packages will be installed into an isolated Python virtual environment within this repository, and will not affect your system-wide set of packages.
127130

projectDocs/testing/automated.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ This will automatically apply lint fixes where possible, and will cancel the com
1010

1111
From a shell, [set up pre-commit scripts](https://pre-commit.com/#pre-commit-install) for your NVDA python environment:
1212

13-
1. `venvUtils\ensureAndActivate.bat`
14-
1. `pre-commit install`
13+
`uv run pre-commit install`
1514

1615
Alternatively, set up pre-commit scripts globally:
1716

0 commit comments

Comments
 (0)