flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
11.24k stars 432 forks source link

Flet module does not include binaries when installed with Conda on macOS #203

Open clstaudt opened 2 years ago

clstaudt commented 2 years ago

Trying to package a simple demo app:

╰─ pyinstaller counter.py                                                                                                                           (flet-test) 
291 INFO: PyInstaller: 5.1
291 INFO: Python: 3.10.5 (conda)
320 INFO: Platform: macOS-12.5.1-arm64-i386-64bit
321 INFO: wrote /Users/cls/Documents/Work/Projects/PrototypeFund/Dev/flet-test/counter.spec
326 INFO: UPX is not available.
327 INFO: Extending PYTHONPATH with paths
['/Users/cls/Documents/Work/Projects/PrototypeFund/Dev/flet-test']
697 INFO: checking Analysis
698 INFO: Building Analysis because Analysis-00.toc is non existent
698 INFO: Initializing module dependency graph...
699 INFO: Caching module graph hooks...
707 INFO: Analyzing base_library.zip ...
3546 INFO: Processing pre-find module path hook distutils from '/Users/cls/miniforge3/envs/flet-test/lib/python3.10/site-packages/PyInstaller/hooks/pre_find_module_path/hook-distutils.py'.
3639 INFO: distutils: retargeting to non-venv dir '/Users/cls/miniforge3/envs/flet-test/lib/python3.10'
4468 INFO: Caching module dependency graph...
4565 INFO: running Analysis Analysis-00.toc
4569 INFO: Analyzing /Users/cls/Documents/Work/Projects/PrototypeFund/Dev/flet-test/counter.py
5524 INFO: Processing pre-safe import module hook six.moves from '/Users/cls/miniforge3/envs/flet-test/lib/python3.10/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-six.moves.py'.
5778 INFO: Processing module hooks...
5779 INFO: Loading module hook 'hook-flet.py' from '/Users/cls/miniforge3/envs/flet-test/lib/python3.10/site-packages/flet/__pyinstaller'...
Unable to find "/Users/cls/miniforge3/envs/flet-test/lib/python3.10/site-packages/flet/bin" when adding binary and data files.

This is the full app:


import flet

from flet import icons

def main(page: flet.Page):
    page.title = "Counter"
    page.vertical_alignment = "center"

    text_field = flet.TextField(
        value=0,
        width=100,
        text_align="right",
    )

    def minus_clicked(event):
        text_field.value = int(text_field.value) - 1
        page.update()

    def plus_clicked(event):
        text_field.value = int(text_field.value) + 1
        page.update()

    page.add(
        flet.Row(
            [
                flet.Text("Counter"),
                flet.IconButton(
                    icons.REMOVE,
                    on_click=minus_clicked,
                ),
                text_field,
                flet.IconButton(
                    icons.ADD,
                    on_click=plus_clicked,
                )
            ],
            alignment="center",
        )
    )

flet.app(
    target=main,
)
FeodorFitsner commented 2 years ago

What OS is that?

clstaudt commented 2 years ago

@FeodorFitsner macOS as mentioned in the title.

Specifically macOS 12.5.1, and Python is 3.10, managed by https://github.com/conda-forge/miniforge

FeodorFitsner commented 2 years ago

OK, thanks. I'm yet to become familiar with conda. How did you install flet module? Do you have /Users/cls/miniforge3/envs/flet-test/lib/python3.10/site-packages/flet/bin folder?

clstaudt commented 2 years ago

@FeodorFitsner I installed flet with >conda install flet. The bin folder is not there.

clstaudt commented 2 years ago

I just tried installing flet with pip: There the error does not appear.

(On Apple Silicon however, installing binaries with pip is still often unrealiable, so using miniforge is quite common)

FeodorFitsner commented 2 years ago

That could mean conda prefered/downloaded source distribution instead of a wheel. When you install flet with pip on macOS it pulls either flet-0.1.51-py3-none-macosx_12_0_arm64.whl or flet-0.1.51-py3-none-macosx_10_14_x86_64.whl: https://pypi.org/project/flet/#files

Do you have an idea why conda skips a platform-specific wheel?

clstaudt commented 2 years ago

Do you have an idea why conda skips a platform-specific wheel?

I don't know enough about packaging to have an idea about that.

Testing the pip-installed flet with pyinstaller:

╰─ pyinstaller counter.py --onefile                                                                                             (flet-test-2) 
196 INFO: PyInstaller: 5.3
196 INFO: Python: 3.10.5 (conda)
218 INFO: Platform: macOS-12.5.1-arm64-i386-64bit
219 INFO: wrote /Users/cls/Documents/Work/Projects/PrototypeFund/Dev/flet-test/counter.spec
222 INFO: UPX is not available.
223 INFO: Extending PYTHONPATH with paths
['/Users/cls/Documents/Work/Projects/PrototypeFund/Dev/flet-test']
531 INFO: checking Analysis
531 INFO: Building Analysis because Analysis-00.toc is non existent
531 INFO: Initializing module dependency graph...
533 INFO: Caching module graph hooks...
540 INFO: Analyzing base_library.zip ...
3961 INFO: Processing pre-find module path hook distutils from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks/pre_find_module_path/hook-distutils.py'.
4016 INFO: distutils: retargeting to non-venv dir '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10'
4892 INFO: Caching module dependency graph...
4987 INFO: running Analysis Analysis-00.toc
4991 INFO: Analyzing /Users/cls/Documents/Work/Projects/PrototypeFund/Dev/flet-test/counter.py
5756 INFO: Processing pre-safe import module hook six.moves from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-six.moves.py'.
6008 INFO: Processing module hooks...
6008 INFO: Loading module hook 'hook-flet.py' from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/flet/__pyinstaller'...
6010 INFO: Loading module hook 'hook-pkg_resources.py' from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks'...
6459 INFO: Processing pre-safe import module hook win32com from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/_pyinstaller_hooks_contrib/hooks/pre_safe_import_module/hook-win32com.py'.
6812 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks'...
6812 INFO: Loading module hook 'hook-lib2to3.py' from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks'...
6834 INFO: Loading module hook 'hook-_tkinter.py' from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks'...
6920 INFO: checking Tree
6920 INFO: Building Tree because Tree-00.toc is non existent
6920 INFO: Building Tree Tree-00.toc
6928 INFO: checking Tree
6928 INFO: Building Tree because Tree-01.toc is non existent
6928 INFO: Building Tree Tree-01.toc
6979 INFO: checking Tree
6980 INFO: Building Tree because Tree-02.toc is non existent
6980 INFO: Building Tree Tree-02.toc
6983 INFO: Loading module hook 'hook-encodings.py' from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks'...
7227 INFO: Loading module hook 'hook-distutils.util.py' from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks'...
7230 INFO: Loading module hook 'hook-platform.py' from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks'...
7230 INFO: Loading module hook 'hook-pickle.py' from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks'...
7232 INFO: Loading module hook 'hook-heapq.py' from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks'...
7233 INFO: Loading module hook 'hook-difflib.py' from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks'...
7234 INFO: Loading module hook 'hook-multiprocessing.util.py' from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks'...
7236 INFO: Loading module hook 'hook-sysconfig.py' from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks'...
7249 INFO: Loading module hook 'hook-xml.py' from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks'...
7282 INFO: Loading module hook 'hook-distutils.py' from '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks'...
7297 INFO: Looking for ctypes DLLs
7311 INFO: Analyzing run-time hooks ...
7313 INFO: Including run-time hook '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks/rthooks/pyi_rth_inspect.py'
7315 INFO: Including run-time hook '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks/rthooks/pyi_rth_subprocess.py'
7316 INFO: Including run-time hook '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/flet/__pyinstaller/rthooks/pyi_rth_localhost_fletd.py'
7316 INFO: Including run-time hook '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgres.py'
7320 INFO: Including run-time hook '/Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgutil.py'
7329 INFO: Looking for dynamic libraries
7700 INFO: Looking for eggs
7700 INFO: Python library not in binary dependencies. Doing additional searching...
7703 INFO: Using Python library /Users/cls/miniforge3/envs/flet-test-2/lib/libpython3.10.dylib
7706 INFO: Warnings written to /Users/cls/Documents/Work/Projects/PrototypeFund/Dev/flet-test/build/counter/warn-counter.txt
7736 INFO: Graph cross-reference written to /Users/cls/Documents/Work/Projects/PrototypeFund/Dev/flet-test/build/counter/xref-counter.html
7754 INFO: checking PYZ
7754 INFO: Building PYZ because PYZ-00.toc is non existent
7754 INFO: Building PYZ (ZlibArchive) /Users/cls/Documents/Work/Projects/PrototypeFund/Dev/flet-test/build/counter/PYZ-00.pyz
8160 INFO: Building PYZ (ZlibArchive) /Users/cls/Documents/Work/Projects/PrototypeFund/Dev/flet-test/build/counter/PYZ-00.pyz completed successfully.
8168 INFO: EXE target arch: arm64
8168 INFO: Code signing identity: None
8168 INFO: checking PKG
8168 INFO: Building PKG because PKG-00.toc is non existent
8168 INFO: Building PKG (CArchive) counter.pkg
15460 INFO: Building PKG (CArchive) counter.pkg completed successfully.
15462 INFO: Bootloader /Users/cls/miniforge3/envs/flet-test-2/lib/python3.10/site-packages/PyInstaller/bootloader/Darwin-64bit/run
15462 INFO: checking EXE
15462 INFO: Building EXE because EXE-00.toc is non existent
15462 INFO: Building EXE from EXE-00.toc
15463 INFO: Copying bootloader EXE to /Users/cls/Documents/Work/Projects/PrototypeFund/Dev/flet-test/dist/counter
15463 INFO: Converting EXE to target arch (arm64)
15494 INFO: Removing signature(s) from EXE
15522 INFO: Appending PKG archive to EXE
15554 INFO: Fixing EXE headers for code signing
15560 INFO: Rewriting the executable's macOS SDK version (12.1.0) to match the SDK version of the Python library (11.0.0) in order to avoid inconsistent behavior and potential UI issues in the frozen application.
15561 INFO: Re-signing the EXE
15924 INFO: Building EXE from EXE-00.toc completed successfully.

The resulting dist/counter binary works too.

FeodorFitsner commented 2 years ago

OK, thanks for confirming it works with pip. I might play with conda sometime later. Would you mind if I rename this issue to "Flet module does not include binaries when installed with Conda on macOS"?