Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show a list of packages installed on environment #6992

Merged
merged 6 commits into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/guides/feature-flags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 27 additions & 1 deletion readthedocs/doc_builder/python_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down Expand Up @@ -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(),
)
8 changes: 8 additions & 0 deletions readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -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'),
Expand Down
2 changes: 2 additions & 0 deletions readthedocs/projects/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down