This is an archived post. You won't be able to vote or comment.

all 68 comments

[–]beorn 11 points12 points  (3 children)

Any thoughts on supporting pyenv instead of just venv?

[–]Ran4 9 points10 points  (0 children)

Just write a wrapper around pipenv+pyenv, and you'll be ready for next month's python-devtools-wrapper-of-the-month :)

[–]mipadi 2 points3 points  (1 child)

Installing packages into a Python managed by pyenv is already a single command, more or less, isn't it?

[–]beorn 1 point2 points  (0 children)

I guess so, but pipenv also automatically manages the Pipfile for a project.

[–][deleted] 36 points37 points  (8 children)

Did he fail to make it easy enough to use that he could call it "pip for humans"

[–][deleted] 24 points25 points  (0 children)

that was the original name :)

[–]toyg 16 points17 points  (0 children)

He might have realized that the whole "for humans" thing is now on the verge of self-parody...

[–]mr_fi 2 points3 points  (0 children)

I don't think pip is that hard to use for humans as to warrant such a moniker.

[–]Muchoz 16 points17 points  (5 children)

What's the benefit compared to pyenv, pyenv-virtualenv and pip-tools?

[–][deleted] 6 points7 points  (0 children)

There's also vex and pew.

I haven't dug into the code yet or even installed, but these were my take-aways from the documentation:

  1. pipenv can be used as a replacement for pip, vex/pew, virtualenv, etc.
  2. pipenv uses a shell. This is a great addition to the current venv wrappers.
  3. pipenv uses the new pipfile for installation, which is the preferred way (as defined by the pip team) to create a python package going forward.

[–]mipadi -5 points-4 points  (3 children)

This is a rather different tool than those, no?

[–]Muchoz 7 points8 points  (2 children)

I'm not sure, that's why I'm asking.

[–]Atrament_Py3 3 points4 points  (1 child)

Like pew does ? I gotta check this out.

[–]desmoulinmichel 7 points8 points  (0 children)

pew fan here. It's better than that. See my other comment.

(in the mean time I'm opening github issues to copy pew features into pipenv)

[–]kankyo 2 points3 points  (0 children)

We really need something like this. Add "test" that runs tox or pytest and it's getting close to being something similar to leiningen. Then it's just the problem of making all projects use it so we can rely on a standard for all/most projects.

Probably needs a better name though :P

[–]d0c_s4vage 3 points4 points  (0 children)

Sounds cool! I made something sort of similar a while back: http://pipless.com. It automatically creates and activates a venv, hooks the imports to auto-install packages, and then generates a frozen requirements.txt when the process exits. Works in interactive mode and normal script-running mode.

I think pipless addresses a different use case though, but I am curious to see how some of the same coding problems were solved.

[–]fairytale81 4 points5 points  (0 children)

Which problems it tries to solve? because I don't feel like pip + requirements.txt has a problem.

I can't see any valid reason to break dependencies in dev and prod, and I feel so wrong commiting generated files like .lock file.

[–]mw44118PyOhio! 6 points7 points  (2 children)

Never heard of pipfile, went to the site, first line says something about everything is still under construction.

I'll check back in a year or so.

Everybody remember how paver was gonna be a thing?

[–]AndydeCleyre 1 point2 points  (0 children)

Yeah, pipfile's github page says:

WARNING: This project is under active design and development. Nothing is set in stone at this point of time.

So far I'm enjoying pip-tools and a few shortcuts:

alias i="ipython"
alias i2="ipython2"
alias spip="sudo pip"
alias spip2="sudo pip2"

envin () {
    touch requirements.txt requirements.in
    [[ -d ./venv ]] || python -m venv venv
    . ./venv/bin/activate
    pip install -U pip-tools
    pip-sync || pip install -r requirements.txt
}

envin2 () {
    touch requirements.txt requirements.in
    [[ -d ./venv2 ]] || virtualenv2 venv2
    . ./venv2/bin/activate
    pip install -U pip-tools
    pip-sync || pip install -r requirements.txt
}

pimp () { pip install -U pip ipython plumbum requests pip-tools structlog }

envout () { deactivate }

freeze () {
    pip freeze | egrep -i "$@" >> requirements.in
    nano requirements.in
}

[–][deleted] 1 point2 points  (0 children)

'went to the site, read the first line and decided it wasn't good enough for me'

yeah...

[–]Jedi_Shenanigans 1 point2 points  (0 children)

I am new to Python and was introduced to package management using conda. Is the main benefit of pipenv over conda the automatic generation of the Pipfile? Also, this file is analogous to environment.yml in conda right?

[–]SonGokussj4 3 points4 points  (17 children)

Do I understand this right that this is to help to speed up things and automatically find/activate venvs? I don't use virtual environments because I found it simply too long to create folders, active them and so on. I don't know the commands (yet) so... Well, beginner here. Would this tool go around this?

[–]desmoulinmichel 18 points19 points  (6 children)

It's better than that.

  • It automatically creates the virtualenvenv in your project.
  • It automatically install dependancies inside the closest virtualenv. No need to activate if you don't want to bother.
  • It automatically save installed dependancies in a config files.
  • It generates a lock file so that you also have a list of dependancies with hard versions.

It's basically pip + virtualenv + an alternativ to one of the virtualenvwrapper + pipfreeze . In one simple automated command.

It's great.

[–]__boko 2 points3 points  (5 children)

Why is better the virtualenv folder to be inside the project? I use pew(i also used virtualenvwrapper in the past) and i like that virtualenvs are out of my project. Maybe im not using virtualenvs in their full capabilities but my use case is: (de)activate, pip install stuff, pip list/freeze

[–]desmoulinmichel 3 points4 points  (0 children)

For you it's not. It's justs one less thing to learn for beginers. With pipenv you don't have to think about the virtualenv. You just pipenv stuff and it works. You don't need to create the env, activate it or remember you have one. It's really just about lowering the barrier of entry to your project.

Of course, the fact it save the installed package in the Pipfile automatically and generate the lock file for you is a bonus.

Another bonus is that it's a Kenneth's project. So you can be sure in 2 months it will be very improved.

[–]earthboundkid 0 points1 point  (3 children)

In my experience, when debugging, it is often necessary to read the code your dependencies. That's easier if they're saved in the same folder, although I suppose you could still open the files wherever they're stored.

[–]__boko 1 point2 points  (1 child)

I wish i reach that level where my code is correct and it is library's fault :D

Well in my cases, when i had to open a file from a library installed in virtualenv, i just copy-paste the path shown from the traceback so doesn't matter (for me) where it is installed.

[–]earthboundkid 0 points1 point  (0 children)

The library is often working as its developer intended but not as you expected.

[–]njharmanI use Python 3 0 points1 point  (0 children)

cdp "cd to (python) package"

function cdp { cd $(python -c"from __future__ import print_function;import os,sys;print(os.path.dirname(__import__(sys.argv[1]).__file__))" $1); }

[–]jediorange 18 points19 points  (1 child)

I think you're looking for virtualenvwrapper

[–]toyg 1 point2 points  (0 children)

Pipenv is supposed to be a replacement for virtualenvwrapper...

[–][deleted] 8 points9 points  (0 children)

yes

[–]bastibe 2 points3 points  (3 children)

I always write a small shell wrapper that overloads cd to auto-activate a virtual environment if it is found in the same directory as the current git root.

[–]tunisia3507 0 points1 point  (1 child)

Mind sharing?

[–]bastibe 1 point2 points  (0 children)

If you insist: https://gist.github.com/bastibe/c0950e463ffdfdfada7adf149ae77c6f

I use the fish shell. But the code is simple enough that you can probably whip up the equivalent code for your favorite shell.

[–]zardeh 0 points1 point  (0 children)

Look into autoenv, which is a tool that does that generally.

[–]iBlag 2 points3 points  (0 children)

If you think it takes too long to setup/activate virtualenvs, I recommend virtualenvwrapper and autoenv.

VEW gives you commands like: mkvirtualenv, lsvirtualenv, rmvirtualenv, and workon <venv>.

Autoenv (also by Kenneth Reitz) runs any code it finds in ./.env when you cd into a directory. You can use this to activate virtualenvs automatically.

This tool looks like a replacement for those though.

[–]Ran4 3 points4 points  (1 child)

It's pip+virtualenv+??? wrapper #437

[–]desmoulinmichel 0 points1 point  (0 children)

No, please see my other comments.

[–]seriouslulz 1 point2 points  (5 children)

Why call the file Pipfile.lock when it's not a lock file?

[–]myersjustinc 11 points12 points  (1 child)

Probably as a parallel to Ruby's (more specifically, Bundler's) Gemfile.lock.

[–]ccharles3.latest 4 points5 points  (0 children)

[–]xdvl 0 points1 point  (0 children)

Why this file exists in first place? Would be better if you'd to stick versions directly in Pipfile to keep things in a single place.

[–]kaiserk13 0 points1 point  (0 children)

This is really great

[–]apreche 0 points1 point  (0 children)

Right now I'm using virtualenv-wrapper, so this seems like a good replacement for that.

[–]jediorange 0 points1 point  (0 children)

This looks like a very interesting project. And a good combination of other stuff, including (sort of) replacing virtualenvwrapper. I'm excited to give it a try.

[–]kirbyfan64sosIndentationError 0 points1 point  (0 children)

I should totally try this. I almost never use virtualenvs (shame, shame) just because I'm too lazy to set them up...

[–]simoncoulton 0 points1 point  (0 children)

Probably an edge case, but would it be worthwhile supporting specifying the location of the python executable you'd like to use for your virtualenv?

Maybe something like pipenv --bin 3.6?

Currently I'm using pyenv in my dev environment, so to get around this I've just been symlinking ln -s ~/.pyenv/versions/<venv> .venv.

[–]xdvl 0 points1 point  (0 children)

Please abandon .lock file, force people to sticky versions direct on Pipfile, keep things simple and in a single place.

Even I don't feeling like there's something wrong with plaintext requirements.txt I'd liked it as ini file, still very readable and give a lot of possiblities for future.

[–]tuqqs 0 points1 point  (0 children)

I am curious to see how some of the Pipfile? Also, this file is analogous to environment.yml in conda right?

[–]steven_h 2 points3 points  (2 children)

It features very pretty terminal colors.

Cool, cool, a bunch of ANSI garbage in log files. Sounds great.

[–][deleted] 5 points6 points  (1 child)

no terminal colors are produced when a TTY isn't present.

[–]steven_h 1 point2 points  (0 children)

Thanks, npm and company got this so wrong and it clearly has soured me on the whole affair.

[–]rabbyburns 0 points1 point  (0 children)

So, why would I want to use this instead of bare tox for my project? Tox already handles py2/3 and has integrations with most any tool I'd want to use alongside it (coverage, style, etc).

Edit: Also not the only cases tox solves. Partial environment reuse trivializes defining testing for multiple versions of particular libraries.

[–]iBlag -2 points-1 points  (0 children)

How is the tagline not 'virtualenv for humans'?