bug: [packaging] editing requirements.txt does not trigger pip reinstall (stale hash), produces APK with missing/empty site-packages
Los mantenedores suelen responder en 1 día
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Duplicate Check
- I have searched the opened issues and there are no duplicates
Describe the bug
flet build apk: editing requirements.txt does not trigger pip reinstall (stale hash), produces APK with missing/empty site-packages
Affected versions
- flet 0.85.3 (verified locally)
- flet 1.0.5 /
mainbranch (code path unchanged — verified againstsdk/python/packages/flet-cli/src/flet_cli/commands/build_base.pyon GitHub main as of 2026-10-24) - Platform: Windows 10 Pro (10.0.19045),
flet build apk(Android target)
Summary
When requirements.txt is modified between builds, flet build apk does NOT
re-run pip install. The incremental-build hash that decides whether to pass
--skip-site-packages only includes the path of requirements.txt, not
its contents. The branch that hashes the file contents is gated behind
self.verbose > 1, so in a default (verbose=0) build the contents are never
hashed, and editing dependencies silently reuses stale site-packages.
This is worse than "stale": if build/site-packages was removed (or the
previous build failed partway), the skip logic still fires, and the resulting
APK contains no third-party packages at all. The app then crashes at
import time (e.g. ModuleNotFoundError: No module named 'certifi'), and on
Android the error is swallowed — the user just sees a white screen.
Related issues (same symptoms, root cause never identified)
Several closed issues report the same failure mode, all resolved with
"delete the build directory" without tracing the cause:
- #5376
ModuleNotFoundError: No module named 'certifi'— identical traceback
(even the sameline 77) to what we hit; closed without root cause - #6049 gTTS installed but missing from APK (CI had cached
build/) - #6213, #5113, #5952 various ModuleNotFoundError after adding deps
- #2406, #2611 same on Windows builds
As long as the hash ignores requirements.txt contents, any user who edits
dependencies and has a warm build/ cache (or clears site-packages but
not .hash) will hit this again.
Root cause (source, build_base.py)
Contents only hashed under verbose (0.85.3 line ~1941 / main line ~2610):
elif requirements_txt.exists():
if self.verbose > 1: # <-- gate
with open(requirements_txt, encoding="utf-8") as f:
reqs_txt_contents = f.read()
...
hash.update(reqs_txt_contents) # <-- only reached with -vv
package_args.extend(["-r", "-r", "-r", str(requirements_txt)])
Skip decision (0.85.3 line ~2051 / main line ~2808):
for arg in package_args: # <-- only "-r <path>", "--exclude ...", etc.
hash.update(arg)
if not dev_packages_configured:
if not hash.has_changed():
package_args.append("--skip-site-packages") # <-- pip skipped
Since package_args contains only the path string of requirements.txt,
editing its contents changes nothing in the hash → --skip-site-packages is
appended → pip install never runs.
Impact note
On Android the resulting failure mode is severe for debugging: the missing
module crashes Python at import time, the error is not surfaced in logcat, and
the app renders a blank screen. It took considerable effort to trace this back
to the packaging cache. (In our case certifi was missing from the APK while
present in requirements.txt-installed environments, since build/site-packages
had been cleared while the hash stamp remained.)
Code sample
Steps to reproduce
mkdir repro && cd repro
# main.py — any minimal flet app
cat > main.py <<'EOF'
import flet as ft
def main(page: ft.Page):
page.add(ft.Text("hello"))
ft.run(main)
EOF
printf 'flet==0.85.3\nhttpx==0.28.1\n' > requirements.txt
# Build 1: baseline — pip runs (~1 min "Packaging Python app...")
flet build apk --yes --project repro --bundle-id com.test.repro
# -> build/site-packages contains httpx, certifi, etc.
# Build 2: change requirements.txt CONTENTS (path unchanged!)
printf 'flet==0.85.3\nhttpx==0.28.1\npyDes\n' > requirements.txt
flet build apk --yes --project repro --bundle-id com.test.repro
# Observe: "Packaging Python app..." completes in ~2 seconds (vs ~60s),
# no pip output; build/site-packages still has the OLD package set.
To reproduce
Measured reproduction (2026-10-24, flet 0.85.3, Windows 10, Python 3.14 host)
| Build 1 (baseline) | Build 2 (after editing requirements.txt) | |
|---|---|---|
Packaging Python app... |
00:49:44 → 00:51:33 (~109 s, pip installs) | 00:55:42 → 00:55:44 (2 s) |
build/site-packages files |
2228 | 2228 — unchanged |
new package pyDes installed |
n/a | No (still absent) |
| Total build time | ~20 min (cold) | ~22 s |
pyDes was added to requirements.txt between builds; after build 2 it is
still absent from build/site-packages, and the .hash/package stamp was
silently rewritten — so build 3 will skip pip again.
Also reproducible by deleting build/site-packages between builds: build 2
then produces an APK whose Python bundle has no third-party packages, and
the app fails at import. This exact sequence (edit requirements → clear
build/site-packages but not build/.hash → rebuild) produced an APK
missing certifi and a blank screen on Android, which is how the issue was
found.
Expected behavior
Expected behavior
Editing requirements.txt should be detected and pip install re-run.
Screenshots / Videos
Captures
[Upload media here]
Operating System
Windows
Operating system details
10 pro
Flet version
0.85.3
Regression
I'm not sure / I don't know
Suggestions
Suggested fix
Unconditionally hash the contents (the verbose > 1 gate should only control
logging the contents, not whether they're hashed):
elif requirements_txt.exists():
with open(requirements_txt, encoding="utf-8") as f:
reqs_txt_contents = f.read()
if self.verbose > 1:
console.log(f"Contents of requirements.txt: {reqs_txt_contents}",
style=verbose2_style)
hash.update(reqs_txt_contents)
Alternatively, hash a stat of the file (mtime + size), or always pass the file
to serious_python and let it decide.## Workaround
Delete build/ (or at least build/.hash/) after changing
requirements.txt, or run flet build apk -vv ... (contents then enter the
hash).
Logs
Logs
[Paste your logs here]
Additional details
No response
- Lenguaje dominante
- Python
- Estrellas
- 17.5k
- Forks
- 740
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 74
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de flet-dev/flet
-
feature: python 3.15 supportAbiertofeature request
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
flet-dev/flet#6985 · 3 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Web: `TextField.focus()` after `on_submit` discards keys typed while the focus request is in flightAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
Los mantenedores suelen responder en 1 día
-
Web: TextField values set through the DOM (autofill-like) are lost; on_submit carries an empty valueAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 1 día
-
feature request
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Los mantenedores suelen responder en 1 día
Todos los issues de flet-dev/flet
Issues similares
-
integration: logger
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
home-assistant/core#191147 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
documentation p4
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
MillenniumDawn/focus-tree-creation-tool#417 ·
Los mantenedores suelen responder en 3 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
CharlesP44/Beem_Energy#96 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
rheeloaded/paperpull#153 ·
Los mantenedores suelen responder en 1 día