Skip to content

FAQ is wrong? #8087

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
ruro opened this issue Apr 11, 2021 · 9 comments · Fixed by #8118
Closed

FAQ is wrong? #8087

ruro opened this issue Apr 11, 2021 · 9 comments · Fixed by #8118
Assignees
Labels
Needed: documentation Documentation is required

Comments

@ruro
Copy link

ruro commented Apr 11, 2021

Don't know if this is the correct place to report errors in the readthedocs documentation, but here goes.

The official documentation Frequently Asked Questions > Can I document a python package that is not at the root of my repository? page states (emphasis mine):

If you want to place your package in a different directory or have multiple python packages in the same project, then create a pip requirements file. You can specify the relative path to your package inside the file. For example you want to keep your python package in the src/python directory, then create a requirements.txt file with the following contents:

src/python/

Please note that the path must be relative to the file. So the example path above would work if the file is in the root of your repository. If you want to put the requirements in a file called requirements/requirements.txt, the contents would look like:

../python/

Unless I am misunderstanding something, this is wrong on 2 accounts.

  1. The relative path would be ../src/python, not ../python.
  2. Even with a "correct" relative path, this doesn't actually work, afaik, since pip install -r requirements/requirements.txt resolves the relative paths inside requirements.txt as if they were relative to the CWD, not to the requirements.txt file.

Piggybacking on this issue, I would like to ask if there is some way to control the CWD during the pip install -r step to make it so that the paths inside requirements.txt are actually resolved relative to its location?

I use pip-tools (pip-compile) to create my requirements.txt file and I would like to keep my requirements-related files in a subdirectory, however pip-tools version 7.0.0 will change relative path handling to be relative to the requirements.txt file, so doing a pip install -r requirements/requirements.txt from the root of the project will no longer work. Instead, I will have to cd requirements && pip install -r requirements.txt or pip-sync requirements/requirements.txt.

@stsewd
Copy link
Member

stsewd commented Apr 12, 2021

The relative path would be ../src/python, not ../python.

Yes, that's right, the path is wrong.

since pip install -r requirements/requirements.txt resolves the relative paths inside requirements.txt as if they were relative to the CWD, not to the requirements.txt file.

Oh, if that's correct then we should change the recommendation to use https://docs.readthedocs.io/en/stable/config-file/v2.html#packages instead. But you won't be able to specify them in the requirements file.

And I don't think we would allow to change the cwd, but we are considering allowing to run arbitrary commands in some stages of the build, so things like this can be done (#6662).

@stsewd stsewd added the Needed: documentation Documentation is required label Apr 12, 2021
@rajpratyush
Copy link

is this issue open for work?

@stsewd
Copy link
Member

stsewd commented Apr 15, 2021

is this issue open for work?

yes!

@rajpratyush
Copy link

so i just have to change the FAQ documentation a\not the other part concerning with requirements.txt

@astrojuanlu astrojuanlu self-assigned this Apr 19, 2021
@astrojuanlu
Copy link
Contributor

since pip install -r requirements/requirements.txt resolves the relative paths inside requirements.txt as if they were relative to the CWD, not to the requirements.txt file.

I confirm this.

@astrojuanlu
Copy link
Contributor

Related issue in pip-tools: jazzband/pip-tools#797 (closed as "won't fix")

astrojuanlu added a commit to astrojuanlu/readthedocs.org that referenced this issue Apr 19, 2021
@ruro
Copy link
Author

ruro commented Apr 19, 2021

however pip-tools version 7.0.0 will change relative path handling to be relative to the requirements.txt file

Related issue in pip-tools: jazzband/pip-tools#797 (closed as "won't fix")

I must have been very tired, when I wrote the last paragraph of the original post. I have confused 2 different pull requests in pip-tools. Somehow, I was under the impression that pull request jazzband/pip-tools#1329 was accepted and/or scheduled for the next milestone, this is not correct. That pull request indeed implements the "new" relative path handling that I was describing, but it's currently only a draft and not scheduled for any version/milestone AFAIK.

I think, I mixed it up with a different pull request that I was also following at the time that did get merged into the 6.1.0 release but is unrelated to the relative path handling issue. Sorry for any confusion.

@astrojuanlu
Copy link
Contributor

No worries @ruro ! In any case, you were right about the FAQ and I submitted #8118 with a fix / clarification of that part, in case you want to have a look.

@ruro
Copy link
Author

ruro commented Apr 19, 2021

lgtm! :^)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needed: documentation Documentation is required
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants