Python: Make space for additional python modules

Move Slint module into sub-directory under api/python
This commit is contained in:
Simon Hausmann 2025-06-25 10:20:51 +02:00 committed by Simon Hausmann
parent ad2766518e
commit 86befbe769
43 changed files with 31 additions and 31 deletions

View file

@ -149,7 +149,7 @@ jobs:
- name: "Python docs"
run: uv run build_docs.py
working-directory: api/python
working-directory: api/python/slint
- name: Generate a token
if: ${{ github.ref == 'refs/heads/master' }}
@ -192,11 +192,11 @@ jobs:
target/cppdocs/html
docs/astro/dist
api/node/docs
api/python/docs
api/python/slint/docs
docs/site
- name: "Check for docs warnings in internal crates"
run: cargo doc --workspace --no-deps --all-features --exclude slint-node --exclude pyslint --exclude mcu-board-support --exclude mcu-embassy --exclude printerdemo_mcu --exclude carousel --exclude test-* --exclude plotter --exclude uefi-demo --exclude ffmpeg --exclude gstreamer-player --exclude slint-cpp --exclude slint-python
- name: Clean cache # Don't cache docs to avoid them including removed classes being published
run: |
rm -rf target/doc target/cppdocs api/node/docs api/python/docs
rm -rf target/doc target/cppdocs api/node/docs api/python/slint/docs

View file

@ -207,13 +207,13 @@ jobs:
uses: astral-sh/setup-uv@v6
- uses: fjwillemsen/setup-nox2@v3.0.0
- name: Run python tests
working-directory: api/python
working-directory: api/python/slint
run: nox --default-venv-backend uv
- name: Run mypy
working-directory: api/python
working-directory: api/python/slint
run: uv run mypy -p tests -p slint
- name: Run ruff linter
working-directory: api/python
working-directory: api/python/slint
run: uv tool run ruff check
cpp_test_driver:

View file

@ -14,7 +14,7 @@ on:
env:
MACOSX_DEPLOYMENT_TARGET: "11.0"
# Keep in sync with features in nightly_snapshot.yaml, slint_tool_binary.yaml, api/node/Cargo.toml, and api/python/Cargo.toml
# Keep in sync with features in nightly_snapshot.yaml, slint_tool_binary.yaml, api/node/Cargo.toml, and api/python/slint/Cargo.toml
SLINT_BINARY_FEATURES: "-DSLINT_FEATURE_BACKEND_LINUXKMS_NOSEAT=ON -DSLINT_FEATURE_BACKEND_WINIT=ON -DSLINT_FEATURE_RENDERER_FEMTOVG=ON -DSLINT_FEATURE_RENDERER_SKIA=ON -DSLINT_FEATURE_RENDERER_SOFTWARE=ON"
SLINT_MCU_FEATURES: "-DSLINT_FEATURE_FREESTANDING=ON -DSLINT_FEATURE_RENDERER_SOFTWARE=ON"
# env variable used by espup https://github.com/esp-rs/espup?tab=readme-ov-file#github-api

View file

@ -22,7 +22,7 @@ on:
- cron: "0 2 * * *"
env:
# Keep in sync with features in slint_tool_binary.yaml, cpp_package.yaml, api/node/Cargo.toml, and api/python/Cargo.toml
# Keep in sync with features in slint_tool_binary.yaml, cpp_package.yaml, api/node/Cargo.toml, and api/python/slint/Cargo.toml
SLINT_BINARY_FEATURES: "backend-linuxkms-noseat,backend-winit,renderer-femtovg,renderer-skia,renderer-software"
MACOSX_DEPLOYMENT_TARGET: "11.0"
@ -475,7 +475,7 @@ jobs:
mkdir -p $output_path/docs/node
cp -a ../api/node/docs/* $output_path/docs/node/
mkdir -p $output_path/docs/python
cp -a ../api/python/docs/* $output_path/docs/python/
cp -a ../api/python/slint/docs/* $output_path/docs/python/
mkdir -p $output_path/docs/slint
cp -a ../docs/astro/dist/* $output_path/docs/slint/

View file

@ -15,7 +15,7 @@ on:
features:
type: string
description: features to enable for build
# Keep in sync with features in nightly_snapshot.yaml, cpp_package.yaml,api/node/Cargo.toml, and api/python/Cargo.toml
# Keep in sync with features in nightly_snapshot.yaml, cpp_package.yaml,api/node/Cargo.toml, and api/python/slint/Cargo.toml
default: "backend-linuxkms-noseat,backend-winit,renderer-femtovg,renderer-skia,renderer-software"
codesign:
type: boolean
@ -30,7 +30,7 @@ on:
features:
type: string
description: features to enable for build
# Keep in sync with features in nightly_snapshot.yaml, cpp_package.yaml,api/node/Cargo.toml, and api/python/Cargo.toml
# Keep in sync with features in nightly_snapshot.yaml, cpp_package.yaml,api/node/Cargo.toml, and api/python/slint/Cargo.toml
default: "backend-linuxkms-noseat,backend-winit,renderer-femtovg,renderer-skia,renderer-software"
codesign:
type: boolean

View file

@ -26,7 +26,7 @@ jobs:
sed -i 's/ VERSION [0-9]*\.[0-9]*\.[0-9]*)$/ VERSION ${{ github.event.inputs.new_version }})/' api/cpp/CMakeLists.txt
# The version is also in these files
sed -i "s/^version = \"[0-9]*\.[0-9]*\.[0-9]*\(.*\)\"/version = \"${{ github.event.inputs.new_version }}\1\"/" api/cpp/docs/conf.py api/python/pyproject.toml
sed -i "s/^version = \"[0-9]*\.[0-9]*\.[0-9]*\(.*\)\"/version = \"${{ github.event.inputs.new_version }}\1\"/" api/cpp/docs/conf.py api/python/slint/pyproject.toml
# Version in package.json files
git ls-files | grep package.json | xargs sed -i 's/"version": ".*"/"version": "${{ github.event.inputs.new_version }}"/'

View file

@ -54,7 +54,7 @@ jobs:
with:
crate: taplo-cli
- name: Prepare feature config for binaries
working-directory: api/python
working-directory: api/python/slint
shell: bash
run: |
cat Cargo.toml | taplo format --option column_width=100000 --stdin-filepath=Cargo.toml - | \
@ -67,7 +67,7 @@ jobs:
- name: Build a binary wheel
uses: PyO3/maturin-action@v1
with:
working-directory: api/python
working-directory: api/python/slint
target: ${{ matrix.platform.target }}
args: --release --out wheelhouse --find-interpreter
container: ${{ matrix.platform.container }}
@ -75,7 +75,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: python-package-distributions-${{ matrix.platform.runner }}-${{ strategy.job-index }}
path: api/python/wheelhouse/*.whl
path: api/python/slint/wheelhouse/*.whl
ios_binaries:
strategy:
@ -108,7 +108,7 @@ jobs:
with:
crate: taplo-cli
- name: Prepare feature config for binaries
working-directory: api/python
working-directory: api/python/slint
shell: bash
run: |
cat Cargo.toml | taplo format --option column_width=100000 --stdin-filepath=Cargo.toml - | \
@ -138,7 +138,7 @@ jobs:
env:
_PYTHON_HOST_PLATFORM: ${{ matrix.tag }}
with:
working-directory: api/python
working-directory: api/python/slint
target: ${{ matrix.target }}
args: --release --out wheelhouse --find-interpreter
@ -146,7 +146,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: python-package-distributions-${{ matrix.target }}
path: api/python/wheelhouse/*.whl
path: api/python/slint/wheelhouse/*.whl
build_source_package:
name: Build source package
@ -157,7 +157,7 @@ jobs:
with:
crate: taplo-cli
- name: Prepare feature config for binaries
working-directory: api/python
working-directory: api/python/slint
shell: bash
run: |
cat Cargo.toml | taplo format --option column_width=100000 --stdin-filepath=Cargo.toml - | \
@ -169,13 +169,13 @@ jobs:
- name: Build source package
uses: PyO3/maturin-action@v1
with:
working-directory: api/python
working-directory: api/python/slint
command: sdist
args: --out dist
- uses: actions/upload-artifact@v4
with:
name: python-package-distributions-source
path: api/python/dist/*.tar.gz
path: api/python/slint/dist/*.tar.gz
publish-to-test-pypi:
if: ${{ github.event.inputs.release != 'true' }}

View file

@ -8,7 +8,7 @@ members = [
'api/rs/build',
'api/rs/macros',
'api/rs/slint',
'api/python',
'api/python/slint',
'api/wasm-interpreter',
'examples/7guis',
"examples/bevy",

View file

@ -103,7 +103,7 @@ Refer to the README of each language directory in the `api` folder:
- [C++](api/cpp) ([Documentation][#15] | [Getting Started Template][#17])
- [Rust](api/rs/slint) [![Crates.io][#18]][#19] ([Documentation][#20] | [Tutorial Video][#22] | [Getting Started Template][#23])
- [JavaScript/NodeJS (Beta)](api/node) [![npm][#24]][#25] ([Documentation][#26] | [Getting Started Template][#28])
- [Python (Beta)](api/python) [![pypi][#31]][#32] ([Documentation][#33] | [Getting Started Template][#34])
- [Python (Beta)](api/python/slint) [![pypi][#31]][#32] ([Documentation][#33] | [Getting Started Template][#34])
## Architecture

View file

@ -22,7 +22,7 @@ path = "rust/lib.rs"
[features]
default = ["backend-winit", "renderer-femtovg", "renderer-software", "backend-qt", "accessibility"]
# Keep in sync with features in nightly_snapshot.yaml, cpp_package.yaml, slint_tool_binary.yaml, and api/python/Cargo.toml
# Keep in sync with features in nightly_snapshot.yaml, cpp_package.yaml, slint_tool_binary.yaml, and api/python/slint/Cargo.toml
# binaries: default = ["backend-linuxkms-noseat", "backend-winit", "renderer-femtovg", "renderer-skia", "accessibility"]
backend-qt = ["slint-interpreter/backend-qt"]

View file

@ -38,7 +38,7 @@ def test_property_access() -> None:
finished: true,
dash-prop: true,
};
in property <image> imageprop: @image-url("../../../demos/printerdemo/ui/images/cat.jpg");
in property <image> imageprop: @image-url("../../../../demos/printerdemo/ui/images/cat.jpg");
callback test-callback();
}
@ -103,7 +103,7 @@ def test_property_access() -> None:
Image.load_from_path(
os.path.join(
os.path.dirname(__file__),
"../../../examples/iot-dashboard/images/humidity.png",
"../../../../examples/iot-dashboard/images/humidity.png",
)
),
)
@ -193,7 +193,7 @@ def test_callbacks() -> None:
if __name__ == "__main__":
import slint
module = slint.load_file(Path("../../demos/printerdemo/ui/printerdemo.slint"))
module = slint.load_file(Path("../../../demos/printerdemo/ui/printerdemo.slint"))
instance = module.MainWindow()
instance.PrinterQueue.start_job = lambda title: print(f"new print job {title}")
instance.run()

View file

@ -15,7 +15,7 @@ def test_magic_import_path() -> None:
oldsyspath = sys.path
assert loader.printerdemo is None
try:
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", ".."))
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", ".."))
instance = loader.demos.printerdemo.ui.printerdemo.MainWindow()
del instance
finally:

View file

@ -10,4 +10,4 @@ requires-python = ">=3.12"
dependencies = ["slint"]
[tool.uv.sources]
slint = { path = "../../../api/python", editable = true }
slint = { path = "../../../api/python/slint", editable = true }

View file

@ -47,7 +47,7 @@ Add the following section to your `pyproject.toml` to configure [uv](https://doc
```toml
[tool.uv.sources]
slint = { git = "https://github.com/slint-ui/slint", subdirectory = "api/python" }
slint = { git = "https://github.com/slint-ui/slint", subdirectory = "api/python/slint" }
```
### Editors / IDEs

View file

@ -10,4 +10,4 @@ requires-python = ">=3.12"
dependencies = ["slint"]
[tool.uv.sources]
slint = { path = "../../api/python", editable = true }
slint = { path = "../../api/python/slint", editable = true }