briefcase: Briefcase can't install Python packages with binary modules on mobile platforms.

Describe the bug

Briefcase is able to package any an app that has a dependency that is a pure-Python package (i.e., a package that contains only Python code).

However, if you’re targeting a mobile platform (iOS or Android), and the Python module has a binary component (i.e., it contains a C module), any attempt to import that module will fail, causing the app to crash.

Desktop platforms (macOS, Windows and Linux) are not affected by this problem.

To Reproduce Steps to reproduce the behavior:

  1. Set up a hello world application
  2. Add a package with a binary dependency (e.g., numpy or pillow) to the requires list, and add an import for that code (e.g., import numpy or import pil)
  3. Deploy the app to iOS or Android
  4. Try to run the app.

Expected behavior

The import should succeed and the app should continue to run.

Environment:

  • Operating System: iOS or Android
  • Python version: Any
  • Software versions:
    • Briefcase: Any

Additional context

This isn’t purely a Briefcase issue; pip and PyPI doesn’t currently have any support for mobile platforms.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 32 (13 by maintainers)

Most upvoted comments

Is this limitation mentioned in the docs? I’ve run through the tutorials and only saw the “platform notice”. An explicit note would have saved me a good chunk of time 😞

@boxed If the binary package is available, you don’t need to do anything other than adding the package to your app’s requires list (which is what you need to do on any platform). bcrypt is definitely on that list for iOS. If you’re having problems, you’ll need to provide more details.

All the PRs needed to support binary modules on iOS and Android have now been merged, so I’m going to close this ticket. The changes will be in the next release of Briefcase (v0.3.10), due for release in the next day or two (pending final release testing)

I modified the hello world tutorial like so:

        import numpy
        label = toga.Label(
            'Hello NumPy, {}'.format(numpy.random.random()),
            style=Pack(padding=(10, 10))
        )
        main_box.add(label)

and the result:

Screenshot_20211207-101934_Hello World

Pull request incoming…

It is possible to add any library you want to the support package by forking and modifying the build process; however, we’re unlikely to include it in the official package. OpenSSL is included because it’s needed to compile the Python standard library.

The fix here isn’t to add more and more binary libraries to the support package; it’s to fix the underlying problem of binary wheels for mobile platforms.