Skip to content

fix(flet-cli): correct dependency parsing (#6332)#6340

Open
td3447 wants to merge 3 commits intoflet-dev:mainfrom
td3447:fix/6332-parse-dependency-constraints
Open

fix(flet-cli): correct dependency parsing (#6332)#6340
td3447 wants to merge 3 commits intoflet-dev:mainfrom
td3447:fix/6332-parse-dependency-constraints

Conversation

@td3447
Copy link

@td3447 td3447 commented Mar 21, 2026

Fix #6332

Summary

Commit message

Closes issue: #6332

  • Adds a space (' ') in front of dependencies in pyproject.toml that have version constraints starting with < or <=.
  • Fixes the issue where flet build would give a The system cannot find the file specified. error.

Additional Details

  • This prevents users from having to manually edit the pyproject.toml after adding dependencies with uv add. uv does not have a leading space before the < but with flet build a lack of leading space raises an error.
  • The function looks for a <= or < and bypasses all others, if it has one from the list then it appends a space and adds that to the set.

Test Code

  • Builds tested on the following.
flet build windows | linux | apk

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Summary by Sourcery

Bug Fixes:

  • Ensure dependencies with < or <= version constraints are formatted with a leading space to avoid build failures when parsing pyproject.toml dependencies.

Closes issue: flet-dev#6332
- Adds a space (' ') in front of dependencies in `pyproject.toml` that have version constraints starting with `<` or `<=`.
- Fixes the issue where `flet build` would give a `The system cannot find the file specified.` error.
@CLAassistant
Copy link

CLAassistant commented Mar 21, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@FeodorFitsner
Copy link
Contributor

Thank you for your PR!

This only fixes project.dependencies. flet build / flet publish prefer tool.poetry.dependencies first, and get_poetry_dependencies() can still emit pkg<ver without normalization, so Poetry users may still hit the same issue. Can you fix that too please?

- Fixed parsing issue for dependencies in [tool.poetry.dependencies]
- Adds single space ' ' to the front of the `<` or `<=` to prevent `The system cannot find the file specified.` error.
@td3447
Copy link
Author

td3447 commented Mar 21, 2026

Updates

  • Added compatibility with poetry
  • Edited format_dependency_version() to include checks for < or <= and include a leading space.

Test Code

  • Builds tested on the following.
poetry run flet build windows | apk

Tests

[tool.poetry.dependencies]
 chardet = "<=6"
 chardet = "<6"
 chardet = "   <     6  "

- Fixed an error where a `<` after a `,` was not recognized as a dependency.
- Added more checks to ensure a wider variety of typos are covered.
- Fixed an issue where using a `*` wouldn't correctly look for any version and raise an error.
- Fixed an issue where using a `!` after a `,` would raise an error, since it was missing the required ` ` in front.
- Ensured the correct separators were added for all the types of requirements I could think of
- Added support for clearing whitespace from uv dependencies, in the same way used with the poetry dependencies.
- Tests were conducted on both poetry and uv, using `flet build`
@td3447
Copy link
Author

td3447 commented Mar 25, 2026

Updates

  • Fixed an error where a < after a , was not recognized as a dependency.
  • Added more checks to ensure a wider variety of typos are covered.
  • Fixed an issue where using a * wouldn't correctly look for any version and raise an error.
  • Fixed an issue where using a ! after a , would raise an error, since it was missing the required in front.
  • Ensured the correct separators were added for all the types of requirements I could think of
  • Added support for clearing whitespace from uv dependencies, in the same way used with the poetry dependencies.
  • Tests were conducted on both poetry and uv, using flet build

Testing

Poetry

poetry run flet build windows | apk -v

pyproject.toml (Poetry)

Test Case

[tool.poetry.dependencies]
boto3 = "*       "
packaging = "   26.0    "
urllib3 = "   ^   2.6.0    "
setuptools = "  ~  82.0.0  "
certifi = "  >=  2026.1.4  "
chardet = " < 6 "
requests = " <= 2.32.4 "
pydantic = " >= 2.9.0 ,     <3.0.0   "
pillow = "  >  11.1.0,  <=  12.0.0  "
sqlalchemy = "  >=   1.4   ,  <=2.0"
pandas = " >=  2.3,  != 2.3.3  "
scipy = { version = "^ 1.16", optional = true }
uvicorn = { version = ">=  0.42.0", extras = ["standard"] }
pywin32 = { version = " >=  310", markers = "sys_platform == 'win32'" }
numpy = { git = "https://github.com/numpy/numpy.git", branch = "main" }
Standard case
[tool.poetry.dependencies]
boto3 = "*"
packaging = "26.0"
urllib3 = "^2.6.0"
setuptools = "~82.0.0"
certifi = ">=2026.1.4"
chardet = "<6"
requests = "<=2.32.4"
pydantic = ">=2.9.0,<3.0.0"
pillow = ">11.1.0,<=12.0.0"
sqlalchemy = ">=1.4,<=2.0"
pandas = ">=2.3,!=2.3.3"
scipy = { version = "^1.16", optional = true }
uvicorn = { version = ">=0.42.0", extras = ["standard"] }
pywin32 = { version = ">=310", markers = "sys_platform == 'win32'" }
numpy = { git = "https://github.com/numpy/numpy.git", branch = "main" }

Output

[dependencies]
pandas>=2.3, !=2.3.3
boto3
certifi>=2026.1.4
chardet <6
pydantic>=2.9.0, <3.0.0
packaging==26.0
scipy>=1.16
requests <=2.32.4
numpy@git+https://github.com/numpy/numpy.git@main
pywin32>=310;sys_platform == 'win32'
setuptools~=82.0.0
pillow>11.1.0, <=12.0.0
urllib3>=2.6.0
uvicorn>=0.42.0
sqlalchemy>=1.4, <=2.0
Detailed Output
dep: boto3
sep: ''
val:
suf:

dep: packaging
sep: '=='
val: 26.0
suf:

dep: urllib3
sep: '>='
val: 2.6.0
suf:

dep: setuptools
sep: ''
val: ~=82.0.0
suf:

dep: certifi
sep: ''
val: >=2026.1.4
suf:

dep: chardet
sep: ''
val:  <6
suf:

dep: requests
sep: ''
val:  <=2.32.4
suf:

dep: pydantic
sep: ''
val: >=2.9.0, <3.0.0
suf:

dep: pillow
sep: ''
val: >11.1.0, <=12.0.0
suf:

dep: sqlalchemy
sep: ''
val: >=1.4, <=2.0
suf:

dep: pandas
sep: ''
val: >=2.3, !=2.3.3
suf:

start: scipy^1.16
dep: scipy
sep: '>='
val: 1.16
suf:

start: uvicorn>=0.42.0
dep: uvicorn
sep: ''
val: >=0.42.0
suf:

start: pywin32>=310
dep: pywin32
sep: ''
val: >=310
suf: ;sys_platform == 'win32'

dep: numpy
sep: '@'
val: git+https://github.com/numpy/numpy.git@main
suf:

Result

Build successful 🥳


UV

uv run flet build windows | apk -v

pyproject.toml (UV)

Test Case

dependencies = [
    "flet    ",
    "  boto3  ",
    "  packaging  ==   26.0    ",
    " urllib3  >=  2.6.0 ",
    "  setuptools  ~=  82.0.0 ",
    " certifi  >= 2026.1.4  ",
    "chardet <  6  ",
    "requests <=  2.32.4",
    "pydantic>=   2.9.0  , <3.0.0  ",
    "pillow>  11.1.0, <=12.0.0  ",
    "sqlalchemy>=1.4, <=2.0",
    "uvicorn[  standard  ]>=  0.42.0",
    "pywin32   >=310 ; sys_platform     == 'win32'",
    "numpy @ git+https://github.com/numpy/numpy.git@main",
]
Standard case
dependencies = [
    "flet",
    "boto3",
    "packaging==26.0",
    "urllib3>=2.6.0",
    "setuptools~=82.0.0",
    "certifi>=2026.1.4",
    "chardet <6",
    "requests<=2.32.4",
    "pydantic>=2.9.0, <3.0.0",
    "pillow>11.1.0, <=12.0.0",
    "sqlalchemy>=1.4, <=2.0",
    "pandas>=2.3, !=2.3.3",
    # "scipy>=1.16",
    "uvicorn[standard]>=0.42.0",
    "pywin32>=310; sys_platform == 'win32'",
    "numpy @ git+https://github.com/numpy/numpy.git@main",
]

Output

packaging==26.0
urllib3>=2.6.0
chardet <6
sqlalchemy>=1.4, <=2.0
pydantic>=2.9.0, <3.0.0
pillow>11.1.0, <=12.0.0
boto3
flet
pandas>=2.3, !=2.3.3
pywin32>=310;sys_platform=='win32'
requests <=2.32.4
uvicorn[standard]>=0.42.0
numpy@git+https://github.com/numpy/numpy.git@main
certifi>=2026.1.4
setuptools~=82.0.0
Detailed Output
dep: flet

dep: boto3

dep: packaging==26.0

dep: urllib3>=2.6.0

dep: setuptools~=82.0.0

dep: certifi>=2026.1.4

dep: chardet<6
val: chardet
sep: '<'
suf: 6

dep: requests<=2.32.4
val: requests
sep: '<='
suf: 2.32.4

dep: pydantic>=2.9.0,<3.0.0
val: pydantic>=2.9.0,
sep: '<'
suf: 3.0.0

dep: pillow>11.1.0,<=12.0.0
val: pillow>11.1.0,
sep: '<='
suf: 12.0.0

dep: sqlalchemy>=1.4,<=2.0
val: sqlalchemy>=1.4,
sep: '<='
suf: 2.0

dep: pandas>=2.3,!=2.3.3
val: pandas>=2.3,
sep: '!'
suf: =2.3.3

dep: uvicorn[standard]>=0.42.0

dep: pywin32>=310;sys_platform=='win32'

dep: numpy@git+https://github.com/numpy/numpy.git@main

Result

Build successful 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: flet build fails with dependency with only <, The system cannot find the file specified.

3 participants