Repository: flet-dev/flet
Issue category: Bug Report

Issue:
`flet build` creates bundle but running it gives `ImportError: No module named main` error
### Duplicate Check

- [X] I have searched the [opened issues](https://github.com/flet-dev/flet/issues) and there are no duplicates

### Describe the bug

Traceback (most recent call last):
  File "<string>", line 47, in <module>
  File "<frozen runpy>", line 222, in run_module
  File "<frozen runpy>", line 142, in _get_module_details
ImportError: No module named main


### Code sample

<details open><summary>Code</summary>

```python
print(error)
```

</details>


### To reproduce

...

### Expected behavior

_No response_

### Screenshots / Videos

<details open>
<summary>Captures</summary>

![Screenshot_2024-11-28-23-36-20-36_92b64b2a7aa6eb3771ed6e18d0029815](https://github.com/user-attachments/assets/e22fcd4a-eaa1-448f-8c61-51164c6cbae7)


</details>


### Operating System

Windows

### Operating system details

11

### Flet version

0.25

### Regression

No, it isn't

### Suggestions

_No response_

### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Additional details

_No response_


Hints:
What do you have in pyproject.toml and what is the file structure of your project?


### `pyproject.toml`

```toml
[project]
name = "weather-app"
version = "0.1.0"
description = ""
readme = "README.md"
requires-python = ">=3.8"
dependencies = [
  "flet"
]

[tool.flet]
# org name in reverse domain name notation, e.g. "com.mycompany".
# Combined with project.name to build bundle ID for iOS and Android apps
org = "com.mycompany"

# project display name that is used as an app title on Android and iOS home screens,
# shown in window titles and about app dialogs on desktop.
product = "Weather Forcast"

# company name to display in about app dialogs
company = "Flet"

# copyright text to display in about app dialogs
copyright = "Copyright (C) 2024 by Flet"

[tool.flet.app]
path = "src"
```
### `Structure`
```
W:\dev-mobile\dev mobile (flet)\api-app\weather-app>flet build apk
[09:17:25] Created Flutter bootstrap project from gh:flet-dev/flet-build-template with ref 0.25.0 ✅
           Customized app icons and splash images ✅
[09:18:41] Generated app icons ✅
[09:18:51] Generated splash screens ✅
[09:21:48] Packaged Python app ✅
[09:30:39] Built .apk for Android ✅
           Copied build to build\apk directory ✅
           Successfully built your .apk for Android! 🥳 Find it in build\apk directory. 📁
```

![Screenshot 2024-11-29 091419](https://github.com/user-attachments/assets/784e36c1-4450-4269-b8f7-a42cf28c11b4)

![Screenshot 2024-11-29 091455](https://github.com/user-attachments/assets/3bcecb4c-51b6-4b33-a2f6-7259916c2477)
![Screenshot 2024-11-29 091512](https://github.com/user-attachments/assets/332c1a6d-4b46-484f-974f-ea914158c952)

I'm having the same problem.
I created a basic project and built it right away, and it runs fine with flet run, but I get an error after building.

win11, 0.25.0

Commands used
```
mkdir flet-test
cd flet-test
flet create .
flet run
flet build windows -vv
cd flet build/windows
flet-test.exe
```

Error Description
```
Traceback (most recent call last):
  File "<string>", line 47, in <module>
  File "<frozen runpy>", line 222, in run_module
  File "<frozen runpy>", line 142, in _get_module_details
ImportError: No module named main
```

I filmed a video of the process.

https://github.com/user-attachments/assets/c6033991-4dbb-4967-9206-2f8833cd2640

The terminal log is here.
[ps-log.txt](https://github.com/user-attachments/files/17961394/ps-log.txt)

Also, apps written with existing FLETs are experiencing the same error after updating from 0.24.1 to 0.25.0.
Thanks for the additional details. I'm on it.

Patch:
diff --git a/sdk/python/packages/flet-cli/src/flet_cli/commands/build.py b/sdk/python/packages/flet-cli/src/flet_cli/commands/build.py
index 0dcd8539a..212157549 100644
--- a/sdk/python/packages/flet-cli/src/flet_cli/commands/build.py
+++ b/sdk/python/packages/flet-cli/src/flet_cli/commands/build.py
@@ -1271,6 +1271,7 @@ def package_python_app(self):
         assert self.options
         assert self.get_pyproject
         assert self.python_app_path
+        assert self.package_app_path
         assert self.build_dir
         assert self.flutter_dir
 
@@ -1282,7 +1283,7 @@ def package_python_app(self):
             "run",
             "serious_python:main",
             "package",
-            str(self.python_app_path),
+            str(self.package_app_path),
             "--platform",
             self.package_platform,
         ]


Test patch: