Packaging For Mac Os X



  1. Packaging For Mac Os X 10.10
  2. How To Update Mac Os X
  3. Chrome For Mac Os X

Table Of Contents

Whenever you need to create an installation package or distribution for Mac OS X 10.5 or later, Packages is the powerful and flexible solution you're looking for. With Packages, you can define which applications, bundles, documents or folders should be part of the payload of your installation packages and where they should be installed. Mac OS X Leopard (version 10.5) is the sixth major release of Mac OS X (now named macOS), Apple's desktop and server operating system for Macintosh computers. Leopard was released on October 26, 2007 as the successor of Mac OS X 10.4 Tiger, and is available in two editions: a desktop version suitable for personal computers, and a server version, Mac OS X Server. In the Apple macOS operating system, a package is a file system directory that is normally displayed to the user by the Finder as if it were a single file. Such a directory may be the top-level of a directory tree of objects stored as files, or it may be other archives of files or objects for various purposes, such as installer packages, or backup archives.

  • Creating packages for OS X
    • Using PyInstaller and Homebrew
      • Additional Libraries
    • Using the Kivy SDK
      • To include other frameworks

Note

This guide describes multiple ways for packaging Kivy applications.Packaging with PyInstaller is recommended for general use.

Using PyInstaller and Homebrew¶

Note

Package your app on the oldest OS X version you want to support.

Complete guide¶

  1. Install Homebrew

  2. Install Python:

    Note

    To use Python 3, brewinstallpython3 and replace pip withpip3 in the guide below.

  3. (Re)install your dependencies with --build-bottle to make sure they canbe used on other machines:

    Note

    If your project depends on GStreamer or other additional libraries(re)install them with --build-bottle as describedbelow.

  4. Install Cython and Kivy:

  5. Install PyInstaller:

  6. Package your app using the path to your main.py:

    Note

    This will not yet copy additional image or sound files. You would need toadapt the created .spec file for that.

Editing the spec file¶

The specs file is named touchtracer.spec and is located in the directorywhere you ran the pyinstaller command.

You need to change the COLLECT() call to add the data of touchtracer(touchtracer.kv, particle.png, …). Change the line to add a Tree()object. This Tree will search and add every file found in the touchtracerdirectory to your final package. Your COLLECT section should look somethinglike this:

This will add the required hooks so that PyInstaller gets the required Kivyfiles. We are done. Your spec is ready to be executed.

Build the spec and create a DMG¶

  1. Open a console.

  2. Go to the PyInstaller directory, and build the spec:

  3. Run:

  4. You will now have a Touchtracer.dmg available in the dist directory.

Additional Libraries¶

GStreamer¶

If your project depends on GStreamer:

Note

If your Project needs Ogg Vorbis support be sure to add the--with-libvorbis option to the command above.

If you are using Python from Homebrew you will also need the following stepuntil this pull requestgets merged:

Packaging For Mac Os X 10.10

Using PyInstaller without Homebrew¶

First install Kivy and its dependencies without using Homebrew as mentioned herehttp://kivy.org/docs/installation/installation.html#development-version.

Once you have kivy and its deps installed, you need to install PyInstaller.

Let’s assume we use a folder like testpackaging:

Create a file named touchtracer.spec in this directory and add the followingcode to it:

Change the paths with your relevant paths:

Then run the following command:

Replace touchtracer with your app where appropriate.This will give you a <yourapp>.app in the dist/ folder.

Using Buildozer¶

pip install git+http://github.com/kivy/buildozercd /to/where/I/Want/to/packagebuildozer init

Note

Packaging Kivy applications with the following method must be done insideOS X, 32-bit platforms are no longer supported.

Edit the buildozer.spec and add the details for your app.Dependencies can be added to the requirements= section.

By default the kivy version specified in the requirements is ignored.

If you have a Kivy.app at /Applications/Kivy.app then that is used,for packaging. Otherwise the latest build from kivy.org using Kivymaster will be downloaded and used.

If you want to package for python 3.x.x simply download the packagenamed Kivy3.7z from the download section of kivy.org and extract itto Kivy.app in /Applications, then run:

How To Update Mac Os X

Once the app is packaged, you might want to remove unneededpackages like gstreamer, if you don’t need video support.Same logic applies for other things you do not use, just reducethe package to its minimal state that is needed for the app to run.

As an example we are including the showcase example packaged usingthis method for both Python 2 (9.xMB) and 3 (15.xMB), you can find thepackages here:https://drive.google.com/drive/folders/0B1WO07-OL50_alFzSXJUajBFdnc .

That’s it. Enjoy!

Buildozer right now uses the Kivy SDK to package your app.If you want to control more details about your app than buildozercurrently offers then you can use the SDK directly, as detailed in thesection below.

Using the Kivy SDK¶

Note

Kivy.app is not available for download at the moment. For details,see this issue.

Note

Packaging Kivy applications with the following method must be done insideOS X, 32-bit platforms are no longer supported.

Since version 1.9.0, Kivy is released for the OS X platform in aself-contained, portable distribution.

Apps can be packaged and distributed with the Kivy SDK using the methoddescribed below, making it easier to include frameworks like SDL2 andGStreamer.

  1. Make sure you have the unmodified Kivy SDK (Kivy.app) from the download page.

  2. Run the following commands:

Note

This step above is important, you have to make sure to preserve the pathsand permissions. A command like cp-rf will copy but make the appunusable and lead to error later on.

  1. Now all you need to do is to include your compiled app in the Kivy.appby running the following command:

Where <app_folder_name> is the name of your app.

This copies Kivy.app to <app_folder_name>.app and includes a compiled copyof your app into this package.

  1. That’s it, your self-contained package is ready to be deployed!You can now further customize your app as described bellow.

Installing modules¶

Kivy package on osx uses its own virtual env that is activated when you runyour app using kivy command.To install any module you need to install the module like so:

Where are the modules/files installed?¶

Inside the portable venv within the app at:

Chrome for mac os x

If you install a module that installs a binary for example like kivy-gardenThat binary will be only available from the venv above, as in after you do:

Packaging For Mac Os X

Chrome For Mac Os X

The garden lib will be only available when you activate this env.

source /Applications/Kivy.app/Contents/Resources/venv/bin/activategarden install mapviewdeactivate

To install binary files¶

Just copy the binary to the Kivy.app/Contents/Resources/venv/bin/ directory.

To include other frameworks¶

Kivy.app comes with SDL2 and Gstreamer frameworks provided.To include frameworks other than the ones provided do the following:

Do not forget to replace <Framework_name> with your framework.This tool osxrelocator essentially changes the path for thelibs in the framework such that they are relative to the executablewithin the .app, making the Framework portable with the .app.

Shrinking the app size¶

The app has a considerable size right now, however the unneeded parts can beremoved from the package.

For example if you don’t use GStreamer, simply remove it fromYourApp.app/Contents/Frameworks.Similarly you can remove the examples folder from/Applications/Kivy.app/Contents/Resources/kivy/examples/ or kivy/tools,kivy/docs etc.

This way the package can be made to only include the parts that are needed foryour app.

Adjust settings¶

Icons and other settings of your app can be changed by editingYourApp/Contents/info.plist to suit your needs.

Create a DMG¶

To make a DMG of your app use the following command:

Note the lack of / at the end.This should give you a compressed dmg that will further shrink the size of yourdistributed app.

« Kivy on AndroidCreate a package for IOS »