Skip to content

Scripts

This guide explains how to import bip safely from your own code.

There are three scenarii:

  • Development: If you want to call the bip package from a script that is not ran by Bip itself (that would be from the Brioche application for instance) and where the environment is not set up, you must set it manually. Typically, when developing for Bip, outside a Bip client installation, you would need to specify those environment variables.
  • Production (internal to Bip runtime): On the contrary, if your code is to be called by Bip (indirectly or not), there is nothing to do, importing bip will work out-of-the-box. For example, if your script is called from a Maya that has been launched with Bip, the environment is already set up.
  • Production (external to Bip runtime): Alternatively, if you are attempting to import bip from a non-Bip runtime, but there is an existing Bip client installation on your machine, the import would work, and the bip package would be initialized with the default values of the paths to the config and auth files, or the database password saved in the keyring.

Since Bip looks for certain configuration files and data stored in keyring at initialization, those configuration data must be explicitly provided through environment variables, unless it is a choice to have the default values and locations to be used (in the case of an existing Bip installation on the machine).

Tip

For more information about environment variables, check this documentation.

In any scenario, you must be aware that any variable that is not overriden results in its default value being used. If that default value is valid (in case of an existing parallel client installation), it could for example lead to executing code to the wrong database, and therefore compromising its integrity. Make sure you keep your development and production environments completely independent.

Info

If your script is using mink.update, you might also want to override BIP_PYTHON_HOST, BIP_COMPATIBILITY_VERSION, BIP_CHECK_UPDATES, BIP_REFRESH_CONTENT and BIP_DEBUG_UPDATE_TARGET.

Development

Warning

This documentation assumes that you have already set up a Bip development instance, and that your development directories are following the recommended structure.

When running your script, specify the following environment variables:

  • BIP_CONFIG: Bip configuration file (example: /path/to/bip/config/config.yml)
  • BIP_AUTH: Bip authentication file (example: /path/to/bip/config/auth.yml)
  • BIP_DATABASE_PASSWORD: Neo4j password (example: your-database-password)
  • BIP_CONTENT: Bip content repository (example: /path/to/bip/content)

If your development machine has a production Bip client installed, you must also override the following environment variables, in order to avoid conflicting with the production instance:

  • BIP_PATH: Root of the Bip ecosystem (example: path/to/the/parent/folder/of/your/bip/repo)
  • BIP_PYTHON: Python virtual environment (example: path/to/the/root/of/the/python_venv)

If you are working in a hosted context, you must also specify the path to the Hosted Python venv:

  • BIP_PYTHON_HOST: Host Python venv (example: C:\Users\corentin\Documents\Code\.venvs\host)

Production (Bip runtime)

Nothing to do. If running a script from a Python interpreter that has been launched through Bip, all the configuration is already set.

Production (external)

If you want to import Bip from an existing installation, you have to add to your PYTHONPATH or sys.path the /path/to/your/Blink/bip installation. It is usually in %USERPROFILE%/Blink/bip.

Make sure your Python interpreter has all the dependencies required from /path/to/your/bip/client/requirements.txt.

There is no environment variable to specify since the default values will be used.