briefcase
Tools to support converting a Python project into a standalone native application.
Top Related Projects
Freeze (package) Python programs into stand-alone executables
Generic Python packager for Android and iOS
Install and Run Python Applications in Isolated Environments
Nuitka is a Python compiler written in Python. It's fully compatible with Python 2.6, 2.7, 3.4-3.13. You feed it your Python app, it does a lot of clever things, and spits out an executable or extension module.
Quick Overview
Briefcase is a tool for converting Python projects into standalone native applications for various platforms, including Windows, macOS, Linux, iOS, Android, and the web. It simplifies the process of packaging and distributing Python applications by handling the complexities of creating native installers and app bundles.
Pros
- Supports multiple platforms and packaging formats
- Simplifies the process of creating native applications from Python code
- Integrates well with the BeeWare suite of tools for cross-platform development
- Provides a consistent interface for building and packaging across different platforms
Cons
- May have limitations for complex applications with specific native dependencies
- Learning curve for developers new to cross-platform packaging
- Some platforms may require additional setup or developer accounts (e.g., iOS development)
- Generated apps may be larger in size compared to manually optimized native applications
Code Examples
- Creating a new Briefcase project:
from briefcase.bootstraps import NewProject
project = NewProject(
formal_name="My App",
app_name="myapp",
bundle="com.example",
version="0.0.1",
description="A sample Briefcase app",
author="Jane Developer",
author_email="jane@example.com",
)
project.generate()
- Building an application for a specific platform:
from briefcase.platforms.windows import Windows
windows = Windows()
windows.build(app="myapp")
- Running the application:
from briefcase.platforms.windows import Windows
windows = Windows()
windows.run(app="myapp")
Getting Started
To get started with Briefcase, follow these steps:
- Install Briefcase:
pip install briefcase
- Create a new project:
briefcase new
- Build the application for your desired platform:
briefcase create
briefcase build
- Run the application:
briefcase run
For more detailed instructions and options, refer to the official Briefcase documentation.
Competitor Comparisons
Freeze (package) Python programs into stand-alone executables
Pros of PyInstaller
- Widely used and mature project with extensive documentation
- Supports a broader range of Python versions and operating systems
- Generally faster build times for simple applications
Cons of PyInstaller
- Limited support for mobile platforms (iOS, Android)
- Can be more complex to configure for advanced use cases
- May require manual tweaking of spec files for certain dependencies
Code Comparison
PyInstaller:
# PyInstaller command line usage
pyinstaller --onefile --windowed myapp.py
Briefcase:
# Briefcase command line usage
briefcase new
briefcase create
briefcase run
Key Differences
- Briefcase focuses on cross-platform deployment, including mobile, while PyInstaller primarily targets desktop platforms
- Briefcase provides a more streamlined experience for packaging Python apps as native applications
- PyInstaller creates standalone executables, while Briefcase generates platform-specific app bundles
Use Cases
- Choose PyInstaller for quick deployment of desktop applications or scripts
- Opt for Briefcase when developing cross-platform apps, especially if targeting mobile platforms
Generic Python packager for Android and iOS
Pros of Buildozer
- Specifically designed for Kivy applications, offering seamless integration
- Supports a wider range of mobile platforms, including iOS, Android, and desktop
- Has a more mature ecosystem with extensive documentation and community support
Cons of Buildozer
- Limited to Kivy-based applications, less flexible for other Python frameworks
- Can be more complex to set up and configure for beginners
- May require more manual intervention for advanced customization
Code Comparison
Briefcase configuration (pyproject.toml):
[tool.briefcase.app.myapp]
formal_name = "My App"
description = "My amazing app"
sources = ["myapp"]
requires = ["toga==0.3.0"]
Buildozer configuration (buildozer.spec):
[app]
title = My App
package.name = myapp
requirements = kivy
source.dir = .
Both tools aim to simplify the process of packaging Python applications for various platforms, but they cater to different ecosystems. Briefcase is more versatile and supports a wider range of Python frameworks, while Buildozer is tailored specifically for Kivy applications. The choice between the two depends on the specific needs of your project and your familiarity with the respective ecosystems.
Install and Run Python Applications in Isolated Environments
Pros of pipx
- Simpler installation process for end-users
- Focuses on installing and running Python applications in isolated environments
- Lightweight and fast, with minimal dependencies
Cons of pipx
- Limited to Python applications only
- Doesn't provide native packaging or GUI support
- Less suitable for complex applications with multiple dependencies
Code Comparison
pipx:
pipx install your_app
pipx run your_app
Briefcase:
briefcase new
briefcase dev
briefcase build
briefcase run
Summary
pipx is a lightweight tool for installing and running Python applications in isolated environments, making it easy for end-users to manage Python-based command-line tools. It's simpler to use but has limitations in terms of application complexity and platform support.
Briefcase, on the other hand, is a more comprehensive tool for packaging Python applications as standalone executables for various platforms, including desktop and mobile. It supports GUI applications and provides a more robust development workflow, but may have a steeper learning curve for both developers and end-users.
Choose pipx for simple Python CLI tools, and Briefcase for more complex, cross-platform applications with GUI support.
Nuitka is a Python compiler written in Python. It's fully compatible with Python 2.6, 2.7, 3.4-3.13. You feed it your Python app, it does a lot of clever things, and spits out an executable or extension module.
Pros of Nuitka
- Compiles Python code to standalone executables, potentially improving performance
- Supports a wide range of Python versions and libraries
- Can create smaller executables compared to some alternatives
Cons of Nuitka
- Steeper learning curve for configuration and optimization
- May require additional setup for certain dependencies or modules
- Less focus on cross-platform mobile app development
Code Comparison
Briefcase example:
from briefcase.app import App
class MyApp(App):
formal_name = "My App"
description = "A sample Briefcase app"
def main(self):
print("Hello, World!")
Nuitka example:
# main.py
print("Hello, World!")
# Command to compile:
# python -m nuitka --standalone main.py
Briefcase focuses on creating native applications with a more structured approach, while Nuitka aims to compile Python scripts directly into executables. Briefcase provides a higher-level abstraction for app development, especially for cross-platform and mobile applications. Nuitka, on the other hand, offers more fine-grained control over the compilation process and is primarily used for creating standalone executables from Python scripts.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
.. |logo| image:: https://beeware.org/project/briefcase/briefcase.png :width: 72px :target: https://beeware.org/briefcase
.. |pyversions| image:: https://img.shields.io/pypi/pyversions/briefcase.svg :target: https://pypi.python.org/pypi/briefcase :alt: Python Versions
.. |version| image:: https://img.shields.io/pypi/v/briefcase.svg :target: https://pypi.python.org/pypi/briefcase :alt: PyPI Version
.. |maturity| image:: https://img.shields.io/pypi/status/briefcase.svg :target: https://pypi.python.org/pypi/briefcase :alt: Maturity
.. |license| image:: https://img.shields.io/pypi/l/briefcase.svg :target: https://github.com/beeware/briefcase/blob/main/LICENSE :alt: BSD License
.. |ci| image:: https://github.com/beeware/briefcase/workflows/CI/badge.svg?branch=main :target: https://github.com/beeware/briefcase/actions :alt: Build Status
.. |social| image:: https://img.shields.io/discord/836455665257021440?label=Discord%20Chat&logo=discord&style=plastic :target: https://beeware.org/bee/chat/ :alt: Discord server
|logo|
Briefcase
|pyversions| |version| |maturity| |license| |ci| |social|
Briefcase is a tool for converting a Python project into a standalone native application. You can package projects for:
- Mac
- Windows
- Linux
- iPhone/iPad
- Android
- Web
Support for AppleTV, watchOS, and wearOS deployments is planned.
Getting started
To install Briefcase, run::
$ python -m pip install briefcase
If you would like a full introduction to using Briefcase, try the BeeWare tutorial <https://docs.beeware.org>
__. This tutorial walks you through the process of creating
and packaging a new application with Briefcase.
Financial support
The BeeWare project would not be possible without the generous support of our financial members:
.. image:: https://beeware.org/community/members/anaconda/anaconda-large.png :target: https://anaconda.com/ :alt: Anaconda logo
Anaconda Inc. - Advancing AI through open source.
Plus individual contributions from users like you <https://beeware.org/community/members/>
__. If you find Briefcase, or other BeeWare
tools useful, please consider becoming a financial member.
Documentation
Documentation for Briefcase can be found on Read The Docs <https://briefcase.readthedocs.io>
__.
Community
Briefcase is part of the BeeWare suite <https://beeware.org>
__. You can talk to the
community through:
-
@beeware@fosstodon.org on Mastodon <https://fosstodon.org/@beeware>
__ -
Discord <https://beeware.org/bee/chat/>
__ -
The Briefcase
GitHub Discussions forum <https://github.com/beeware/briefcase/discussions>
__
We foster a welcoming and respectful community as described in our BeeWare Community Code of Conduct <https://beeware.org/community/behavior/>
__.
Contributing
If you experience problems with Toga, log them on GitHub <https://github.com/beeware/briefcase/issues>
__.
If you'd like to contribute to Toga development, our contribution guide <https://briefcase.readthedocs.io/en/latest/how-to/contribute/index.html>
__
details how to set up a development environment, and other requirements we have
as part of our contribution process.
Top Related Projects
Freeze (package) Python programs into stand-alone executables
Generic Python packager for Android and iOS
Install and Run Python Applications in Isolated Environments
Nuitka is a Python compiler written in Python. It's fully compatible with Python 2.6, 2.7, 3.4-3.13. You feed it your Python app, it does a lot of clever things, and spits out an executable or extension module.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot