'How to include Variables file that is part of an installed pip package

I'm currently having trouble including a Robot Framework "Variables" file that is contained within a python pip package. I can successfully include files in this package as a "Library", but not "Variables". The reason I have variables stored in a pip package is that this package is privately maintained and is used across a variety of projects.

Example contents of the file with both variables and functions that I need to access from Robot Framework: "package_file.py"


VARIABLE_ABC = "important constant here"


def my_function(arg1, arg2)
    return 0

I can create a dummy file that merely imports all the variables from the package file and its path is known and consistent. I would consider this to be a workaround and not the ideal solution:

"my_variables_file_copy.py"

from my_module.package_file import *

See the example syntax from one of my .robot files below for a better explanation of what is going on:

*** Settings ***
Documentation    Description of this file

# This brings in functions, but not variables
Library          my_module.package_file

# This doesn't work
Variables        my_module.package_file

# This does work, but is not ideal
Variables        my_variables_file_copy.py

# This would also work but is not ideal and could be change depending on the installation
Variables         path/to/installed/pip/package/my_module/package_file.py

Any advice on how to handle this situation?



Solution 1:[1]

Support for this has recently been added in Robot Framework 5.0

https://github.com/robotframework/robotframework/blob/master/doc/releasenotes/rf-5.0.rst#variable-files-can-be-imported-as-modules

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 notoriousjere