Runtime

This code is run when initializing the python interperter in a Relenv environment.

  • Point Relenv’s Openssl to the system installed Openssl certificate path

  • Make sure pip creates scripts with a shebang that points to the correct python using a relative path.

  • On linux, provide pip with the proper location of the Relenv toolchain gcc. This ensures when using pip any c dependencies are compiled against the proper glibc version.

class relenv.runtime.RelenvImporter(wrappers=None, _loads=None)

Handle runtime wrapping of module methods.

create_module(spec)

Create the module via a spec.

exec_module(module)

Exec module noop.

find_module(module_name, package_path=None)

Find modules being imported.

find_spec(module_name, package_path=None, target=None)

Find modules being imported.

load_module(name)

Load an imported module.

class relenv.runtime.TARGET

Container for global pip target state.

class relenv.runtime.Wrapper(module, wrapper, matcher='equals', _loading=False)

Wrap methods of an imported module.

matches(module)

Check if wrapper metches module being imported.

relenv.runtime.bootstrap()

Bootstrap the relenv environment.

relenv.runtime.buildenv()

Late import relenv buildenv.

relenv.runtime.common()

Late import relenv common.

relenv.runtime.debug(string)

Prints the provided message if RELENV_DEBUG is truthy in the environment.

Parameters:

string (str) – The message to print

relenv.runtime.finalize_options_wrapper(func)

Wrapper around build_ext.finalize_options.

Used to add the relenv environment’s include path.

relenv.runtime.get_config_var_wrapper(func)

Return a wrapper to resolve paths relative to the relenv root.

relenv.runtime.get_config_vars_wrapper(func, mod)

Return a wrapper to resolve paths relative to the relenv root.

relenv.runtime.get_major_version()

Current python major version.

relenv.runtime.get_paths_wrapper(func, default_scheme)

Return a wrapper to resolve paths relative to the relenv root.

relenv.runtime.install_cargo_config()

Setup cargo config.

relenv.runtime.install_legacy_wrapper(func)

Wrap pip’s legacy install function.

This method determines any newly installed files and checks their RPATHs.

relenv.runtime.install_wheel_wrapper(func)

Wrap pip’s wheel install function.

This method determines any newly installed files and checks their RPATHs.

relenv.runtime.load_openssl_provider(name)

Load an openssl module.

relenv.runtime.path_import(name, path)

Import module from a path.

This causes hashlib to be imported because of importing importlib.util so it can not be used until after openssl has been configured.

relenv.runtime.pushd(new_dir)

Changedir context.

relenv.runtime.relenv_root()

Return the relenv module root.

relenv.runtime.relocate()

Late import relenv relocate.

relenv.runtime.set_env_if_not_set(name, value)

Set an environment variable if not already set.

If the environment variable is already set and not equal to value, warn the user.

relenv.runtime.set_openssl_modules_dir(path)

Set the default search location for openssl modules.

relenv.runtime.setup_crossroot()

Setup cross root if needed.

relenv.runtime.setup_openssl()

Configure openssl certificate locations.

relenv.runtime.system_sysconfig()

Read the system python’s sysconfig values.

Th system python isthe one installed by your package manager. Memoize them to avoid the overhead of shelling out.

relenv.runtime.wrap_cmd_install(name)

Wrap pip install command to store target argument state.

relenv.runtime.wrap_distutils_command(name)

distutils.command wrapper.

relenv.runtime.wrap_locations(name)

Wrap pip locations to fix locations when installing with target.

relenv.runtime.wrap_pip_build_wheel(name)

pip._internal.operations.build wrapper.

relenv.runtime.wrap_pip_distlib_scripts(name)

pip.distlib.scripts wrapper.

relenv.runtime.wrap_pip_install_legacy(name)

pip._internal.operations.install.legacy wrapper.

relenv.runtime.wrap_pip_install_wheel(name)

pip._internal.operations.install.wheel wrapper.

relenv.runtime.wrap_req_command(name)

Honor ignore installed option from pip cli.

relenv.runtime.wrap_req_install(name)

Honor ignore installed option from pip cli.

relenv.runtime.wrap_sysconfig(name)

Sysconfig wrapper.

relenv.runtime.wrapsitecustomize(func)

Wrap site.execsitecustomize.

This allows relenv a hook to be the last thing that runs when pythong is setting itself up.