Skip to content
module

rsconnect.environment

Environment data class abstraction that is usable as an executable module

python -m rsconnect.environment
Classes
  • Environment Environment(conda, contents, error, filename, locale, package_manager, pip, python, source)</>
  • EnvironmentException Common base class for all non-exit exceptions.</>
Functions
  • conda_env_export(conda) Inspect the environment using conda env export :param: conda path to the conda tool :return: dictionary containing the key "environment.yml" and the data inside</>
  • detect_environment(dirname, force_generate, conda_mode, conda) Determine the python dependencies in the environment.</>
  • get_conda(conda) get_conda tries to find the conda executable if we're in a conda environment. If not, or if we cannot find the executable, return None. :returns: conda string path to conda or None.</>
  • main() Run detect_environment and dump the result as JSON.</>
  • output_file(dirname, filename, package_manager) Read an existing package spec file.</>
  • pip_freeze() Inspect the environment using pip freeze.</>
class

rsconnect.environment.Environment(conda, contents, error, filename, locale, package_manager, pip, python, source)

Bases
tuple

Environment(conda, contents, error, filename, locale, package_manager, pip, python, source)

class

rsconnect.environment.EnvironmentException()

Bases
Exception BaseException

Common base class for all non-exit exceptions.

function

rsconnect.environment.detect_environment(dirname, force_generate=False, conda_mode=False, conda=None)

Determine the python dependencies in the environment.

pip freeze will be used to introspect the environment unless conda_mode is set to True. In that case, an attempt will be made to use Conda to introspect the environment.

:param: dirname Directory name :param: force_generate Force the generation of an environment :param: conda_mode inspect the environment assuming Conda :return: a dictionary containing the package spec filename and contents if successful, or a dictionary containing error on failure.

function

rsconnect.environment.get_conda(conda=None)

get_conda tries to find the conda executable if we're in a conda environment. If not, or if we cannot find the executable, return None. :returns: conda string path to conda or None.

function

rsconnect.environment.output_file(dirname, filename, package_manager)

Read an existing package spec file.

Returns a dictionary containing the filename and contents if successful, None if the file does not exist, or a dictionary containing 'error' on failure.

function

rsconnect.environment.pip_freeze()

Inspect the environment using pip freeze.

Returns a dictionary containing the filename (always 'requirements.txt') and contents if successful, or a dictionary containing 'error' on failure.

function

rsconnect.environment.conda_env_export(conda)

Inspect the environment using conda env export :param: conda path to the conda tool :return: dictionary containing the key "environment.yml" and the data inside

function

rsconnect.environment.main()

Run detect_environment and dump the result as JSON.