beeware / Python-Apple-support

A meta-package for building a version of Python that can be embedded into a macOS, iOS, tvOS or watchOS project.
MIT License
1.11k stars 160 forks source link

Include module when packaging beeware using briefcase for MacOS #121

Closed hoffenmerCode closed 3 years ago

hoffenmerCode commented 3 years ago

Newbie using briefcase and loving it. I have a simply code that includes a twilio module in my python code (import twilio) in my main app. When I dev or run the app on my mac = works. When I package it using briefcase with --no-sign, the dmg app never opens on my mac. When I remove the (import twilio) from the code and update and repackage, then it works again.

Why? What am I missing? Please help. I don't want to go back to pyQt :)

freakboy3742 commented 3 years ago

The most likely culprit I can think of would be missing dependencies.

When you added the twilio libraries, you've clearly done a pip install twilio - but did you also add twilio to the requires list in briefcase.toml? Briefcase builds a completely isolated environment for packaged apps, so you need to explicitly declare any dependencies so it knows what to put into that environment.

Once you've done that and re-packaged the app, the dependency will be included (you should see it being installed as part of the packaging process) - with any luck, the app will then start the same as it does in dev mode.

hoffenmerCode commented 3 years ago

The most likely culprit I can think of would be missing dependencies.

When you added the twilio libraries, you've clearly done a pip install twilio - but did you also add twilio to the requires list in briefcase.toml? Briefcase builds a completely isolated environment for packaged apps, so you need to explicitly declare any dependencies so it knows what to put into that environment.

Once you've done that and re-packaged the app, the dependency will be included (you should see it being installed as part of the packaging process) - with any luck, the app will then start the same as it does in dev mode.

Perfect. Worked. Thank you!