Skip to content

Add support for "packages" install key in v2 config #7289

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

Closed
wants to merge 10 commits into from
Closed

Add support for "packages" install key in v2 config #7289

wants to merge 10 commits into from

Conversation

NiklasRosenstein
Copy link

@NiklasRosenstein NiklasRosenstein commented Jul 13, 2020

This adds support for a packages install option in the v2 config file. Example:

version: 3.7
install:
  - packages:
    - mkdocs-material
    - Pygments

The motivation for this change is that you don't have to have a requirements.txt in your project when you only need those requirements for the Read the Docs build environment.

Testing

  • Add unit test
  • Actually test the package installation (install_packages_list())

@ericholscher ericholscher requested a review from stsewd July 30, 2020 00:34
Copy link
Member

@stsewd stsewd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! We need to see how we should check for valid packages names before passing them down to pip. I have made some suggestions in the meantime.

'--exists-action=w',
*self._pip_cache_cmd_argument(),
]
args += install.packages
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be careful here, users could set a package name like --option and we will execute that. Not sure the best way to prevent that. We could probably validate this in the config module and raise an exception for invalid names, or maybe escape those characters here. /cc @readthedocs/core

Invalid names would be those that start with -, not sure what else we should validate here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much of a concern is this really? Pip also reads options from requirements.txt files, or at least a subset of options that are valid for the pip install command like

--extra-index-url https://example.org/pypi/simple
some-requirement >=1.0.0, <2.0.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, you are right, maybe allow the same subset of options?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about using the same parser that pip uses and check for a valid name?

On the other hand, @davidfischer created this package that could be useful if we can validate each line separately: https://requirements-parser.readthedocs.io/en/latest/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does RTD have a separate validation step? Otherwise Pip will just complain if the requirement is invalid.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but we need to verify it before sending to pip in some way because otherwise you can inject random commands into the pip by calling pip install package1 "echo test > /tmp/test.txt" (quotes should be `, but I can escape them here)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, @davidfischer created this package that could be useful if we can validate each line separately: https://requirements-parser.readthedocs.io/en/latest/

This package is super old and outdated and probably would need some love before it's useful. That package doesn't directly parse the lines by itself but instead uses the parser built-in to setuptools.

Co-authored-by: Santos Gallegos <[email protected]>
Comment on lines +251 to +252
- mkdocs-material
- Pygments
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should consider supporting private packages https://docs.readthedocs.io/en/stable/guides/private-python-packages.html for Read the Docs for Business, probably.

Copy link
Author

@NiklasRosenstein NiklasRosenstein Sep 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I am missing something, this should already be supported implicitly. You can just use a Git repository URL instead of a package name, e.g.:

- packages:
  - mkdocs-material
  - git+https://${GITHUB_TOKEN}@github.com/user/project.git@{version}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested that the environment variable is properly replaced with its value?

Copy link
Author

@NiklasRosenstein NiklasRosenstein Sep 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope and I doubt that it will be at this stage. Good point that we should probably support the substitution of environment variables, otherwise while it technically works to hard code the token, that's probably not what anyone wants 😄

Does Pip support the substitution in requirements.txt?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Pip support the substitution in requirements.txt?

Yes, pip supports expanding variables

Copy link
Author

@NiklasRosenstein NiklasRosenstein Sep 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it'll be easier to just write the arguments into a temporary requirements file and re-use the existing logic for installing from that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to push this along and finish this work, I'd be fine opening an issue to add private repository support to the packages config key later. This PR seems close otherwise and it looks to be blocked on this additional feature.

@humitos humitos added the PR: work in progress Pull request is not ready for full review label Aug 31, 2020
@stale
Copy link

stale bot commented Oct 24, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: stale Issue will be considered inactive soon label Oct 24, 2020
@stale stale bot closed this Nov 1, 2020
@stsewd stsewd removed the Status: stale Issue will be considered inactive soon label Nov 2, 2020
@stsewd stsewd reopened this Nov 2, 2020
@stale
Copy link

stale bot commented Jan 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: stale Issue will be considered inactive soon label Jan 2, 2021
@stsewd stsewd removed the Status: stale Issue will be considered inactive soon label Jan 4, 2021
@stale
Copy link

stale bot commented Jun 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: stale Issue will be considered inactive soon label Jun 2, 2021
@stale stale bot closed this Jun 9, 2021
@stsewd
Copy link
Member

stsewd commented Jun 10, 2021

With our future direction to allow executing arbitrary commands, do we still want this feature?

@humitos
Copy link
Member

humitos commented Jun 14, 2021

We may want to talk a little more about this now that we are deciding to make more changes to the builder. However, at first sight, I still think this is a useful feature for noob users that don't need to understand how pip/requirements.txt file works (probably, this is more interesting in particular for the commercial site --cc @agjohnson) or just when your project is simple enough to require a small number of packages that are different from the requirements of the package itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: work in progress Pull request is not ready for full review Status: stale Issue will be considered inactive soon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants