Skip to content

Commit 0ccd53b

Browse files
v1: Migrated poetry to uv (#5253)
* poetry replaced with uv * Try building with CI * add uv to path * Fix sdk path * Support for desktop light * unpack pyodide * Update contributing guide * Enable Ruff
1 parent 5abc6e0 commit 0ccd53b

File tree

18 files changed

+2339
-3784
lines changed

18 files changed

+2339
-3784
lines changed

.appveyor.yml

Lines changed: 38 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ environment:
6868
- job_name: Build Flet for web
6969
job_group: build_flet
7070
job_depends_on: build_flet_package
71+
PYODIDE_URL: https://github.com/pyodide/pyodide/releases/download/0.27.5/pyodide-core-0.27.5.tar.bz2
7172
APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004
7273

7374
- job_name: Test Python 3.10
@@ -162,9 +163,9 @@ for:
162163
install:
163164
- python --version
164165
- pip3 install --upgrade setuptools wheel twine tomlkit
165-
- ps: (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
166-
- ps: Add-SessionPath "$HOME\AppData\Roaming\Python\Scripts"
167-
- poetry --version
166+
- ps: irm https://astral.sh/uv/install.ps1 | iex
167+
- ps: Add-SessionPath "$HOME\.local\bin"
168+
- uv --version
168169
- dart pub global activate fvm
169170
- set PATH=%LOCALAPPDATA%\Pub\Cache\bin;%USERPROFILE%\fvm\default\bin;%PATH%
170171
- fvm install %FLUTTER_VERSION%
@@ -194,13 +195,9 @@ for:
194195
- mkdir %flet_sdk_root%\packages\flet-desktop\src\flet_desktop\app
195196
- xcopy flet %flet_sdk_root%\packages\flet-desktop\src\flet_desktop\app\flet\ /s /e
196197

197-
# install poetry env
198+
# build package
198199
- cd %flet_sdk_root%
199-
- poetry install
200-
201-
# build "flet-desktop" package
202-
- cd packages\flet-desktop
203-
- poetry build
200+
- uv build --wheel --package flet-desktop
204201
- ps: |
205202
$ErrorActionPreference = "Continue"
206203
Get-ChildItem -Path dist/*-py3-none-any.whl | ForEach-Object {
@@ -209,15 +206,14 @@ for:
209206
Remove-Item $_.FullName
210207
}
211208
$ErrorActionPreference = "Stop"
212-
- cd %APPVEYOR_BUILD_FOLDER%
213-
- dir %flet_sdk_root%\packages\flet-desktop\dist
209+
- dir dist
214210

215211
# publish
216212
- ps: |
217213
if (($env:APPVEYOR_REPO_BRANCH -eq "main" -or $env:APPVEYOR_REPO_TAG_NAME) -and (-not $env:APPVEYOR_PULL_REQUEST_NUMBER)) {
218-
twine upload $env:flet_sdk_root\packages\flet-desktop\dist\*
214+
twine upload $env:flet_sdk_root\dist\*
219215
} elseif (-not $env:APPVEYOR_PULL_REQUEST_NUMBER) {
220-
$wheels = (Get-ChildItem $env:flet_sdk_root/packages/flet-desktop/dist/*.whl | Select-Object -ExpandProperty FullName)
216+
$wheels = (Get-ChildItem $env:flet_sdk_root/dist/*.whl | Select-Object -ExpandProperty FullName)
221217
foreach ($wheel in $wheels) {
222218
curl.exe -sF package=@$wheel https://$env:GEMFURY_TOKEN@push.fury.io/flet/
223219
}
@@ -227,7 +223,7 @@ for:
227223

228224
artifacts:
229225
- path: client\build\windows\x64\runner\flet-windows.zip
230-
- path: sdk\python\packages\flet-desktop\dist\*.whl
226+
- path: sdk\python\packages\*.whl
231227

232228
deploy:
233229
provider: GitHub
@@ -261,27 +257,22 @@ for:
261257
# Python package
262258
- patch_python_package_versions
263259

264-
# install poetry env
260+
# build package
265261
- cd $flet_sdk_root
266-
- poetry install
267-
268-
# build "flet-desktop" package
269-
- pushd packages/flet-desktop
270-
- poetry build
262+
- uv build --wheel --package flet-desktop
271263
- sh: |
272264
for file in dist/*-py3-none-any.whl; do
273265
python $root/ci/repackage_wheel_with_tag.py $file "py3-none-macosx_12_0_arm64"
274266
python $root/ci/repackage_wheel_with_tag.py $file "py3-none-macosx_10_14_x86_64"
275267
rm $file
276268
done
277-
- popd
278269
279270
# publish
280-
- publish_to_pypi packages/flet-desktop/dist/*.whl
271+
- publish_to_pypi dist/*.whl
281272

282273
artifacts:
283274
- path: client/flet-macos.tar.gz
284-
- path: sdk/python/packages/flet-desktop/dist/*.whl
275+
- path: sdk/python/dist/*.whl
285276

286277
deploy:
287278
provider: GitHub
@@ -346,13 +337,13 @@ for:
346337
# Python package
347338
- patch_python_package_versions
348339

349-
# install poetry env
340+
# build package
350341
- cd $flet_sdk_root
351-
- poetry install
352-
353-
# build "flet-desktop" package
354-
- pushd packages/flet-desktop
355-
- poetry build
342+
- sh: |
343+
if [[ "$PACKAGE_NAME" == "flet-desktop-light" ]]; then
344+
sed -i 's/flet-desktop/flet-desktop-light/g' pyproject.toml
345+
fi
346+
- uv build --wheel --package $PACKAGE_NAME
356347
- sh: |
357348
for file in dist/*-py3-none-any.whl; do
358349
for tag in "${wheel_tags[@]}"; do
@@ -361,14 +352,13 @@ for:
361352
done
362353
rm "$file"
363354
done
364-
- popd
365355
366356
# publish
367-
- publish_to_pypi packages/flet-desktop/dist/*.whl
357+
- publish_to_pypi dist/*.whl
368358

369359
artifacts:
370360
- path: client/flet-linux-*.tar.gz
371-
- path: sdk/python/packages/flet-desktop/dist/*.whl
361+
- path: sdk/python/dist/*.whl
372362

373363
deploy:
374364
provider: GitHub
@@ -395,28 +385,25 @@ for:
395385
- flutter build web --wasm
396386
- cp -R build/web $flet_sdk_root/packages/flet-web/src/flet_web
397387
# fix on mobile Safari: https://github.com/flutter/flutter/issues/145111#issuecomment-2714599139
398-
- cp "$(dirname "$(command -v flutter)")/cache/flutter_web_sdk/flutter_js/flutter.js.map" $flet_sdk_root/packages/flet-web/src/flet_web
388+
- ls "$(dirname "$(command -v flutter)")/cache/flutter_web_sdk/flutter_js"
389+
- cp "$(dirname "$(command -v flutter)")/cache/flutter_web_sdk/flutter_js/flutter.js.map" $flet_sdk_root/packages/flet-web/src/flet_web/web
390+
- curl -L $PYODIDE_URL | tar -xj -C "$flet_sdk_root/packages/flet-web/src/flet_web/web"
399391
- popd
400392
- tar -czvf client/build/flet-web.tar.gz -C client/build/web .
401393

402394
# Python package
403395
- patch_python_package_versions
404396

405-
# install poetry env
397+
# build package
406398
- cd $flet_sdk_root
407-
- poetry install
408-
409-
# build "flet-web" package
410-
- pushd packages/flet-web
411-
- poetry build
412-
- popd
399+
- uv build --wheel --package flet-web
413400

414401
# publish
415-
- publish_to_pypi packages/flet-web/dist/*.whl
402+
- publish_to_pypi dist/*.whl
416403

417404
artifacts:
418405
- path: client/build/flet-web.tar.gz
419-
- path: sdk/python/packages/flet-web/dist/*.whl
406+
- path: sdk/python/dist/*.whl
420407

421408
deploy:
422409
provider: GitHub
@@ -437,14 +424,13 @@ for:
437424
- cd sdk/python
438425
- python -m ensurepip --upgrade
439426
- pip3 install --upgrade setuptools pip
440-
- curl -sSL https://install.python-poetry.org | python -
427+
- curl -LsSf https://astral.sh/uv/install.sh | sh
441428
- export PATH="$HOME/.local/bin:$PATH"
442-
- poetry install
443429

444430
build: off
445431

446432
test_script:
447-
- poetry run pytest
433+
- uv run pytest
448434

449435
######################
450436
# Python Build #
@@ -461,30 +447,19 @@ for:
461447
build_script:
462448
- patch_python_package_versions
463449

464-
# install poetry env
450+
# build packages
465451
- cd $flet_sdk_root
466-
- poetry install
452+
- uv build --wheel --package flet-cli
453+
- uv build --wheel --package flet
467454

468-
# build "flet-cli" package
469-
- pushd packages/flet-cli
470-
- poetry build
471-
- popd
472-
473-
# build "flet" package
474-
- pushd packages/flet
475-
- poetry build
455+
# update deps
476456
- python $root/ci/update-flet-wheel-deps.py dist
477-
- popd
478457

479-
# publish package
480-
- |
481-
publish_to_pypi \
482-
packages/flet-cli/dist/*.whl \
483-
packages/flet/dist/*.whl
458+
# publish packages
459+
- publish_to_pypi dist/*.whl
484460

485461
artifacts:
486-
- path: sdk/python/packages/flet-cli/dist/*
487-
- path: sdk/python/packages/flet/dist/*
462+
- path: sdk/python/dist/*.whl
488463

489464
deploy:
490465
provider: GitHub

CONTRIBUTING.md

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ git clone https://github.com/flet-dev/flet
1010

1111
## Python SDK
1212

13-
### Install Poetry
13+
### Install uv
1414

1515
#### Windows
1616

1717
```powershell
18-
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -
18+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
1919
```
2020

2121
Be sure to add `%USERPROFILE%\AppData\Roaming\Python\Scripts` to `PATH`.
2222

23-
#### macOS
23+
#### macOS/Linux
2424

2525
```
26-
curl -sSL https://install.python-poetry.org | python3 -
26+
curl -LsSf https://astral.sh/uv/install.sh | sh
2727
```
2828

2929
### Open worker directory
@@ -37,7 +37,7 @@ cd sdk/python
3737
To install all Flet dependencies and enable the project as editable package run:
3838

3939
```
40-
poetry install
40+
uv sync
4141
```
4242

4343
### Check the installation
@@ -57,7 +57,7 @@ flet.app(target=main)
5757
and then run it:
5858

5959
```
60-
poetry run python hello.py
60+
uv run python hello.py
6161
```
6262

6363
During the first run Flet Client (`flet`) executable will be downloaded from [Flet GitHub releases](https://github.com/flet-dev/flet/releases) to a user temp directory and then started from there. The version of release to download from is taken from `flet/version.py` file.
@@ -66,10 +66,10 @@ You should see a new native OS window opened with "Hello, world!" in it.
6666

6767
### Running tests
6868

69-
Pytest should be run with `poetry run`:
69+
Pytest should be run with `uv run`:
7070

7171
```
72-
poetry run pytest
72+
uv run pytest
7373
```
7474

7575
### Code formatting
@@ -95,19 +95,10 @@ Install `isort` extension for imports formatting: https://marketplace.visualstud
9595

9696
### pre-commit
9797

98-
[pre-commit](https://pre-commit.com) is a dev dependency of Flet and is automatically installed by `poetry install`.
99-
To install the pre-commit hooks run: `poetry run pre-commit install`.
98+
[pre-commit](https://pre-commit.com) is a dev dependency of Flet and is automatically installed by `uv sync`.
99+
To install the pre-commit hooks run: `uv run pre-commit install`.
100100
Once installed, every time you commit, pre-commit will run the configured hooks against changed files.
101101

102-
## Possible installation error when working with a source package
103-
104-
When you run python3 hello.py, you might encounter an error like this:
105-
`FileNotFoundError: [Error 2] No such file or directory: '/var/folders/xm/cyv42vbs27gff3s39vy97rx00000gn/T/fletd-0.1.50/fletd'`
106-
107-
To resolve the issue, just delete this folder `../T/fletd-0.1.50/fletd`. The folder is the one with the FileNotFound Error encountered earlier.
108-
109-
It should work now.
110-
111102
## Flutter client
112103

113104
Add the `FLET_VIEW_PATH` and `FLET_WEB_PATH` variables to the environment variables or profile scripts for your respective OS, making sure to modify the path accordingly:
@@ -163,7 +154,7 @@ Create a new folder preferably named `playground` (it has been added to the giti
163154
Try running the below command, where `<your-main.py>` is the file to test your additions:
164155
165156
```bash
166-
poetry run flet run -w -p 8550 playground/<your-main.py>
157+
uv run flet run -w -p 8550 playground/<your-main.py>
167158
```
168159
You should see http://127.0.0.1:8550/ opened in the browser and also a desktop window with the output of your code.
169160
Making changes to the `<your-main.py>` will automatically trigger a hot reload.
@@ -182,9 +173,10 @@ You will be able to see the debugging outputs of the flet client in this termina
182173
- slowest: use `flutter run` as seen previously.
183174

184175
- When you make changes to the flet **python** files, you will need to restart/rerun the Python client for the changes to take effect in the opened flutter applications. This is done with the same command:
185-
```bash
186-
poetry run flet run -w -p 8550 playground/<your-main.py>
187-
```
176+
177+
```bash
178+
uv run flet run -w -p 8550 playground/<your-main.py>
179+
```
188180

189181
## Releasing Flet
190182

@@ -252,17 +244,17 @@ which ruby
252244
* **GitHub Desktop**: https://desktop.github.com/download/
253245
Open GitHub Desktop app, install Rosetta.
254246

255-
* **Poetry**: https://python-poetry.org/docs/#installing-with-the-official-installer
247+
* **uv**: https://docs.astral.sh/uv/getting-started/installation/
256248

257-
After installing poetry, set PATH:
249+
After installing uv, set PATH:
258250
```
259251
echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.zprofile
260252
```
261253

262-
Check Poetry version and make sure it's in PATH:
254+
Check `uv` version and make sure it's in PATH:
263255

264256
```
265-
poetry --version
257+
uv --version
266258
```
267259

268260
* **Android Studio** for Android SDK required by Flutter: https://developer.android.com/studio

ci/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ echo "flet_sdk_root: $flet_sdk_root"
44

55
python --version
66
pip install --upgrade setuptools wheel twine tomlkit
7-
curl -sSL https://install.python-poetry.org | python3 -
7+
curl -LsSf https://astral.sh/uv/install.sh | sh
88
export PATH="$HOME/.local/bin:$PATH"
99

1010
function patch_python_package_versions() {

ci/patch_toml_versions.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@
2121
t["project"]["version"] = ver
2222

2323
# patch dependencies
24-
deps = t["tool"]["poetry"]["dependencies"]
24+
deps: list[str] = t["project"]["dependencies"]
2525

2626

2727
def patch_dep(dep_name):
28-
if deps.get(dep_name):
29-
if isinstance(deps[dep_name], dict):
30-
deps[dep_name]["version"] = ver
31-
else:
32-
deps[dep_name] = ver
28+
for i in range(0, len(deps)):
29+
dep = deps[i]
30+
if dep == dep_name:
31+
deps[i] = f"{dep_name}=={ver}"
32+
elif dep.startswith(f"{dep_name};"):
33+
deps[i] = dep.replace(f"{dep_name};", f"{dep_name}=={ver};")
3334

3435

3536
patch_dep("flet-cli")

ci/update-flet-wheel-deps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ def update_metadata(metadata_file, version):
3333
i = 0
3434
while i < len(lines):
3535
# insert Requires-Dist: flet-desktop-light ...
36-
if lines[i].startswith("Requires-Dist: flet-desktop "):
36+
if lines[i].startswith("Requires-Dist: flet-desktop=="):
3737
lines.insert(
3838
i + 1,
39-
f'Requires-Dist: flet-desktop-light (=={version}) ; platform_system == "Linux" and (extra == "all" or extra == "desktop")\n',
39+
f'Requires-Dist: flet-desktop-light=={version}; platform_system == "Linux" and (extra == "all" or extra == "desktop")\n',
4040
)
4141
lines[i] = re.sub(
4242
r'platform_system != "desktop-light"',

client/web/assets/fonts/roboto.woff2

62 KB
Binary file not shown.

0 commit comments

Comments
 (0)