diff --git a/docs/guides/feature-flags.rst b/docs/guides/feature-flags.rst index 9beb7043aa9..3976421a6cd 100644 --- a/docs/guides/feature-flags.rst +++ b/docs/guides/feature-flags.rst @@ -37,6 +37,8 @@ e.g. python-reno release notes manager is known to do that ``EXTERNAL_VERSION_BUILD``: :featureflags:`EXTERNAL_VERSION_BUILD` +``LIST_PACKAGES_INSTALLED_ENV``: :featureflags:`LIST_PACKAGES_INSTALLED_ENV` + ``SHARE_SPHINX_DOCTREE``: :featureflags:`SHARE_SPHINX_DOCTREE` By default, when Read the Docs runs Sphinx it passes a different output directory for the generated/parsed doctrees diff --git a/readthedocs/doc_builder/python_environments.py b/readthedocs/doc_builder/python_environments.py index 3f95282bd0f..678322f3b3f 100644 --- a/readthedocs/doc_builder/python_environments.py +++ b/readthedocs/doc_builder/python_environments.py @@ -425,9 +425,23 @@ def install_requirements_file(self, install): self.build_env.run( *args, cwd=self.checkout_path, - bin_path=self.venv_bin() # noqa - no comma here in py27 :/ + bin_path=self.venv_bin(), ) + def list_packages_installed(self): + """List packages installed in pip.""" + args = [ + self.venv_bin(filename='python'), + '-m', + 'pip', + 'list', + ] + self.build_env.run( + *args, + cwd=self.checkout_path, + bin_path=self.venv_bin(), + ) + class Conda(PythonEnvironment): @@ -627,3 +641,15 @@ def install_requirements_file(self, install): # as the conda environment was created by using the ``environment.yml`` # defined by the user, there is nothing to update at this point pass + + def list_packages_installed(self): + """List packages installed in conda.""" + args = [ + 'conda', + 'list', + ] + self.build_env.run( + *args, + cwd=self.checkout_path, + bin_path=self.venv_bin(), + ) diff --git a/readthedocs/projects/models.py b/readthedocs/projects/models.py index a5f64eb4e7a..a776f77e105 100644 --- a/readthedocs/projects/models.py +++ b/readthedocs/projects/models.py @@ -1584,6 +1584,7 @@ def add_features(sender, **kwargs): CACHED_ENVIRONMENT = 'cached_environment' CELERY_ROUTER = 'celery_router' LIMIT_CONCURRENT_BUILDS = 'limit_concurrent_builds' + LIST_PACKAGES_INSTALLED_ENV = 'list_packages_installed_env' VCS_REMOTE_LISTING = 'vcs_remote_listing' FEATURES = ( @@ -1663,6 +1664,13 @@ def add_features(sender, **kwargs): LIMIT_CONCURRENT_BUILDS, _('Limit the amount of concurrent builds'), ), + ( + LIST_PACKAGES_INSTALLED_ENV, + _( + 'List packages installed in the environment ("pip list" or "conda list") ' + 'on build\'s output', + ), + ), ( VCS_REMOTE_LISTING, _('Use remote listing in VCS (e.g. git ls-remote) if supported for sync versions'), diff --git a/readthedocs/projects/tasks.py b/readthedocs/projects/tasks.py index 668b00cf963..2b9b67ec147 100644 --- a/readthedocs/projects/tasks.py +++ b/readthedocs/projects/tasks.py @@ -1205,6 +1205,8 @@ def setup_python_environment(self): self.python_env.save_environment_json() self.python_env.install_core_requirements() self.python_env.install_requirements() + if self.project.has_feature(Feature.LIST_PACKAGES_INSTALLED_ENV): + self.python_env.list_packages_installed() def build_docs(self): """