Announcing Pipenv
664 points by imkevinxu 8 years ago | 162 comments- cderwin 8 years agoThis is great, but sometimes I think that python needs a new package manager from scratch instead of more tools trying to mix and mash a bunch of flawed tools together in a way that's palatable by most of us. Python packaging sucks, the whole lot of it. Maybe I'm just spoiled by rust and elixir, but setuptools, distutils, pip, ez_install, all of it is really subpar. But of course everything uses pypi and pip now, so it's not like any of it can actually be replaced. The state of package management in python makes me sad. I wish there was a good solution, but I just don't see it.
Edit: I don't mean to disparage projects like this and pipfile. Both are great efforts to bring the packaging interface in line with what's available in other languages, and might be the only way up and out of the current state of affairs.
- renesd 8 years agoI think python packaging has gotten LOTS better in the last few years. I find it quite pleasurable to use these days.
From binary wheels (including on different linux architectures), to things like local caching of packages (taking LOTS of load off the main servers). To the organisation github of pypa [0], to `python -m venv` working.
Also lots of work around standardising things in peps, and writing documentation for people.
I would like to applaud all the hard work people have done over the years on python packaging. It really is quite nice these days, and I look forward to all the improvements coming up (like pipenv!).
I'd suggest people checkout fades [1] (for running scripts and automatically downloading dependencies in a venv), as well as conda [2] the alternative package manager.
[1] https://fades.readthedocs.io/en/release-5/readme.html#what-d...
- sametmax 8 years ago+1. Relatively to what we have before, it's so much better. But compared to the JS/Rust ecosystem, we are behind.
Now it's hard to compete with JS on some stuff : it's the only language in the most popular dev plateform (the web) and it has one implicit standardized async model by default.
It's hard to compete with rust on some stuff : it's compiled and is fast, can provide stand alone binaries easily and has a checker that can avoid many bugs.
But this. The package manager. We can compete. And yet we are late.
It's partially my fault since it's a project I had in mind for years and never took the time to work on. It's partially everybody's fault I guess :)
- Dowwie 8 years agoIt was definitely your fault. Thanks for nothing.
- nerdwaller 8 years agoI'd strongly disagree with Python being behind relative to JS. They're roughly on par (with Python being slightly ahead due to smarter caching and more deterministic builds). Unfortunately neither does namespacing nor good versioning, especially in the cache. Take for example Maven (from Java), it caches namespaced and versioned dependencies and is pretty reliably deterministic in the build process.
Verses node which makes horribly assumptions that allow dependencies of libraries to be resolved and dumped into the same library namespace as your application. It also allows users to use the shrinkwrap feature, which imposes the dependency's settings on me (say, for example, I want to use my own npmjs proxy, this is bypassed...)
- 8 years ago
- HowDoesItWork 8 years agoWow, Javascript, really? I am guessing you don't actually work with NPM a lot.
- Dowwie 8 years ago
- sjellis 8 years agoThis is actually one of the big problems, I think: Python packaging involves knowing a number of different things and reading various resources to get the full picture.
Recently, I built a small CLI tool in Python, and learned all of the bits needed to build, test and package my application "the right way". I knew Python syntax before, but it was a lot of effort to set this up. The difference in the experience between Python and Rust or .NET Core is actually shocking, and most it isn't down to anything that Python couldn't do, just the current state of the tooling.
- d0mine 8 years agoCould you provide some specific examples of the "shocking" difference?
- d0mine 8 years ago
- nerdponx 8 years agoConda is great software but the Conda/Anaconda ecosystem is a mess.
- pwang 8 years agoCan you elaborate?
- pwang 8 years ago
- sametmax 8 years ago
- ghshephard 8 years agoOkay - maybe I'm missing something, but pip is the only Python package manager I've ever used. And it's basically "pip install xxx", "pip install --upgrade xxx", "pip show xxx", "pip list", "pip uninstall xxx"
I'm curious what I've been missing about pip that makes it problematic - I've never used the other tools you mentioned (setuptools/distutils/ez_install) - so I can't comment on them, but, on the flip side, I've never had to use them, so maybe my requirements are somewhat more simple than yours.
- sametmax 8 years agoOne things is a good dependency management. Right now if you want to upgrade your Python version, or one of your packages, it's a mountain of manual work. There is nothing in the stack helping you with the dependency graph.
Another thing is providing a stand alone build. Something you can just ship without asking the client to run commands in the terminal to make it work. I use nuikta (http://nuitka.net/) for this. It's a fantastic project, but man it's a lot of work for something that works out of the box in Go or Rust.
One last thing is to generate packages for OS (msi/deb/rpm/dmg/snap). Your sysadmin will like you. Pex (https://pypi.python.org/pypi/pex) is the closest, but not very standard.
Other pet peeves of mine:
- you can't easily move virtualenvs;
- creating a setup.py is very hard for a beginner and has numerous traps;
- setup.py are executable files. Meh.
- what's with this setup.cfg containing 2 lines ? And the MANIFEST.IN being a separate files. Why do I have to put conf also in tox.ini ? And one for each of my linters ? I want ONE setup.cfg file with all config for all tools for my project inside and be done with it. TOML can handle rich sections, just stop creating new files.
- accessing file with pkg_resources() is way harder than it should be. I made a wrapper for this (http://sametmax.com/embarquer-un-fichier-non-python-propreme...).
- one place to have __version__, please. I want it readable in my code AND in my package metadata, without having to use regex or have side effects on imports.
- remove the "can't build wheel message" when it's useless. It scares newcomers.
- README is the long_description. Don't make me read it manually.
- how do I provide vendors in a clean way ?
- install_requires, extras_requires, setup_requires, tests_requires... Make it one require with hooks and tags and be done with it.
- creating a setup.py test config is way harder than it should be and breaks in CI on strange edge cases.
- can we get a PEP on the standard project structure and built it in our tools to be done with it? We all have src/package + setup.py on root anyway.
- pip installs packages in the site-packages dir of the python executable it's installed for. It makes sense, and I think Python deals pretty well with the fact you can have various versions installed on the same machine. But God people are confused by this. Now you can recommend to do "python -m pip", but it's very verbose and it assumes people know what version of Python is behind the "python" executable. On windows it can be any, and they must chose with... yet another command ("py")! pipenv just bypass that by assuming you want a virtualenv, and be able to access it. It's a very good call.
- pip install --user will create commands you can't use unless you edit your PATH. This makes newcomers go mad.
- scrollaway 8 years agoOh my god, you've described every single one of my issues with Python packaging.
The whole setup.py/setup.cfg situation really is ridiculous. Having to import the __version__, read() the README, no markdown support on pypi, MANIFEST / MANIFEST.in files, tox.ini, what a mess.
- schlumpf 8 years agoThis. Particularly the need for a minimum standard project structure.
Pipenv shows its pedigree and looks like a great tool...that also overlaps significantly with conda. What are the use cases that Pipenv addresses better than/in lieu of conda?
- StavrosK 8 years agoI kind of want to take your list and write a tool that fixes (or, at least, automatically works around) all of these issues. Good job.
- kyrias 8 years agoI agree with almost all of this, but...
> - you can't easily move virtualenvs;
`virtualenv --relocatable`, though it's weird that it's not the default, yes.
- annnnd 8 years agoNice list! We manage to avoid most problems with distribution by using Docker containers, but it brings its own set of problems and downsides. I would love to have a better solution!
- brbsix 8 years ago
I'm not sure whether it qualifies as easy, but you can use virtualenv-mvyou can't easily move virtualenvs
- Diederich 8 years agoHonest question: have you seen how the Perl world handles this stuff? Now that I've mostly moved over to Python, the Perl experience (overall package mgmt) seems much, much better.
Note, it doesn't feel terrible in Python land, to me at least. But it was almost a joy working with Perl's packaging system.
- crdoconnor 8 years ago>One things is a good dependency management. Right now if you want to upgrade your Python version, or one of your packages, it's a mountain of manual work. There is nothing in the stack helping you with the dependency graph.
There's pip-tools.
- renesd 8 years agoNice list of warts.
- scrollaway 8 years ago
- Kaizyn 8 years agoPip is built on top of setuptools/distutils, so you are using them without even knowing it.
- yjftsjthsd-h 8 years agoNot atypical; I'm pretty sure apt uses dpkg, and dnf and yum use rpm underneath.
- yjftsjthsd-h 8 years ago
- sametmax 8 years ago
- sametmax 8 years agoI strongly agree but this can work now and is a big improvement over what we currently have. So while I would literally pay to see somebody work on a better package manager (which can generate exe, deb and use a conf file indead of .py), this is a good filler.
- X-Istence 8 years agoWhy should it generate a deb file? How is this useful on anything but Debian based systems?
Why exe? How do you package libraries using this new tool you are envisioning?
- sametmax 8 years agoYou do package lib the same way as before, although cargo like dependency handling would be a nice thing. Especially for upgrades.
But a good package manager should ALSO allow you to produce a:
- a stand alone executable for most OS.
- a standard package for major OS (msi, deb, snap, rpm, dmg, etc).
Doing that right now with Python requires you to setup stuff like nuikta and the like. It works but it's much harder than it should be.
- sametmax 8 years ago
- X-Istence 8 years ago
- ploggingdev 8 years agoJust curious, what aspects of pip/virtualenv specifically do you find subpar in comparison to other languages' package managers.
- cderwin 8 years agoI would look at this comment[0] by sametmax for a critique of pip. My main gripe with virtualenv is that it's required at all: other interpreted languages, like node and elixir for example, have figured out how to handle non-global dependencies without a third-party package. Beyond that, it's frustrating to deploy because its non-relocatable (in our build/deploy scripts at my last python job we had to use sed all over the place to fix paths), and I find it semi-annoying to have a bunch of different copies of interpreter and all that goes with it (though this is mostly a minor annoyance -- it doesn't take up that much space and it doesn't matter if it gets out of sync.
Also notable, IMO, is the lack of a tool like rbenv or rustup for python. I can't tell you how many times I have had to try to figure out which python version a given pip executable worked with.
- rplnt 8 years ago> like node [...] have figured out how to handle non-global dependencies
Node would be the last place I'd look for a good solution in. Not sure if there was some progress recently, but it was hell some time back. Modules were huge, taking thousands of other modules with them, majority of those being duplicates. There was no deduplication, no version wildcards I believe either. It wouldn't even work with some tools because the path would end up being hundreds of characters long.
- brennebeck 8 years ago> Also notable, IMO, is the lack of a tool like rbenv or rustup for python
Does pyenv not meet your needs there?
- crdoconnor 8 years ago>it's frustrating to deploy because its non-relocatable
I've tried relocating node_modules. It's a recipe for pain and tears.
I don't see why it's a big problem that virtualenv is a package rather than built in.
I also haven't had much of a problem with virtualenv not being relocatable. If you want it somewhere else, just build it there.
>Also notable, IMO, is the lack of a tool like rbenv
Ummmmm the creator of rbenv also created pyenv.
- catdog 8 years ago> Beyond that, it's frustrating to deploy because its non-relocatable (in our build/deploy scripts at my last python job we had to use sed all over the place to fix paths)
pip does cache the wheels so instead of moving the virtualenvs around, just recreate them. This also ensures the virtualenv is up to date. Using tox this is fairly easy to do.
Sure virtualenv is a bit of a hack but it's not that bad.
- kyrias 8 years ago> My main gripe with virtualenv is that it's required at all: other interpreted languages, like node and elixir for example, have figured out how to handle non-global dependencies without a third-party package.
venv is in the stdlib since 3.3. (Though I agree with the annoyance at the need.)
- jjawssd 8 years agopyenv
- rplnt 8 years ago
- bge0 8 years agoI actually really love `Cargo` : the rust package manager.
- cderwin 8 years ago
- barbs 8 years agoAll you've said here is "python packaging sucks", with no explanation why, and with no alternative. Not a substantial comment, and I'm disappointed that it's been voted to the top.
I'd ask for your reasoning but it seems sametmax has done a good job of that for you:
- jessaustin 8 years agoComments that make a single unambiguous point are fine. It's no problem to leave detailed support to replies.
A more controversial statement with the same content probably wouldn't have been voted up, but thread parent is objectively true even though it doesn't contain its own proof.
- jessaustin 8 years ago
- 8 years ago
- ellisv 8 years agoI don't disagree but your suggestion sort of reminds me of this xkcd: http://xkcd.com/927/
- edblarney 8 years ago"This is great, but sometimes I think that python needs a new package manager from scratch"
Ha, that's what I came here to say!
Or better - a new packaging paradigm.
Maybe it's extremely uncool to say ... but I think Java still has the best packaging paradigm of all languages. Jars rule. Of course 'gradle' is kind of a confusing mess so they don't have dependencies worked out very well ...
Nevertheless I do feel that Python's packaging and dependency/versioning woes create a much bigger systematic problem than many realize.
Kudos to the author though ...
- renesd 8 years ago
- shakna 8 years ago> I wrote a new tool this weekend, called pipenv.
> It harnesses Pipfile, pip, and virtualenv into one single toolchain. It features very pretty terminal colors.
For a weekend project, this has some very nice things.
Which removes the need for me to run my own project that basically does these things... In more or less, a worse way.
Everything I've come to expect from Reitz, and hopefully it'll gain some decent ground like other projects of the same author.
- therealmarv 8 years agoFor people who want to do it right without using an additional tool read this: setup.py vs. requirements.txt by Donald Stufft https://caremad.io/posts/2013/07/setup-vs-requirement/
- yeukhon 8 years agoI gave up populating requirements in setup.py. I just use multiple requirements.txt. This article has been debated for years already and there is absolutely no right / wrong.
- yeukhon 8 years ago
- kalefranz 8 years agoHey everyone. I'm Kale, currently the lead developer on the conda project. It's been mentioned a few times in this thread, and I just want to make sure that any questions about it are answered accurately. Feel free to ask me anything about product conda. Thanks!
- renesd 8 years agoNeat. Now for questions and comments.
Often people have a requirements.live.txt, or other packages depending on the environment. Is that handled somehow? Can we use different files or sections? [ED: yes, different sections]
Still wondering to myself if this is worth the fragmentation for most people using requirements.txt ? Perhaps the different sections could have a "-r requirements.txt" in there, like how requirements.dev.txt can have "-r requirements.txt". [ED: the pipfile idea seems to have quite some people behind it, and pip will support it eventually. Seems it will be worth it to standardise these things. requirements.txt is a less jargony name compared to Pipfile though, and has a windows/gui friendly extension.]
Other tools can set up an environment, download stuff, and run the script. Will pipenv --shell somescript.py do what I want? (run the script with the requirements it needs). ((I guess I could just try it.)) [ED: doesn't seem so]
Why Pipfile with Caps? Seems sort of odd for a modern python Thing. It looks like a .ini file? [ED: standard still in development it seems. TOML syntax.]
With a setup.py set up, all you need to do is `pip install -e .` to download all the required packages. Or `pip install somepackage`. Lots of people make the setup.py file read the requirements.txt. Do you have some command for handling this integration? Or is this needed to be done manually? [ED: seems no considering about this/out of scope.]
Is there a pep? [ED: too early it seems.]
- kenneth_reitz 8 years agoCheck out https://github.com/pypa/pipfile for more info. The format is TOML. It is mainly intended for deployments (e.g. web applications)
- renesd 8 years agoThanks.
- kenneth_reitz 8 years agoAlso `pipenv install -r requirements.txt` is supported, for importing.
- kenneth_reitz 8 years ago
- renesd 8 years ago
- kenneth_reitz 8 years ago
- conradev 8 years agoI'm surprised that no one has mentioned pip-tools: https://github.com/nvie/pip-tools
It's a very similar set of tools. I use pip-compile which allows me to put all of my dependencies into a `requirements.in` file, and then "compile" them to a `requirements.txt` file as a lockfile (so that it is compatible with pip as currently exists).
This looks great, though, I'm excited to check it out!
- FabioFleitas 8 years agoWe use pip-tools on all our Python projects and it works great. I believe the requirements.in compiled to requirements.txt approach is much more sane and less error-prone.
- FabioFleitas 8 years ago
- throw2016 8 years agoI think an app should not expose end users to its dependencies. That leaves the end user with a lot of pain figuring out versions of dependencies and god forbid you need to compile some dep then you need a build environment and its dependencies any of which can fail in this chain leaving a very unpleasant and even hostile end user experience.
Ruby and Node apps are particularly guilty of this pulling in sometimes hundreds of packages some of which need compilation. Compare that to a Go binary which is download and use. These things can get very complicated very fast even for developers or system folks let alone end users who may not be intimately familiar with that specific ecosystem.
- choxi 8 years agoIs this like Ruby's Bundler for Python? I've just been getting into Python and am really glad to see this, thanks for creating it!
- igravious 8 years agoVery similar. I think Pipenv improves on Bundler by leveraging Virtualenv and Ruby doesn't have a per project equivalent to Virtualenv that I'm aware of. You can set the path config variable of Bundler to not place the project Gems in a central location which I think is cleaner and try to remember to always do now.
It would be _super_ interesting if the Python and Ruby communities got together to harmonize every last detail of their packaging toolchain. Who is in?
- sametmax 8 years agoActually we could also learn from:
- the JS community. npm dependancy graph, webpack resolver and yarn performances;
- the rust community like with cargo.
- K0nserv 8 years agoBundler does proper dependency resolution using Molinillo[0] which is also used by CocoaPods[1]. This is definitely something that other package managers can stand to adopt.
0: https://github.com/CocoaPods/Molinillo 1: http://cocopods.org/
- K0nserv 8 years ago
- mhw 8 years ago> Ruby doesn't have a per project equivalent to Virtualenv that I'm aware of.
The nearest equivalent is to place a file called '.ruby-version' in the top level directory, containing the version number of the Ruby you want to use. Version numbers come from https://github.com/rbenv/ruby-build/tree/master/share/ruby-b.... rbenv, chruby and rvm all support .ruby-version.
One difference from virtualenv is that the Ruby version managers share single installations of each version of Ruby. My understanding from occasional use of Virtualenv is that it copies the python installation into a new per-project subdirectory, which seems a bit wasteful to me.
> You can set the path config variable of Bundler to not place the project Gems in a central location which I think is cleaner and try to remember to always do now.
Yes, this is what I do. It gives me a shared 'clean' Ruby installation of the right version, plus a project-specific copy of all the gems the project depends on. To me this provides the best trade off between project isolation and not duplicating the whole world. You can set bundler up so this is done automatically by creating '~/.bundle/config' containing
(The BUNDLE_PATH one is the important one; see 'bundle config --help' for other options.)--- BUNDLE_PATH: "vendor/bundle" BUNDLE_BIN: ".bundle/bin"
- igravious 8 years agoGreat to here you also do what I do with the path config variable. I was just reading the documentation and Bundler has an opinion about deployment as well. I must look into that. I will also start making sure I am using/setting .ruby-version .
- pkd 8 years ago> It gives me a shared 'clean' Ruby installation of the right version, plus a project-specific copy of all the gems the project depends on
You can also accomplish the same using gemsets which are provided by rvm.
- igravious 8 years ago
- sametmax 8 years ago
- uranusjr 8 years agoWithout some shim like bundler exec, but yeah, you can say that.
- igravious 8 years ago
- gourneau 8 years agoHey other Reitz fans. Make sure to check out his newish podcast series: https://www.kennethreitz.org/import-this/
- olejorgenb 8 years agoSeems to be a python specific nix-shell like tool?
With nix[OS] you just run `nix-shell -p python[2,3] python[2,3]Pacakges.numpy ...` to get an environment with the required packages.
Of course this requires that the python library is packaged in nix, but in my experience the coverage is quite good, and it's not very hard to write packages once you get the hang of it.
It also possible (but currently a bit clumsy in some ways) to set up named and persistent environments.
- command_tab 8 years agoSee also: https://github.com/pypa/pipfile
I'm glad to see Python getting the same attention as other modern package managers. This is all great work!
- caconym_ 8 years agoI will definitely be trying this out. Python version and package management is a dumpster fire that wastes gobs of my time on the regular. I'll try anything that promises to end the pain.
- istoica 8 years agoFinally someones does it! I was using: pip -t .pip in my code, avoiding virtual-env completely, but that was not enough and incomplete.
As this is not cross platform and it would be nice to switch between Linux/Windows while coding to maintain platform compatibility, can the virtualenv envs be created with a os platform & subsystem prefix ? for example, having multiple envs at once:
- env/posix/bin/activate - env/nt/Scripts/activate.bat
- zoul 8 years agoI always wonder if this could be done once and for all languages, instead of Ruby making bundler, Haskell Cabal sandboxes or stack, Perl Brew, etc. Is this where Nix is going?
- HeyImAlex 8 years agoI don't know, different languages and environments need different things. I'm not sure that "package management" is as generic as it seems at first glance.
- toyg 8 years agoYou make it one tool, and sysadmins will instantaneously lock it down. These package managers, in most cases, are developer tools built to get around system-wide locks on libraries; the more you centralize them, the more likely it is they will get locked down, and then someone will build tools to get around that, and so on and so forth.
- olejorgenb 8 years agoAs one of the few package mangers, nix can be used without root access.
- olejorgenb 8 years ago
- olejorgenb 8 years agoIn some way, absolutely.
You can easily get a nice isolated python environment with some packages in nix without using pip, pyenv, etc. `nix-shell -p python pythonPackages.numpy ...`
So far I think it works quite well for most languages as long the needed packages are in nixpkgs.
Some of the tooling could be better, but the underlying model seems sound.
I'm not really convinced language-specific package managers are needed. Nix isn't perfect yet, but it has come a long way.
- HeyImAlex 8 years ago
- jaybuff 8 years agoSee also, pex: https://www.youtube.com/watch?v=NmpnGhRwsu0
- nejdetckenobi 8 years agonormally I use virtualenvwrapper and that makes a virtualenv directory for all virtualenvs you create with it. before that, I always create my projects' venvs inside my project hierarchy.
I had a dilemma about it. But after all, you can not move your venv directory unless you use `--relocatable` option. So, anyone have a strong argument about creating venvs inside your project directory?
- icebraining 8 years agoI've always found the whole virtualenv stuff so superfluous. Do we really need all the machinery with shell scripts and static paths?
We just use a directory where we keep our dependencies. It's a matter of:
From what I can tell, this accomplishes everything a venv does (except bringing the Python interpreter itself along) without requiring any extra tools or conventions to learn.mkdir libs pip install -t libs <package> # then to run PYTHONPATH=libs python app.py
- istoica 8 years agoAs you pasted-it, it does not accomplish venv:
A more proper command: - pip install -t ./libs --install-option="--install-scripts=./bin"- you still need to change PYTHON_PATH to recognize libs from `libs` - packages have bin scripts sometimes that most likely, will be needed by the project
But still, does not solve the PYTHON PATH issue, it won't be solvable because all python cli tools and all scripts in ./bin must be aware of PYTHON_PATH including ./libs
This is what venv does and pip alone cannot easily solve, replicating an entire python environment that is aware of project local pip packages
- icebraining 8 years agoMy commands do set PYTHON PATH when running the app.
As for the cli tools, fair enough, but the packages I use with such tools/scripts are full applications, not dependencies to be included in another project. Which kinds of packages do you see as both dependencies and containing CLI tools?
- icebraining 8 years ago
- sametmax 8 years agoNo, you still don't have:
- ./bin. No commands for you.
- a way to specify your libs to a program not providing a way to set env var.
- isolation from the system stdlib. This will cause subtile bugs.
- a clean pip freeze. No deps listing.
- and hence a lock file.
- istoica 8 years ago
- toyg 8 years agoI just keep venvs in the project folder and add them to .gitignore. --relocatable never worked well for me, I just keep my requirements.txt up to date so it's trivial to blow away a venv and recreate it if necessary (python3 -m venv env && source env/bin/activate && pip install -r requirements.txt).
I find tools like virtualenvwrapper and this one from Kenneth tend to solve issues I don't really have. A little bit of repetitive typing here and there is ok to burn knowledge into my mind; and less leaky abstractions I have to deal with, the better.
- sametmax 8 years agoIt solves more than that:
- beginers don't have to understand the whole virtualenv shenanigans. I use pew myself to replace virtualenvwrapper but I will switch to pipenv just to ease the pain of team member joining in.
- it enforces good dependency management practice with the toml file and lock file. This is an issue in almost all project I worked on, including ones from Python experts. We all use only requirements.txt file out of convenience, and never lock.
- it's one tool to do all the packaging stuff. No need for pip and virtualenv and a wrapper. You got one command.
- sametmax 8 years ago
- icebraining 8 years ago
- sametmax 8 years agoI was really not a fan of the last "made in Reitz" project Maya. But this, I really can get along.
The whole things make it way easier to get started for a beginner. Now more activate. No more wondering about virtualenv. Automatic lock files are great since no project I know of use them since they are not well understood.
It's like node_packages (easy and obvious), but cleaner (no implicit magic).
Like.
- georgeaf99 8 years agoLinkedIn has a similar open source project that is much more mature. It builds on Gradle features to manage complex dependencies and build Python artifacts. If you include this LinkedIn Gradle Plugin [1] you can automatically run tests in a virtual env and source a file to enter the project's virtual env.
PyGradle [2]: "The PyGradle build system is a set of Gradle plugins that can be used to build Python artifacts"
[1] https://github.com/linkedin/pygradle/blob/01d079e2b53bf9933a...
- helb 8 years ago> --three / --two Use Python 3/2 when creating virtualenv.
I use Python 2.7, 3.4, and 3.5 on various projects. Is there a way to choose between 3.4 and 3.5 using Pipenv? I'm using something like this with virtualenv:
$ virtualenv -p `which python3.5` .venv
- iheredia 8 years agoJust a comment. Your command is equivalent to
$ virtualenv -p python3.5 .venv
- emeraldd 8 years agoIs that true? His command would evaluate the path at the time which is run, but yours seems to evaluate the path at the time python3.5 is run. Subtle, but very different results.
- kyrias 8 years agovirtualenv resolves the interpreter when you run virtualenv, and if you specify a different interpreter with `-p` it will resolve the path to the interpreter and then run virtualenv again using it.
- kyrias 8 years ago
- emeraldd 8 years ago
- jjawssd 8 years agoNo, but you could be using pyenv instead of the system package manager because it is far cleaner
- iheredia 8 years ago
- dvl 8 years agoWhy people are trying to complicate things? requirements.txt are much simpler and better.
- sametmax 8 years agoFirst, you need to take care of the virtualenv manually. This tool avoid that. You can completly ignore the virtualenv. You don't even have to populate requirements or learn about pip freeze.
Secondly, this tool allow you to freeze your requirement list at specific versions. So in your req file, you have the name of the packages you depend on. Bon on the req lock, you get all the pulled dependencies recursively with the version you are using right now. The first one let you dev more easily. The second one deploy more easily.
All that, for less complexity. Win win.
- sametmax 8 years ago
- 8 years ago
- wyldfire 8 years agoI haven't really used requirements.txt because I found that I could install 'extra' and 'test' specific content based on args to setup() in my setup.py. It seems more like the Right Thing than requirements.txt, from what I can tell.
At first glance, this doesn't seem to offer anything beyond what I already see from setup(). What am I missing?
It's unfortunate that CPython gave us distutils and took a very long time to converge on a built-in successor (setuptools?) that gives the right composability.
- noway421 8 years agoThis is very interesting! I had exact same question how to do it in python just a while ago! http://stackoverflow.com/questions/41427500/creating-a-virtu...
Glad that someone thought about similar thing and made a tool to solve it!
- JeremyBanks 8 years ago> Otherwise, whatever $ which python will be the default.
This is a bit strange because the python binary is always supposed to be Python 2. The Python 3 binary is supposed to be named python3. Some distributons don't follow this, but they're the weird non-conformant ones; it's not a behaviour that should really be relied on.
- jacobmischka 8 years ago> always supposed to be Python 2
This is not correct. It's a symlink to python2 on systems that rely on calls to python to be python2. On modern systems, python is usually a symlink to python3. This is the case on Arch Linux and I believe other recent distro releases.
- JeremyBanks 8 years agoArch is the oddball. I'm not aware of anybody else who's made the switch.
Given that they're not mutually compatible except in rare cases, it's a very silly thing to do. You can upgrade GCC with the same name because you know it will handle most of the same input. If you do that with Python you're breaking tons of existing scripts for very close to zero benefit. Why would you do that?
- jacobmischka 8 years agoIt's not silly. One of Arch's primary draws is being the first to get updates and integrate new technologies. Other distros will follow soon enough if there really aren't any others.
It's not as if python2 suddenly doesn't exist, it's not terribly life-changing to add a 2 in the places where the scripts are still on the last version.
I'm glad to be on a system where the default Python version isn't one that will be officially unsupported in three years.
Edit: It's worth pointing out that this switch was made 6 years ago and the world is still spinning.
- baq 8 years agoI'm pretty sure Ubuntu 16.04 is Python 3 by default and you have to ask for 2.
edit: nope, been imagining things. too much time in venvs i guess. need to get more sleep :)
- jacobmischka 8 years ago
- JeremyBanks 8 years ago
- kyrias 8 years agoNon-conformant? PEP-394 says that scripts should only use python in the shebang if it's compatible with both py2 and py3, and be updated to work with both, or to use python2 otherwise.
- JeremyBanks 8 years ago
- JeremyBanks 8 years ago
- jjawssd 8 years agoIsn't `python` in Ubuntu a Python 3?
- anuragsoni 8 years agoNot yet. At least on ubuntu 16.10 python still defaults to `python2`
- anuragsoni 8 years ago
- jacobmischka 8 years ago
- mikhuang 8 years agoUninstall by default removing everything seems a little scary. Otherwise looks really neat, looking forward to trying it
- bdukic 8 years agoI wanted to comment on the same thing, IMHO something like `pip uninstall --all` would be a better choice. Great work otherwise!
- bdukic 8 years ago
- therealmarv 8 years agoCurrently using fish and virtualfish. This seems incompatible to non bash shells. Did somebody tested?
- kenneth_reitz 8 years agoFish support was just added!
- kenneth_reitz 8 years ago
- btashton 8 years agoInteresting. I have been leveraging tox to provide a lot of what this seems to give you, but it certainly has been more of a hack than a solution.
- natmaster 8 years agoThis is cool - it's like yarn for python! :)
- zyxzkz 8 years agoWhat took Python so long to get a tool like this?
- lukasm 8 years agoDid anyone had a problem installing in on El Captain? I manage to do it with --user flag but the pipenv command doesn't exist.
- zephyrfalcon 8 years agoA bit off-topic, but what font is used in the video/animated GIF?
- kenneth_reitz 8 years ago
- kenneth_reitz 8 years ago
- auston 8 years agoI can only express my gratitude, thank you Kenneth!
- korijn 8 years agoWindows support?
- kenneth_reitz 8 years agocoming soon, hopefully via pull request!
- kenneth_reitz 8 years ago
- joelbondurant 8 years agoHas anyone in the Python community heard of Docker?
- mulla111 8 years ago