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

Route as '--find-links' replacement #2

Closed
sinoroc opened this issue Nov 17, 2020 · 5 comments
Closed

Route as '--find-links' replacement #2

sinoroc opened this issue Nov 17, 2020 · 5 comments

Comments

@sinoroc
Copy link

sinoroc commented Nov 17, 2020

I see people are struggling with installing pytorch on Windows, especially with poetry since it does not know how to do something like pip's --find-links option does. Would simpleindex be able to help in such a scenario?

Typically the recommended installation command for Windows looks like:

pip install torch===1.7.0 torchvision===0.8.1 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html

which seems to be impossible to do with poetry.

@uranusjr
Copy link
Owner

uranusjr commented Nov 17, 2020

Assuming pytorch’s find-link page is valid HTML5 (I quickly checked and it seems to be the case), you should be able to just route all pytorch-related packages to it:

# Run `simpleindex path/to/this/file.toml` to start the server.
[routes.torch]
source = "http"
to = "https://download.pytorch.org/whl/torch_stable.html"

[routes."torch{suffix}"]
source = "http"
to = "https://download.pytorch.org/whl/torch_stable.html"

[routes."{project}"]
source = "http"
to = "https://pypi.org/simple/{project}/"

[host]
host = "127.0.0.1"
port = 8000
# Add this to `pyproject.toml`
[[tool.poetry.source]]
name = "local"
url = "http://127.0.0.1:8000/"
default = true

This should be able to make Poetry find the packages.


I said should be because it does not. Pytorch’s find-links page has links like this

<a href="torch-0.1-cp27-cp27m-macosx_10_6_x86_64.whl">torch-0.1-cp27-cp27m-macosx_10_6_x86_64.whl</a>

Simpleindex uses 302 FOUND to redirect requests to the actual page, and Poetry would resolve href against http://127.0.0.1:8000/pytorch/, i.e. the original URL. pip instead resolves against the redirected URL.

PEP 503 does not really say what should happen when an endpoint returns redirection, but pip’s behaviour is likely more expected by users since that’s what every web browser in the world does, so Poetry should probably match it.

@sinoroc
Copy link
Author

sinoroc commented Nov 17, 2020

Thanks a lot for looking into this.

I think I saw a bug report and PR in poetry's ticket tracker about URL redirections. Maybe it is related:

@uranusjr
Copy link
Owner

Yeah, I think those are the exact same issue.

@uranusjr
Copy link
Owner

I see python-poetry/poetry#3198 has been merged, so should this be closed?

@sinoroc
Copy link
Author

sinoroc commented Jul 12, 2021

@uranusjr Absolutely. Although I lost touch with the topic, I don't see any reason to keep this ticket open. Thanks for answering my initial question.

@sinoroc sinoroc closed this as completed Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants