Adding New Applications
Meco™ uses simple JSON
structure in order to provide comprehensive solutions when it comes to launching applications.
Each application, which from this point on we'll be referring them as apps, would have a dedicated JSON
file called
app file. All app files are contained and served by mMecoSettings
package, therefore we'll be using this package
to operate on apps. This approach gives you many capabilities on top of just launching apps, which you can use in your
production pipeline.
Initialize a Development Environment
For this tutorial we need two packages to be in our main development environment on the master project. These packages
are; mNukeExample
, mMecoSettings
. If you've installed Meco™ yourself, you would have these packages in the main
development environment since they would have been created automatically.
Create and/or initialize the master project with main
development environment with these two packages present.
You should see all two packages initialized from your main development environment in the displayed information, like so;
----------------------------------------------------------------------------------------------------
DEVELOPMENT
----------------------------------------------------------------------------------------------------
# ...
mMecoSettings > /<PATH>/meco/master/developers/<USER_NAME>/development/main/mMecoSettings
PATH : /<PATH>/meco/master/developers/<USER_NAME>/development/main/mMecoSettings/bin/darwin
PYTHONPATH : /<PATH>/meco/master/developers/<USER_NAME>/development/main/mMecoSettings/python
mNukeExample > /<PATH>/meco/master/developers/<USER_NAME>/development/main/mNukeExample
DYLD_FALLBACK_LIBRARY_PATH : /<PATH>/meco/master/developers/<USER_NAME>/development/main/mNukeExample/lib/darwin
PATH : /<PATH>/meco/master/developers/<USER_NAME>/development/main/mNukeExample/bin/darwin
PYTHONPATH : /<PATH>/meco/master/developers/<USER_NAME>/development/main/mNukeExample/python
# ...
Creating a New App File
Type the following command to create a new app file with given name, which is nuke12.03WithFont
.
mmecosettings-create-app nuke12.03WithFont
You should see a similar success message like the one below.
Meco App file has been created.
/<PATH>/meco/master/developers/<USER_NAME>/development/main/mMecoSettings/resources/apps/nuke12.03WithFont.json
Open the created file and replace the content of it with the following snippet. Please feel free to replace executable paths with the existing ones on your platform.
Please Note: I assume that you have provided existing and valid executable path(s) for the platform you are currently working on.
{
"developer": "your@emailaddress.com",
"description": "Nuke 12.0v3 with fonts",
"darwinExecutable": "open -a Nuke12.0v3.app",
"linuxExecutable": "nuke",
"windowsExecutable": "nuke.exe",
"globalEnvClassName": "Nuke",
"application": "nuke",
"folderName": "nuke",
"version": "12",
"packages": []
}
The following keys are the only accepted keys of an app file.
developer
Data Type: str
Email address of the developer who created the app file.
description
Data Type: str
Description about the app.
darwinExecutable
Data Type: str
Executable, or command that launches the app on Mac OS.
linuxExecutable
Data Type: str
Executable, or command that launches the app on Linux OS.
windowsExecutable
Data Type: str
Executable, or command that launches the app on Windows OS.
globalEnvClassName
Data Type: str
Global environment class name, which must be implemented in mMecoSettings.packageGlobalEnvLib
Python module as we'll
do.
application
Data Type: str
String representation of the application, lower case and usually one word.
folderName
Data Type: str
Name of the folder, which would be found under the packages.
version
Data Type: str
Version of the application
packages
Data Type: str
This key is not used in this release, please ignore it for now.
Now you can activate Meco™ on another terminal or PowerShell window and type the following command.
Please Note: App flag and its values are auto-completed as well.
# meco-init
meco -de main -a nuke12.03WithFont
Upon executing the command you can see that the environment initialized for Nuke, and Nuke itself is launched as well. The displayed information should look like the following.
# ...
----------------------------------------------------------------------------------------------------
DEVELOPMENT
----------------------------------------------------------------------------------------------------
mNukeExample > /<PATH>/meco/master/developers/<USER_NAME>/development/main/mNukeExample
PYTHONPATH : /<PATH>/meco/master/developers/<USER_NAME>/development/main/mNukeExample/python
# ...
Adding App Based Custom Environments Globally
We have mNukeExample/nuke/12/font
folder as you may have noticed, though it didn't get initialized with the environment
we've initialized above.
Imagine every Nuke
related package may have this path, and we like to initialize it every time we initialize an
environment for Nuke
. In such case we can do that globally meaning that we only have to create a global settings
for it and Meco™ handles rest of the work for us.
Open the following Python module in your editor.
/<PATH>/meco/master/developers/<USER_NAME>/development/main/mMecoSettings/python/mMecoSettings/packageGlobalEnvLib.py
This Python module contains settings, which would be applied to all packages globally. Add the following classes and save the file.
## @brief [ ENUM CLASS ] - Nuke folder structure in a package for Linux.
class NukeLinux(object):
## [ str ] - Nuke font path.
NUKE_FONT_PATH = ['FOLDER_NAME/VERSION/font']
#
## @brief [ ENUM CLASS ] - Nuke folder structure in a package for Darwin.
class NukeDarwin(NukeLinux):
pass
#
## @brief [ ENUM CLASS ] - Nuke folder structure in a package for Windows.
class NukeWindows(object):
## [ str ] - Nuke font path.
NUKE_FONT_PATH = ['FOLDER_NAME\\VERSION\\font']
Values of folderName
and version
keys of the app file will replace FOLDER_NAME
and VERSION
keywords
in the paths provided under the classes above. These paths will be initialized as NUKE_FONT_PATH
if they are exist for
each package in the environment.
Some very important points to pay attention to regarding the implementation we provided as snippet above:
-
Combination of two names would determine the name of the classes in the
mMecoSettings.packageGlobalEnvLib
module.- First part must be the class name as it appears in the app file (this is the
nuke12.03WithFont.json
file we've created previously) withglobalEnvClassName
key. - Second part is the name of the platform that starts with capital letter, either Linux, Darwin or Windows.
- These names must be concatenated without any special characters.
- First part must be the class name as it appears in the app file (this is the
-
Since Darwin (Mac OS) is Unix based OS, we can simply inherit Linux version of the setting class directly.
-
Please also note that, in Windows OS version of the settings class backward slashes are used instead of forward slashes.
Meco™ will use globalEnvClassName
value, which is Nuke
in this particular case with considering the platform name
in order to get the class you added in mMecoSettings.packageGlobalEnvLib
Python module. Once the class is obtained
by Meco™, its static members are used to get the environment variable names and their corresponding relative paths.
These paths are tested against all packages, and they get initialized for given environment variable if they exist.
Now it's time to test the changes. Activate Meco™ on another terminal or PowerShell window and type and execute the following command.
# meco-init
meco -de main -a nuke12.03WithFont
You can verify that, NUKE_FONT_PATH
is indeed initialized for mNukeExample
package by looking at the displayed
information, which would look like this.
----------------------------------------------------------------------------------------------------
DEVELOPMENT
----------------------------------------------------------------------------------------------------
# ...
mNukeCore > /<PATH>/meco/master/developers/<USER_NAME>/development/main/mNukeCore
NUKE_FONT_PATH : /<PATH>/meco/master/developers/<USER_NAME>/development/main/mNukeCore/nuke/12/font
NUKE_PATH : /<PATH>/meco/master/developers/<USER_NAME>/development/main/mNukeCore/python
PYTHONPATH : /<PATH>/meco/master/developers/<USER_NAME>/development/main/mNukeCore/python
# ...
Ignoring Application Launch
Sometimes you may want to initialize an environment as if you were launching an application while you are not. In such
cases you can use -iae
flag in order to ignore (not invoke) the application executable itself. Let's type and execute
the following command on a new terminal or PowerShell window.
meco -de main -a nuke12.03WithFont -iae
As you can see in the displayed information, NUKE_FONT_PATH
environment variable is initialized as if we launched the
application. However, you can also see in ENV section that, the application executable is ignored. So we initialized
the environment for Nuke, but we just did not launch the application itself.
----------------------------------------------------------------------------------------------------
DEVELOPMENT
----------------------------------------------------------------------------------------------------
# ...
mNukeCore > /<PATH>/meco/master/developers/<USER_NAME>/development/main/mNukeCore
NUKE_FONT_PATH : /<PATH>/meco/master/developers/<USER_NAME>/development/main/mNukeCore/nuke/12/font
NUKE_PATH : /<PATH>/meco/master/developers/<USER_NAME>/development/main/mNukeCore/python
PYTHONPATH : /<PATH>/meco/master/developers/<USER_NAME>/development/main/mNukeCore/python
# ...
----------------------------------------------------------------------------------------------------
ENV
----------------------------------------------------------------------------------------------------
App File : /<PATH>/meco/master/developers/<USER_NAME>/development/main/mMecoSettings/resources/apps/nuke12.03WithFont.json
Description : Nuke 12.0v3 with fonts (App executable is ignored)
Global Env Class Name : Nuke
Application : nuke
Folder Name : nuke
Version : 12
# ...
However, if you want to launch the application directly by using its executable from this point forward you can also do it since the environment itself is initialized for the application. All the relevant environment variables will be used by the application in such case as well.