项目作者: NiklasRosenstein

项目描述 :
A cross-platform installer for Cinema 4D plugins based on Python 3, PyQt5 and PyInstaller
高级语言: Python
项目地址: git://github.com/NiklasRosenstein/c4d-plugin-installer.git
创建时间: 2016-12-06T14:33:28Z
项目社区:https://github.com/NiklasRosenstein/c4d-plugin-installer

开源协议:GNU General Public License v3.0

下载


Customisable Cinema 4D Plugin Installer











Easily create an installer for your Cinema 4D plugin for Windows and Mac OS.
Replace the banner and icon, update some configuration, build & done.

Check out the Milestones page for what’s still to do.

Features

  • Very customisable
  • Automatically finds available Cinema 4D installations on the system
  • Supports installing dependencies from redistributable installers
  • Optional Uninstaller

Requirements

  • CPython 3.3 or 3.4 (3.5 not supported by PyInstaller)
  • PyInstaller 3.3*
  • PyQt5**
  • GNU Make***

* At the time of this writing (2016-12-06), PyInstaller 3.3 is not released
and must be installed from the development branch using
pip install git+https://github.com/pyinstaller/pyinstaller

** On Windows, it is highly recommended to use an official PyQt5 installer
from Riverbank Software rather than
installing it with Pip as it can lead to issues with finding all dependencies
when building the installer. The official installers can be found on
SourceForge.

Also note that the installer is known to put the development tools into
the wrong directory. If pyuic5 can not be found, copy it from
YourPythonInstall/Libs/site-packages/PyQt5/pyuic5.bat to the
YourPythonInstall/Scripts folder.

*** Windows builds of GNU Make can be found here.
The Makefile is known to work with GNU Make 3.8.1

Configuration & Customisation

The main configuration file is data/config.json. There
you need to specify the following information:

  • Basic installer info, like the generated executable/bundle name and the
    OSX bundle identifier.
  • Features that will be displayed in the “Features” page of the installer.
    Note that if no features are configured, the page will not be displayed.
  • The files that need to be copied for each feature and where they need to
    be copied to.

Text

The strings that are displayed in the dialog are defined in
data/strings/en.json. In every string you can use variables in the format
$varname or ${varname}. These variables are defined in the "__vars__"
section of the same string file.

Colors

In data/config.json you can find a "palette" field which describes the
colors of window components as RGB values.

  1. "palette": {
  2. "background": [40, 40, 40],
  3. "foreground": [200, 200, 200],
  4. "alternate_background": [70, 70, 70],
  5. "button_background": [50, 50, 50],
  6. "button_foreground": [220, 220, 220],
  7. "button_disabled_background": [70, 70, 70],
  8. "button_disabled_foreground": [160, 160, 160]
  9. }

Feature Configuration

Note that these variables are also supported in the "features" object
in data/config.json. The demo configuration contains the following feature
declaration:

  1. "features": {
  2. "!plugin": "$plugin",
  3. "docs": "$documentation",
  4. "presets": "$presets"
  5. }

On the left side you can see the identifiers. These identifiers are used
in the "install" section. On the right side are the names of the features
that are displayed in the installer. In the example above, they reference
variables in the string file. The ! prefix makes the feature always enabled
and prevents the user from turning it of (used for the “main” feature that
is always required).

Install Configuration

Files that are to be installed should be placed into the data/install
directory. By default, there’s a sample Python plugin, a material preview
preset and a plugin documentation file (respective to the default features).

The "install" section lists which files or directoriees are to be copied
where in the Cinema 4D application directory. Available variables:

  • $src for the data/install directory
  • $c4d for the C4D target installation directory (note that theoretically
    this could also be an arbitrary directory, depending on what the user
    chose as target installation path)
  • $systemappdir for the system application folder, this is either C:\Program Files
    on Windows or /Applications on Mac OS. Some plugins might need to install
    stuff there.
  1. "install": {
  2. "slowdown": 0.5,
  3. "copyfiles": {
  4. "plugin": {
  5. "$src/plugin/": "$c4d/plugins/C4DInstaller_ExamplePlugin/"
  6. },
  7. "docs": {
  8. "$src/doc/": "$c4d/plugins/C4DInstaller_ExamplePlugin/doc/"
  9. },
  10. "presets": {
  11. "$src/library/": "$c4d/library/"
  12. }
  13. },
  14. "dependencies": [
  15. ]
  16. }

For testing purposes, you may choose a number in seconds for "slowdown".
This is the time that will be waited after each update to the installation
progress to slow down and make it easier to track what’s happening.

The "dependencies" section is used to specify additional installers that
need to be installed for the plugin to function. Variable substition is
supported in the "name", "file" and "args" fields. The fields
"returncode", "args" and "features" are optional. Valid values for
"platform" are "windows" and "osx". Example:

In the "features" field, you must list the IDs of the features that cause
this dependency to be installed. In the example below, the dependency will
only be installed if the plugin feature is selected to be installed by the
user.

  1. "dependencies": [
  2. {
  3. "name": "MSVC++ 2015 Redistributable (x64) - 14.0.23026",
  4. "platform": "windows",
  5. "features": ["plugin"],
  6. "file": "$src/redist/windows/vc_redist-2015-14.0.23026-x64.exe",
  7. "args": ["/install"],
  8. "returncodes": [0, 1638]
  9. }
  10. ]

Uninstaller

The default configuration for the uninstaller is this:

  1. "uninstaller": {
  2. "enabled": true,
  3. "target_directory": "$c4d/plugins/C4DInstaller_ExamplePlugin/",
  4. "name": "uninstall",
  5. "bundle_identifier": "com.niklasrosenstein.c4dinstaller_uninstaller"
  6. },

You can choose to disable the uninstaller. The uninstaller will be placed
into the directory you specify with "target_directory". In the same directory
a file will be created called ${name}.data which contains all the names of
the files that have been installed, so that the installer knows what to
uninstall.

EULA

The EULA can be in data/eula.txt and should be updated before building the
installer. If you don’t want to display an EULA, you can delete the file
entirely.

Summary

To summarise, these are the steps to configure the installer:

  1. Change the installer and bundle name in data/config.json
  2. Add or remove features from the "features" section in data/config.json
  3. Add the files to be installed to data/install and update the "install"
    section in data/config.json
  4. Update the strings in data/strings/en.json
  5. Test and build the installer

Testing

In order to run the installer or uninstaller for testing purposes, use

  1. make run-installer
  2. make run-uninstaller

The Makefile supports a PYTHON environment version, so if python is not
the program where all of the dependencies are installed, you should use this
variable to point to the correct program, eg. PYTHON=py -3.4 or
PYTHON=python3.

Building the Installer

It is important to build the uninstaller before the installer.

  1. make uninstaller
  2. make installer

Installer admin privileges

On Windows, the installer is built with UAC enabled. Note that there is
currently nothing implemented to have make run-installer run as administrator.

On Mac OS, the /usr/bin/osascript workaround is used to ask the user for
elevated privileges and then execute the installer in that environment.


Copyright © 2016 – Niklas Rosenstein