5 ms·
At first glance, pbr appears to solve the problem of having to duplicate my dependencies in both setup.py and requirements.txt.
by coredog64 9y ago
At first glance, pbr appears to solve the problem of having to duplicate my dependencies in both setup.py and requirements.txt.
- daenney 9y agoI suppose it does doe that, so does this though: with codecs.open('requirements.txt') as f: requirements = f.read().splitlines() ... install_requires=requirements, I don't think it's worth the dependency. But perhaps for others it is.
- leetrout 9y agoThat works for simple use cases but it is not robust. In case anyone sees this, at a minimum you need to use from pip.req import parse_requirements parse_requirements('path/to/requirements.txt') to be safe here.
- bobbyi_settv 9y agoWhat if the user doesn't have pip installed? This is before we've installed the requirements, so we shouldn't be assuming anything outside the stdlib.
- AndrewCHM 9y agoif I'm not mistaken, requirements are parsed out to be installed before installing the desired package, so that should be fine
- blamarvt 9y agoIsn't that paradoxical? That code is for parsing requirements and those requirements can't be parsed until initial pre-requirements (pip, in this case) are installed.
- AndrewCHM 9y agosorta from my understanding, when you build the package, your computer extracts the relevant required packages, and sends up that data to pypi, which then in turn sends that data back to users when they install At least thats how I think it works
- ak217 9y agoI think you may be misunderstanding the problem being discussed. The code that uses pip will crash if pip is not already installed. There is no way to parse and satisfy the dependency on pip, because the author chose to import pip as a library.
- AndrewCHM 9y agopip being a dependency is defined at upload time, it is parsed by the creator of the package, not the consumer, afaik if you used any other package manager, it would need to resolve dependencies from the additional info in the package index, resulting in pip being downloaded and installed before the desired package is installed
- ak217 9y agoThis is actually less robust, since instead of relying on the setuptools API, you now also rely on the pip API. If you control requirements.txt, there is nothing "not robust" about parsing it in setup.py.
- joshuamorton 9y agoWhy are you using a requirements.txt if you have a setup.py that lists them? `pip install -e` or `setup.py install` should just work in that case.
- rajathagasthya 9y agoWhat if you have your own package index? You can use `--index-url` in requirements.txt to specify that.
- joshuamorton 9y agoYou can use `--index-url` when calling pip: https://pip.pypa.io/en/stable/reference/pip_wheel/#index-url https://pip.pypa.io/en/stable/reference/pip_wheel/#index-url You can also use `dependency_links` in your setup.py to specify this, which allows deps on github etc.
- cat199 9y agoYou don't always want to install the actual package necessarily (e.g. dev) - using requirements separately lets you install the deps but not the package...
- di 9y agoYou should read this: https://caremad.io/posts/2013/07/setup-vs-requirement/ https://caremad.io/posts/2013/07/setup-vs-requirement/, it specifically references this "feature" of pbr.
- epage 9y agoThe approach I've been using Define my dependencies - setup.py - requirements_dev.in run piptools pip-compile to generate a locked set of dependencies - requirements.txt - requirements_dev.txt It gives me some of the benefit of Rust's Cargo.toml / Cargo.lock in the python world (and actually respects all package's dependency version declarations unlike other tools like pyup).
- joshuamorton 9y agoI'd suggest pipenv for this kind of thing. It will generate a pipfile.lock, which is the (still in development, but pretty stable) official way to create a locked set of deps.