- 
                Notifications
    You must be signed in to change notification settings 
- Fork 764
Code generation workflow for the Slint Python bindings #9834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- introduce slint.codegen to emit runtime modules and stubs from .slint inputs via CLI or API - expose property/callback metadata in the bindings, extend callback decorator overloads, and add libcst-backed emitters for typed modules - document the workflow, add a counter example plus tests, and keep the legacy import-loader path for now
- Drop nox cause we only rely on uv and maturin
- Also drop unnessesary optional-dependencies group
- Make ruff & mypy happy
- `slint.{slint => core}`, `slint.{__init__ => api}`
    | When i apply  | 
| So, isn't it enough to distribute  | 
| Hi! Could you elaborate a bit what this PR does? As part of #4136 we've been working on generating a  | 
| 
 thx for taking a look. this PR is trying to accomplish: 
 the idea of  BTW, the  | 
| WHY  A maturin-powered  [build-system]
requires = ["maturin>=1.9,<2.0"]
build-backend = "maturin"
[project]
name = "slint-compiler"
requires-python = ">=3.10"
classifiers = [
    "Programming Language :: Rust",
    "Programming Language :: Python :: Implementation :: CPython",
]
dynamic = ["version"]
[tool.maturin]
bindings = "bin"
manifest-path = "Cargo.toml" | 
| 
 The idea was to re-use the same binaries we've already built for the release, instead of doing another build for every host combination for Python. I don't feel too strongly about this, but I like that this makes it a very low maintenance solution. Are there any downsides we should address by using dedicated wheels? | 
| 
 No, but current downloader is not friendly to mirrors, which is important for poor network situation like in china mainland. And... personally, I like to follow the Occam's Razor principle, so if we can get it from PyPI, there's no need for our script to download it again from GitHub. In my opinion, this brings more trouble, like the current downloader has to manually concatenate URLs, etc... Anyway, maturin, cibuildwheel and other smart developers have already taken care of these for us, why not take advantage of that? I have drafted  | 
| All enums in  | 
| 
 Yes 
 Yes | 
…t URLs in pyproject.toml
| Now, it can generate  | 
- Added `is_builtin` and `is_used` attributes to `StructMeta` and `EnumMeta` classes for better tracking of built-in types. - Updated the counter example to include a new property for text alignment and adjusted the generated Python code accordingly. - Introduced a new test module for optional types, including structures and enums, to validate their behavior. - Enhanced the test suite to ensure proper handling of enums and structures, including keyword-only arguments and unknown keywords. - Improved the handling of built-in enums in the Rust backend, ensuring they are correctly initialized and exposed to Python. - Refactored existing tests to use the new structure and ensure compatibility with the updated code generation logic. - Added tests for event loop handling, including SIGINT and quit events, to ensure robustness in asynchronous scenarios.
- Recommend running the code generator as part of the build process - Instructions for using third-party component libraries
- Avoid rust-analyzer alarms and spinning
| @tronical SlintEventLoop always exit when the last window quit, even expose and use the  | 
Summary
Testing
Follow-ups