question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parsing the requirements file always needs HTTP Session object.

See original GitHub issue

Parsing the requirements file should not need a HTTP Session object if there are no references to resolve. This is useful for setup.py files to avoid maintaining the same dependency list twice.

From https://stackoverflow.com/questions/14399534/reference-requirements-txt-for-the-install-requires-kwarg-in-setuptools-setup-py

from pip.req import parse_requirements

# parse_requirements() returns generator of pip.req.InstallRequirement objects
install_reqs = parse_requirements(<requirements_path>)

# reqs is a list of requirement
# e.g. ['django==1.5.1', 'mezzanine==1.4.6']
reqs = [str(ir.req) for ir in install_reqs]

setup(
    ...
    install_requires=reqs
)

The code above no longer works. This hash works:

install_reqs = parse_requirements('requirements.txt', session='hack')

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dstufftcommented, Jun 17, 2017

I’m going to close this, the current behavior is good enough for pip’s uses and uses external to pip are not supported. That this makes it more annoying for people to use outside of pip, particularly in a setup.py is really a good thing TBH.

0reactions
pfmoorecommented, Jun 18, 2017

You know that pip codebase is “not perfect”. Option parsing alone and inheritance is insane. I don’t understand what are you protecting

@techtonik I know that you have persistently failed to understand the explanations that have been offered, so I doubt that this response will fare much better, but I will try one final time to explain the position to you.

Pip’s fundamental purpose is to be a command line program that can be used to install packages for Python. That’s all. It’s not intended as a library for use by other programs, any more than it is intended to be any other thing that isn’t it’s core purpose. So anything that is important for ensuring that pip serves that primary goal of being a command line program for installing packages, is the main priority. The pip development team is very small, given the importance of pip to the Python ecosystem, and is totally unfunded, volunteer time. As a result, work on “tidying up”, or on “improving the codebase” is almost impossible to find time for. And work that implies support for something that is not pip’s key goal, and which is only likely to result in more issues being raised (specifically, making pip’s internal API more usable for 3rd party programs) is a net drain on our resources, for absolutely zero benefit for our key user base - people using pip as a command line program.

We aren’t “protecting” pip’s internal code base. We simply don’t have the time or interest to spend working on tidying up exercises that people who aren’t using pip in the way it was intended are demanding (and in some cases, relentlessly nagging about in spite of being told “this isn’t supported”).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Usage — Requests 2.28.1 documentation
The Session object allows you to persist certain parameters across requests. It also persists cookies across all requests made from the Session instance, ......
Read more >
HTTP requests and JSON parsing in Python - Stack Overflow
I want to send such a request, receive the result and parse it. See also stackoverflow.com/questions/20199126/reading-json-from-a-file, for the case where the ...
Read more >
Requiring modules in Node.js: Everything you need to know
Every module object gets an id property to identify it. This id is usually the full path to the file, but in a...
Read more >
Window.localStorage - Web APIs | MDN
The localStorage read-only property of the window interface allows you to access a Storage object for the Document's origin; the stored data ...
Read more >
REST API Guide | Parse
API access can be provided over HTTPS and HTTP. ... Session objects manually created from POST /parse/sessions are always restricted.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found