Skip to content

Add support for pre-install step #6662

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
jaraco opened this issue Feb 16, 2020 · 8 comments
Closed

Add support for pre-install step #6662

jaraco opened this issue Feb 16, 2020 · 8 comments
Assignees
Labels
Accepted Accepted issue on our roadmap

Comments

@jaraco
Copy link
Contributor

jaraco commented Feb 16, 2020

Details

Expected Result

There would be a hook that setuptools could invoke to bootstrap the source tree prior to attempting to install it.

Actual Result

RTD attempts to install the source and fails because a bootstrap step is necessary.


In pypa/setuptools#2001, I've captured an emergent failure. After switching from pip_install = False to pip_install = True (in order to support extras and eventually support other features like Sphinx builds to include API docstrings), the builds no longer succeed.

Setuptools has a unique condition where it needs some of its functionality available (entry point definitions) before it's able to install itself as other packages do. To accomplish this task, setuptools provides its own ./bootstrap.py that must be invoked prior to invoking setup.py *anything* or pip install <source dir>.

I've looked into the custom build steps, but those seem to happen after any install step. What I desire is a hook where I can define behavior before any install.

I imagine I could build a custom RTD builder that also performs the install, and leave pip_install=False (or version 2 equivalent), but that feels hacky and brittle.

Would it be possible to add a hook pre_install that if set to python -m bootstrap would execute that prior to pip install? Do you have any other suggestions?

@jaraco
Copy link
Contributor Author

jaraco commented Feb 16, 2020

If RTD had a hook that allowed overriding the entire install/build process, setuptools has a tox -e docs routine that builds the docs reliably. Could a plugin be written to invoke that behavior instead, providing a generalizable way for a client to define the larger process?

@humitos
Copy link
Member

humitos commented Feb 17, 2020

Hi @jaraco! Thanks for reporting this. We have a long discussion internally about features like this and we haven't made a decision yet. We are discussing topics like "allowing user to run just random commands" and "allow to upload a pre-built HTML" which are related in some way to what you are needing at this point.

I don't have a good answer and we don't know when we are going to implement these. We need to keep discussing and make a final decision. Although, your report will help us to have another use case where we need to make a decision and do something about this.

clrpackages pushed a commit to clearlinux-pkgs/openstack-setuptools that referenced this issue Mar 10, 2020
…ered processing package index.

Andrew Taylor (1):
      Add info message when authentication error encountered processing package index.

Bastian Venthur (5):
      Deprecated Eggsecutable Scripts
      Put deprecation in section rather then removing it (updated changelog as well)
      Added test for DeprecationWarning
      warning -> deprecated
      Removed unused context.quiet

Dan Rose (1):
      Remove sys.modules hack

Jason R. Coombs (29):
      Error on warnings. Fixes #1823.
      Move the error directive to the top, as it's more permanent.
      Add changelog entry
      normalize indentation
      Remove the Features feature. Fixes #65.
      Update changelog.
      Add azure pipelines from jaraco/skeleton
      Bootstrap the environment in tox, allowing simple 'tox' to run tests and simplifying all of the pipelines.
      Update deprecation version and include extension on changelog file.
      Avoid installing setuptools 45 on Python 2.
      Pin virtualenv to <20 as workaround for #1998.
      Suppress failures due to unfortunate combination of issues. Ref #2000.
      Copy docs requirements to a separate file due to RTD constraints. Fixes #2001. Ref readthedocs/readthedocs.org#6662
      Bump version: 45.2.0 → 45.3.0
      Also remove mysterious hack from pkg_resources.extern
      Try building docs with python3. Ref #1992.
      Reword UserWarning for insecure extraction path so that the message can be keyed for ignoring it. Ref #1899.
      Suppress UserWarning in pkg_resources.
      Try installing pip
      Use pep517 to avoid bb://pypa/distlib#136.
      Emit the Python version
      Add a file 'runtime.txt' to let Netlify know to use that env. Fixes #1992.
      Docs land in build/html
      Add a note about runtime.txt
      Suppress RuntimeWarning from sandbox module on Python 2
      Suppress Windows bytes API warning until it can be fixed. Ref #2016.
      Suppress another warning
      Get both UnicodeWarnings
      Bump version: 45.3.0 → 46.0.0

Miro Hrončok (1):
      Include pkg_resources test data in sdist

Ye-hyoung Kang (2):
      Fix broken link to Python docs
      Create 2011.doc.rst

mayeut (1):
      Use CPython 3.8.0 mechanism to find msvc 14+
clrpackages pushed a commit to clearlinux-pkgs/setuptools that referenced this issue Mar 10, 2020
…ered processing package index.

Andrew Taylor (1):
      Add info message when authentication error encountered processing package index.

Bastian Venthur (5):
      Deprecated Eggsecutable Scripts
      Put deprecation in section rather then removing it (updated changelog as well)
      Added test for DeprecationWarning
      warning -> deprecated
      Removed unused context.quiet

Dan Rose (1):
      Remove sys.modules hack

Jason R. Coombs (29):
      Error on warnings. Fixes #1823.
      Move the error directive to the top, as it's more permanent.
      Add changelog entry
      normalize indentation
      Remove the Features feature. Fixes #65.
      Update changelog.
      Add azure pipelines from jaraco/skeleton
      Bootstrap the environment in tox, allowing simple 'tox' to run tests and simplifying all of the pipelines.
      Update deprecation version and include extension on changelog file.
      Avoid installing setuptools 45 on Python 2.
      Pin virtualenv to <20 as workaround for #1998.
      Suppress failures due to unfortunate combination of issues. Ref #2000.
      Copy docs requirements to a separate file due to RTD constraints. Fixes #2001. Ref readthedocs/readthedocs.org#6662
      Bump version: 45.2.0 → 45.3.0
      Also remove mysterious hack from pkg_resources.extern
      Try building docs with python3. Ref #1992.
      Reword UserWarning for insecure extraction path so that the message can be keyed for ignoring it. Ref #1899.
      Suppress UserWarning in pkg_resources.
      Try installing pip
      Use pep517 to avoid bb://pypa/distlib#136.
      Emit the Python version
      Add a file 'runtime.txt' to let Netlify know to use that env. Fixes #1992.
      Docs land in build/html
      Add a note about runtime.txt
      Suppress RuntimeWarning from sandbox module on Python 2
      Suppress Windows bytes API warning until it can be fixed. Ref #2016.
      Suppress another warning
      Get both UnicodeWarnings
      Bump version: 45.3.0 → 46.0.0

Miro Hrončok (1):
      Include pkg_resources test data in sdist

Ye-hyoung Kang (2):
      Fix broken link to Python docs
      Create 2011.doc.rst

mayeut (1):
      Use CPython 3.8.0 mechanism to find msvc 14+
@NiklasRosenstein
Copy link

NiklasRosenstein commented Jul 3, 2020

FWIW, I've hacked around this for my Pydoc-Markdown project (link to rtd). I created readthedocs-custom-steps which hooks into the MkDocs invocation on Read the Docs and instead routes it to a Python module that reads the contents of .readthedocs-custom-steps.yml.

Unfortunately .readthedocs.yml cannot contain additional keys, so it has to be in a separate file. This would be a lot more concise to set up if one could write the below instead of having to split it up into three files (RTD, requirements and custom steps).

version: 2
mkdocs: {}
python:
  version: 3.7
  install:
  - {method: pip, path: .}
  - requires: readthedocs-custom-steps
x-custom-steps:
- echo "This is a custom build step. Output folder is $SITE_DIR"
- ...

@NiklasRosenstein
Copy link

I've created a pull request to suggest a possible implementation for the above features: #7259

@ericholscher
Copy link
Member

I'm +1 on just having a prebuild CLI step that runs. It's currently possible with hacky workarounds, but I think at this point feels like an obvious win.

@humitos
Copy link
Member

humitos commented May 25, 2021

This is another use case that could be supported by the proposed solution at #8190 by overriding just build.jobs.pre_install config.

@humitos
Copy link
Member

humitos commented Apr 5, 2022

Hi! In a few hours, we are deploying a new feature that will allow people to call arbitrary commands at different moments in the build process (see #9016). For example,

build:
  os: ubuntu-20.04
  jobs:
    pre_install:
      - python -m bootstrap

I think this new config key, build.jobs, will cover this case. Take a look at the documentation at https://docs.readthedocs.io/en/latest/config-file/v2.html#build-jobs and please let me know if this is useful for you.

@humitos humitos added the Needed: more information A reply from issue author is required label Apr 5, 2022
@humitos humitos moved this from In progress to Done in 📍Roadmap Apr 6, 2022
@humitos humitos moved this from Done to In progress in 📍Roadmap Apr 6, 2022
@jaraco
Copy link
Contributor Author

jaraco commented Apr 9, 2022

I no longer have the need that originally inspired this request, but it does appear the pre_create_environment setting of a build does exactly what would have fulfilled this need. Thanks for the work considering it and adding it. I'm confident it will prove useful in the future!

@jaraco jaraco closed this as completed Apr 9, 2022
Repository owner moved this from In progress to Done in 📍Roadmap Apr 9, 2022
@no-response no-response bot removed the Needed: more information A reply from issue author is required label Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted issue on our roadmap
Projects
Archived in project
Development

No branches or pull requests

4 participants