Using Configuration

The Wiz configuration is fully customizable via TOML configuration files and plugins.

The following configuration file is used by default:

[registry]
paths=[]

[environ]
initial={}
passthrough=[]

[resolver]
maximum_combinations=10
maximum_attempts=15

[command]
max_content_width=90
verbosity="info"
no_local=false
no_cwd=false
ignore_implicit=false

[command.list.package]
all=false
no_arch=false

[command.list.command]
all=false
no_arch=false

[command.search]
all=false
no_arch=false
type="all"

[command.view]
json_view=false

[command.freeze]
format="wiz"

[command.install]
overwrite=false

[command.edit]
overwrite=false

[command.analyze]
no_arch=false
verbose=false

It is possible to overwrite, extend or add keywords to this configuration by adding a personal configuration file in ~/.wiz/config.toml. The default configuration will always be loaded first, followed by the personal configuration.

Important

The default configuration will be recursively updated by the personal configuration.

You can fetch the configuration via the Python API with wiz.config.fetch():

>>> wiz.config.fetch()

Let’s go through a few usage examples.

Registry paths

In Getting Started, we used the wiz -r option to indicate the registry path to use:

>>> wiz -r /tmp/registry list package

Registries
-----------------
[0] /tmp/registry

...

Instead of having to constantly set the registry path in the command line, we will add the following configuration in ~/.wiz/config.toml:

[registry]
paths=["/tmp/registry"]

It is now possible to run the same command without indicating the registry path:

>>> wiz list package

Registries
-----------------
[0] /tmp/registry

...

Hint

It is highly recommended to define custom registry paths when installing the package instead of defining it for each user as it can be error prone.

Initial environment

The resolved environment will not take any external environment variables into account as the goal is to create a deterministic environment. However, it is sometimes required to access external environment variables for an application to execute properly.

We can define a list of environment variables which should always get transferred to a resolved environment by adding the following configuration in ~/.wiz/config.toml:

[environ]
passthrough=["ENVIRON_TEST1"]

Using the “python” definition created in a previous example, we can ensure that this variable is properly transferred to the resolved environment:

>>> export ENVIRON_TEST1=1
>>> export ENVIRON_TEST2=1
>>> wiz -r /tmp/registry use python
info: Spawn shell: /bin/bash

>>> echo $ENVIRON_TEST1
1
>>> echo $ENVIRON_TEST2 // Empty

It is also possible to define initial environment variables by modifying the configuration file as follows:

[environ]
initial={ENVIRON_TEST3 = "VALUE"}
passthrough=["ENVIRON_TEST1"]

Ensure that it is properly propagated to the resolved environment:

>>> wiz -r /tmp/registry use python
info: Spawn shell: /bin/bash

>>> echo $ENVIRON_TEST3
VALUE

Hint

If you are defining a lot of initial environment variables in the configuration, using TOML’s inline table will become cumbersome and you will probably prefer this notation:

[environ.initial]
ENVIRON_TEST1=VALUE1
ENVIRON_TEST2=VALUE2
ENVIRON_TEST3=VALUE3
ENVIRON_TEST4=VALUE4

See here how to initialize environment variables using plugins.

Warning

Initial variables will get overwritten or extended by the resolved environment if a package definition is defining the same environment variables.

Hint

It is highly recommended to define initial environment variables when installing the package instead of defining it for each user as it can be error prone.

Customize Logging

By default, wiz.logging.DEFAULT_CONFIG will be used to initialize the Python logging for the command line tool with two handlers:

  • The ‘console’ handler is a StreamHandler instance which handles terminal output. It is using ColoredFormatter to display messages with a color corresponding to the level used.
  • The ‘file’ handler is a RotatingFileHandler instance which saves detailed logs on the disk for each user.

The configuration can be used to modify these handlers, or add new ones. For instance, the following configuration will disable the ‘file’ handler and add a timestamp to each messages displayed via the ‘console’ handler:

[logging.root]
handlers=["console"]

[logging.formatters.standard]
format="%(asctime)s - %(message)s"

Note

Logging configuration should adhere to the Configuration dictionary schema.