[question] How to integrate with setup.py?
See original GitHub issueUsing requirements.txt
I can do it:
from pip.req import parse_requirements
requirements = [str(r.req) for r in
parse_requirements('requirements.txt', session=False)]
test_requirements = [str(r.req) for r in
parse_requirements('requirements-test.txt', session=False)]
How can I do the same using Pipfile?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:38 (13 by maintainers)
Top Results From Across the Web
What is setup.py? - Stack Overflow
setup.py is a python file, the presence of which is an indication that the module/package you are about to install has likely been...
Read more >What is setup.py? - Educative.io
The setup.py file is a Python file which indicates that the installation module/package is most likely packed and distributed using Distutils, the Python...
Read more >Do I need to include the license for all dependencies declared ...
No, you do not need to include licenses for code that isn't part of your repository. However, as a service to your users,...
Read more >How to Package Python dependencies with PIP setuptools
Lay out your project on your local machine using an appropriate directory structure. Create a setup.py script that describes all the metadata ...
Read more >Making sense of setup.py - YouTube
Tim McNamarahttps://kiwi.pycon.org/schedule/presentation/122/This talk will guide you through the process of wrapping your scraps and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
First, disclaimer: My expertise is mainly with lib packages. I might miss some points. I hold the right to be wrong, and I’m ready to use it! Also, this got me to scratch my head a few time. I’d really like some review on this.
Now, let’s get to this.
I’ll start with this statement @elgertam:
You added
numpy
to your environment, you did not addnumpy
to the dependencies of your app. Those are two different things. Keep reading, you’ll see what I mean.Surprisingly, your usage is not so different if you think about it:
pip install stuff
->pip freeze > requirements.txt
-> feedinstall_requires
fromrequirements.txt
pipenv install stuff
->Pipfile
automatically updated -> trying to feedinstall_requires
with thePipfile
.install_requires
->pipenv install
-> Environment andPipfile.lock
are updated.And for that intended way to work, you want a
Pipfile
that states that you want to install your app. Something like therequests
Pipfile
linked by @isobit.Or, an example:
Your
Pipfile
is to describe your environment, not the dependencies of a package. As you see, thePipfile
above defines what I want to install, which is the local package in editable mode.This may look a bit “useless”, as right now its all drived by a single package, but let say you want to install your app, but with
requests[security]
, but it’s not a strict dependency from your app, you dopipenv install requests[security]
, and then:And voilà, here’s an example of the difference between your abstract requirements, and your concrete requirements. Same goes if you wanted to install
gunicorn
or anything else needed in the environment, but that’s not part of the app itself.If I’ve explained this well enough, you can see that its just supposed to be the other way around. You put your dependencies in
install_requires
, you put you package in thePipfile
, and then you get and environment, with aPipfile.lock
for reproducibility (as it will resolve and respect your package dependencies).For
test_require
, I’ll admit I’m not sure that fits in all of this. IIRC, its asetuptools
specific feature. We could argue that it’s a set of abstract dependencies for testing, and expectpipenv
to resolve and install those then doingpipenv install --dev
, for all packages, but I have a feeling that’s not quite right. I dont have a clear idea or opinion on this and the rationale around it, sorry.I hope this all make sense somehow.
You should be able to accomplish this with the code below. This will load the Pipfile from your current project and return the dependencies in a pip compatible list.
Let us know if you have any further questions 😃