Pipenv: Support running via `-m`

Created on 23 Feb 2018  Â·  29Comments  Â·  Source: pypa/pipenv

It would be great if python3 -m pipenv worked in order to support Windows users better as neither pipsi nor --user installs are accessible by default. As it currently stands there's a message about pew needing to be on the PATH, although there's an environment variable called PIPENV_VENV_IN_PROJECT which doesn't seem to have a corresponding command-line flag (I also didn't think to test if this removed the pew warning before leaving work today).

Type

Most helpful comment

merged :)

All 29 comments

Please see this comment -- you need to call pip via python3 -m in the first place because you haven't configured your %PATH% environment variable, as the error message indicates.

I think making things work with -m is good architecture in general though, whether or not there are alternatives. This would also work around the current workaround we have with the pipsi installation that pipsi install pew is required. [sys.executable, ‘-m’, ‘pew’] would always work as long as pew is installed during Pipenv’s installation (it is with the current setup).

This would require pew to work that way first.

@uranusjr I am far from an expert with regard to this aspect of our implementation so I will reopen for now

Do you have a clear understanding of what is preventing pew from working this way?

It needs to add a if __name__ == '__main__': block somewhere, and call the program’s entry point in it. This is how Pipenv does it.

pew’s entry point is pew.pew:pew, judging from its configuration in setup.py, so one possible implementation would be to add a __main__.py with

from .pew import pew
if __name__ == '__main__':
    pew()

@uranusjr ah I thought you were saying there was something more significant

You should submit a PR upstream!

I have already too many things at hand. This is literally a three-liner but I just don’t want to go through the human part off submitting patches. Somebody please do that please? Pretty please? <insert cat gif here>

I can do it.
On Thu, Feb 22, 2018 at 6:26 PM Tzu-ping Chung notifications@github.com
wrote:

I have already too many things at hand. This is literally a three-liner
but I just don’t want to go through the human part off submitting patches.
Somebody please do that please? Pretty please?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/pypa/pipenv/issues/1474#issuecomment-367890447, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABhjq-P2yix1OxsIluLUdYLR1vXTTgs9ks5tXiHogaJpZM4SQOmP
.

And if @jtratner can't find the time I can try as well.

Requiring pew to be installed with the same version of python would be a pain — let's fall back to a system-available pew if -m pew doesn't work.

not necessary, just being thorough.

merged :)

waiting on a release

With the current release:

C:\Users\Dan.Ryan>pipenv --version
pipenv, version 11.0.2

C:\Users\Dan.Ryan>py -3 -m pipenv --version
pipenv, version 11.0.2

/cc @brettcannon

Thanks for the contributions all :fireworks:

@techalchemy Most operations (e.g. install, upgrade, run, shell) wouldn’t work though, unless you also expose the pew executable. That part requires a new Pew release to work.

this is not going to happen.

i experimented heavily with getting us to run pew directly, and it's just not feasible.

so, we're going to have to stick with subprocessing it out and expecting it to be in the PATH.

although, it's very fun to write pew.pew.pew()

I don’t mean running it directly, but with subprocess with python -m pew instead. This should be doable after berdario/pew#177 is released.

ah, i hadn't considered that!

So should this issue be re-opened to track calling pew with -m? Or should I open another issue?

Let’s just track it here.

:+1:

making this work anyway.

done

released

Sorry for holding this up 😞

No worries @berdario we included pew in our vendored packages within a few hours of my PR probably mostly to support the pew.pew.pew() invocation

Was this page helpful?
0 / 5 - 0 ratings