pipenv run does not support a --dev flag

Created on 24 Oct 2018  Â·  10Comments  Â·  Source: pypa/pipenv

Is your feature request related to a problem? Please describe.

pipenv shell and pipenv run creates a virtual environment automatically if one does not already exists. However, they do not install development dependencies by default. As such I have to run pipenv install --dev before using these commands. An example where I need to use pipenv run is in CI scripts as I do not have a tty.

Describe the solution you'd like

It would be ideal to be able to just run pipenv shell --dev or pipenv run --dev <command> in order to also install development dependencies.

Describe alternatives you've considered

My main wish would be that pipenv install (or pipenv shell or pipenv run <command>) actually installs development dependences by default. And that pipenv install --production would install all other dependencies. The reason for this is that most often to install into production you do that in CI scripts so it's easy to always have a --production flag there. However, in development many developers often forget to add the --dev flag and then gets confused as to why some module import does not work when running scripts. I see this problem all the time for colleagues new to Pipenv. This is due that in development the pipenv installation is a manual step.

npm does it the other way around and it feels more natural to just have to issue npm install where it also installs development packages.

Additional context

Add any other context or screenshots about the feature request here. It may be a good idea to mention that platform and Python version you are on.


$ pipenv --support

Pipenv version: '2018.10.13'

Pipenv location: '/project/python2.7.1/lib/python2.7/site-packages/pipenv'

Python location: '/project/python2.7.1/bin/python2.7'

Python installations found:

  • 2.6.6: /usr/bin/python
  • 2.7.1: /app/python/.sys/@sys/2.7.1/RHEL64/bin/python2.7
  • 2.7.1: /project/python2.7.1/bin/python2.7
  • 2.7.1: /app/python/.sys/@sys/2.7.1/RHEL64/bin/python
  • 2.6.6: /usr/bin/python2.6

    • 2.7.1: /project/python2.7.1/bin/python

PEP 508 Information:

{'implementation_name': 'cpython',
'implementation_version': '0',
'os_name': 'posix',
'platform_machine': 'x86_64',
'platform_python_implementation': 'CPython',
'platform_release': '2.6.32-642.6.2.el6.x86_64',
'platform_system': 'Linux',
'platform_version': '#1 SMP Mon Oct 24 10:22:33 EDT 2016',
'python_full_version': '2.7.1',
'python_version': '2.7',
'sys_platform': 'linux2'}

System environment variables:

  • PYTHONDONTWRITEBYTECODE
  • LAST_GIT_REPO
  • SHELL
  • PROJ_NR
  • MANPATH
  • LOG_DIR
  • VENDOR
  • PYTHONPATH
  • JAVA_TOOL_OPTIONS
  • HOSTNAME
  • ARC_ENV
  • MAIL
  • LS_COLORS
  • C_INCLUDE_PATH
  • SSH_ASKPASS
  • GROUP
  • LESSOPEN
  • MACHTYPE
  • CPLUS_INCLUDE_PATH
  • CVS_RSH
  • USER
  • LD_LIBRARY_PATH
  • EDITOR
  • tigPATH
  • RELEASE_MODULE
  • PIP_PYTHON_PATH
  • LS_OPTIONS
  • firefoxPATH
  • MODULEPATH
  • SSH_CONNECTION
  • KERNEL_CHECK
  • WRAPPERFORCEDOS
  • PIP_SHIMS_BASE_MODULE
  • LC_TIME
  • _LMFILES_
  • KERNEL_VERSION
  • REMOTEHOST
  • PKG_CONFIG_PATH
  • DEFGROUP
  • HOME
  • DISPLAY
  • LANG
  • LIBRARY_PATH
  • LMOD_SYSTEM_NAME
  • ARC_OS_DETECT
  • OSTYPE
  • CCHOME
  • SITE
  • HOST
  • LC_MESSAGES
  • SSH_TTY
  • LC_COLLATE
  • ARC_RELEASE
  • WINEDITOR
  • HOSTTYPE
  • PROJECT_MODULE
  • SSH_CLIENT
  • JENKINS_URL
  • LOGNAME
  • PATH
  • TERM
  • ARCRELEASE
  • COBBLER_SERVER
  • ARCPROJECT
  • CCASE_BLD_UMASK
  • SITE_DEF_CC
  • LOADEDMODULES
  • PWD
  • NPM_CONFIG_PREFIX

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /project/bin:/project/python2.7.1/bin:/project/npm-global-package/bin:/project/jre1.8.0_74/bin:/project/node-v8.9.1-linux-x64/global-packages/bin:/app/vbuild/RHEL6-x86_64/firefox/57.0.4:/app/python/2.7.1/RHEL64/bin:/app/vbuild/RHEL6-x86_64/git/2.12.2/bin:/app/vbuild/RHEL6-x86_64/git/2.12.2/libexec/git-core:/app/kdiff3/0.9.96/RHEL64:/opt/quest/bin:/home/yesbox/.afs/0/rbin:/home/yesbox/.afs/0/pbin:/home/yesbox/.afs/0/ibin:/usr/afsws/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/sbin:/sbin
  • SHELL: /bin/tcsh
  • EDITOR: emacs
  • LANG: en_US.utf8
  • PWD: /home/yesbox/repo

Contents of Pipfile ('/home/yesbox/repo/Pipfile'):

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[dev-packages]
beautifulsoup4 = "==4.5.3"
numpy = "==1.13.0"
pexpect = "==4.3.0"
pymongo = "==2.8"
pyyaml = "==3.12"
selenium = "==3.8.0"
svgpathtools = "==1.3.1"
svgwrite = "==1.1.11"
requests = "==2.19.1"

[packages]

[requires]
python_version = "2.7"

Contents of Pipfile.lock ('/home/yesbox/repo/Pipfile.lock'):

{
    "_meta": {
        "hash": {
            "sha256": "d591c5668468393c5cf404947d4808c1db7c35c78384f8d180693a72d8beebde"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "2.7"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {},
    "develop": {
        "beautifulsoup4": {
            "hashes": [
                "sha256:0a91347d5a4ab2196407ff4d3d758f2e712cae9bdfa3fd1eb0f83edea95e0d8d",
                "sha256:50e031957fe5d72c7ff6c10575d07b83a6462d12d12af03666b0dd1d9aa81c43",
                "sha256:b21ca09366fa596043578fd4188b052b46634d22059e68dd0077d9ee77e08a3e"
            ],
            "index": "pypi",
            "version": "==4.5.3"
        },
        "certifi": {
            "hashes": [
                "sha256:376690d6f16d32f9d1fe8932551d80b23e9d393a8578c5633a2ed39a64861638",
                "sha256:456048c7e371c089d0a77a5212fb37a2c2dce1e24146e3b7e0261736aaeaa22a"
            ],
            "version": "==2018.8.24"
        },
        "chardet": {
            "hashes": [
                "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
                "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"
            ],
            "version": "==3.0.4"
        },
        "idna": {
            "hashes": [
                "sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e",
                "sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16"
            ],
            "version": "==2.7"
        },
        "numpy": {
            "hashes": [
                "sha256:0c9c2da161951a041fc01ec1849555532122d6fd5b41144af81ae322e88bf0ef",
                "sha256:27b12b7412c6a1a6bdfd2142aa4c31ca54f0981d36fba787e4a92d4ff22d23a7",
                "sha256:2dc292415b18f08efe615c26b1567dd986006c47dd6b23c870db483db8e95015",
                "sha256:2f1ba22250725b1c719591a07d2146509aae5c620c43ecb9669a45487f7b9c89",
                "sha256:36d932daf153d41789a189e0c266877cd4f2b719a9f9b672e8c3586d01cf0643",
                "sha256:3ccd4f3176a6ca26fdfe31f4648af47a5ce0f681adc8321fe91e621dd26b7aae",
                "sha256:4e9756c9882836690c6cfad0ae3fae51050d78a5766d3e9ecc7a8385425fb92a",
                "sha256:560ca5248c2a8fd96ac75a05811eca0ce08dfeea2ee128c87c9c7261af366288",
                "sha256:5a9e42acf951c84d0fd349d677262d67b913fb399025e5885b7ade20b9a2ace9",
                "sha256:70c30db61dbc10dd5bcb63e830aa8c2ce993eb6821054abce372f04cd36f9bb5",
                "sha256:78ef0f0e2e1701a54555ecb7d2916375dcac462b6511d5cdb2de8a2f2296f501",
                "sha256:a61fd38d1ec67a5e3f0121522b3dddef4ba1407d175135447397cb8baec17860",
                "sha256:ad699f255fba63814f7d55f67c4bf315fb5496f5ba6e0799ed11b00e78bf464f",
                "sha256:ce7b3c0644c9157874d1323906c497c92296ae956e5cef0e4107e1ff55939386",
                "sha256:da0be0d25e845d65f540c92daa17b1bad06c3ed98a54840e6b980cb5d683647f",
                "sha256:dc703270f1caabbe361052ef678d5a5f18f91dfe36b1c5572d0b60dba4835eb5",
                "sha256:dcff367b725586830ff0e20b805c7654c876c2d4585c0834a6049502b9d6cf7e",
                "sha256:e0eb78fd246a965c7c232df88485c887916ec72a3c589ccbaa3f22dc8471b154",
                "sha256:e17a9ec296353b01596b5e669265418343b8d0f2dd82f541d0cf9a3fc7eaccc8",
                "sha256:e5dd9d9808ffcc053ea2c2f54fcd75c460843439daba65a699d6a2c9b8adcf27",
                "sha256:e8edf465be222e324608fd5dd58d60b050c7fd602c9b7710a11631ee7280f59f",
                "sha256:ed9212e489ac7f76506969581f1abb53fc30ac45bb28254759b634f4f51f0217",
                "sha256:ee2bb63226aa933cddda2470e56de858669bdbb612b5bd7b2489408516bb3f24"
            ],
            "index": "pypi",
            "version": "==1.13.0"
        },
        "pexpect": {
            "hashes": [
                "sha256:00ab0872f80f5db740499e7a1283a7c3b97bea542d72df84d83dea17d0afd2d9",
                "sha256:2b50dd8caa5007b10b0afcf075095814780b104b4a5cf9d8fbdc8bbc754e5ca4"
            ],
            "index": "pypi",
            "version": "==4.3.0"
        },
        "ptyprocess": {
            "hashes": [
                "sha256:923f299cc5ad920c68f2bc0bc98b75b9f838b93b599941a6b63ddbc2476394c0",
                "sha256:d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f"
            ],
            "version": "==0.6.0"
        },
        "pymongo": {
            "hashes": [
                "sha256:0543f65364fb54fb54b954136cf6b5e689ab12a7c1d15c59c52d3d0c5fa73935",
                "sha256:1108c3f21541b03d1a8ff49daea5cdbf76da75ff9c09057d8cb0b16c17933ef1",
                "sha256:28d06f38fb8b20df792c3436724041c330902f3bfdfaa71e6e5825a00f328179",
                "sha256:2f3a720aaf3c7f376754bdd128007b792af6fc4c1ad215f18dcb8918ade7ef36",
                "sha256:39e014abb53ed5ef302b69a07b1e6c6ef1d7395af15283001148949ce9676c2f",
                "sha256:65e217533c332a85dfe58e0fc1f44521103f030f97e5429499e0c880f50b666d",
                "sha256:66e946612d932f6b5800c6324fd9bcbadd16de379f4ec56e57538ceff8c683fd",
                "sha256:751918b7dc3bbbc05c071073a50e85a4a265fe5ca2d6ed939d65c1403a0701b0",
                "sha256:8bc017a05f95e6bcb281cc64386822af484f04e8e74a2eb2351c96615a97490f",
                "sha256:91bd48766b99094f646ebf34b35055aa2660d6c1fee7b8d5102ee838213f9387",
                "sha256:a99b554bbeb2f3c8b2df793f187f5c969a3871aa613abd93cc3280c353573dd1",
                "sha256:c1aedbc6044d5e70ea7a8f81205ae89742e7f58d96fd4cb7ef17312e016f20aa",
                "sha256:cf8d4cb28188705da876eb64adacf5c582769dd7c96425e8aaba3e0d6e2d9e77",
                "sha256:e410bfbfc880d63c608c48a787db46284e68642197068855ef1dfc5ff2771b01",
                "sha256:e7483795284e961e33f78637936b14dd99fdc4c004ffdcbdec9b0e5017a7e7bf",
                "sha256:e87c320a1f723dde4ae13bb56b8d91c1af39d99b79ee7b2484bf38f6a447b2d2",
                "sha256:e8a60148a665ff8287559e8fb3835cc144256ee708e3afd3bfa9f23766350af7",
                "sha256:ea57ecaa11b912f2b0339de3b59b27971c7315623f28fb368fd2ccaa35f8c8c8",
                "sha256:f06963ac44d5d8110cf7a3602c990f9196c06160b73a58bf54285667e71d9a22",
                "sha256:fdcc535924c10515e588d841a2cfe51debd760a2c636168182cb56b63ba42a89"
            ],
            "index": "pypi",
            "version": "==2.8"
        },
        "pyparsing": {
            "hashes": [
                "sha256:bc6c7146b91af3f567cf6daeaec360bc07d45ffec4cf5353f4d7a208ce7ca30a",
                "sha256:d29593d8ebe7b57d6967b62494f8c72b03ac0262b1eed63826c6f788b3606401"
            ],
            "version": "==2.2.2"
        },
        "pyyaml": {
            "hashes": [
                "sha256:16b20e970597e051997d90dc2cddc713a2876c47e3d92d59ee198700c5427736",
                "sha256:3262c96a1ca437e7e4763e2843746588a965426550f3797a79fca9c6199c431f",
                "sha256:592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab",
                "sha256:5ac82e411044fb129bae5cfbeb3ba626acb2af31a8d17d175004b70862a741a7",
                "sha256:827dc04b8fa7d07c44de11fabbc888e627fa8293b695e0f99cb544fdfa1bf0d1",
                "sha256:bc6bced57f826ca7cb5125a10b23fd0f2fff3b7c4701d64c439a300ce665fff8",
                "sha256:c01b880ec30b5a6e6aa67b09a2fe3fb30473008c85cd6a67359a1b15ed6d83a4",
                "sha256:e863072cdf4c72eebf179342c94e6989c67185842d9997960b3e69290b2fa269"
            ],
            "index": "pypi",
            "version": "==3.12"
        },
        "requests": {
            "hashes": [
                "sha256:63b52e3c866428a224f97cab011de738c36aec0185aa91cfacd418b5d58911d1",
                "sha256:ec22d826a36ed72a7358ff3fe56cbd4ba69dd7a6718ffd450ff0e9df7a47ce6a"
            ],
            "index": "pypi",
            "version": "==2.19.1"
        },
        "selenium": {
            "hashes": [
                "sha256:3af07d7a4b5d523540fa4f32902b9dec15e0379862406aef974729f42411053d",
                "sha256:af448c15b3225056cd406b435cda10bfcee250460a4811e4fd8b21be9f61626c"
            ],
            "index": "pypi",
            "version": "==3.8.0"
        },
        "svgpathtools": {
            "hashes": [
                "sha256:212cf13b9d7e81b0fd15563464920dddb9f01bb55ddcf3d634f457180eb1ed13",
                "sha256:a865b63d621488ad201be28fde03bbffca311f89ac0062190a992073525e5ddc"
            ],
            "index": "pypi",
            "version": "==1.3.1"
        },
        "svgwrite": {
            "hashes": [
                "sha256:451c7f16220d654be0cfdbd13cc6f23aca69e6fd3ca19254e80b5f6d9ca6af5a",
                "sha256:679507bb71c4eefb0d6c15643dbb8489ed0e3088330f46df30d7dc2abd897a82"
            ],
            "index": "pypi",
            "version": "==1.1.11"
        },
        "urllib3": {
            "hashes": [
                "sha256:a68ac5e15e76e7e5dd2b8f94007233e01effe3e50e8daddf69acfd81cb686baf",
                "sha256:b5725a0bd4ba422ab0e66e89e030c806576753ea3ee08554382c14e685d117b5"
            ],
            "version": "==1.23"
        }
    }
}

Requires Approval Requires PEEP API Change Behavior Change Vendored Dependencies

Most helpful comment

@techalchemy Understandable it is a breaking change, that might be something to consider for a major release.

Is there an idea to add --dev to pipenv run and pipenv shell? As those two are most likely supposed to be used in development? Those commands seemed aimed at development and not production, right?

All 10 comments

This is a delibrate design decision because npm’s default to install all dependencies results in (IMO) people installing dev dependencies everywhere. Pipenv does this the other way around to encourage users to have a workable production environment, with develop requirements more “truly optional”. ~It is also the general direction most project managers work, with npm (and yarn, for this matter) being the exception rather than the rule.~ (Not correct, see discussion below.) The decision is of course open for discuss, but you’ll need a better reason than “because that’s how node does it”.

@uranusjr I think it's good to be clear here that you are discussing the alternative solution I would like. The main solution does not involve doing a change in regards to the default flag. What do you think about the main proposal?

In regards to the alternative solution suggested. When you say "project managers" I am assuming you mean "package managers"? If so, I did not just say "that is how node does it" as my main point. My main point was put forth in the previous lines. I quote:

The reason for this is that most often to install into production you do that in CI scripts so it's easy to always have a --production flag there. However, in development many developers often forget to add the --dev flag and then gets confused as to why some module import does not work when running scripts. I see this problem all the time for colleagues new to Pipenv. This is due that in development the pipenv installation is a manual step.

Which other package managers use the same way as it has been done for Pipenv? Bundler also seem to have defaults for development: https://bundler.io/v1.16/man/bundle-install.1.html#DEPLOYMENT-MODE

As such, that is at least 3 out of all I've checked from this list:
Pipenv is a tool that aims to bring the best of all packaging worlds (bundler, composer, npm, cargo, yarn, etc.) to the Python world

edit: composer also seem to have the default of installing dev: https://getcomposer.org/doc/03-cli.md#install-i

@uranusjr

It is also the general direction most project managers work, with npm (and yarn, for this matter) being the exception rather than the rule.

That's actually not true. composer (PHP), bundler (Ruby), pub (Dart) or mix (Elixir) install development dependencies by default.

@sdispater Bundler is hard to define her (I didn’t really consider it when writing that) because the group idea is quite different (at least to me), but since there are multiple exceptions, I take that back.

Interestingly, Composer is (AFAIK) a main inspiration when Kenneth originally designed Pipenv. I wonder why he chose this particular direction.

@sdispater @uranusjr I agree and honestly I can find no package manager that has the default to do a production installation. @uranusjr Where did you get that it was a deliberate design decision? And that it is the general direction, as that simply does not seem to be true?

I would actually say that it seems pipenv run and pipenv shell seems to be used when not running in production and as such should install dev dependencies by default as well. Consider for example https://pipenv.readthedocs.io/en/latest/advanced/#automatic-loading-of-env which is typically used in development and not in production. Also, Kenneth has previously said that in CI it is recommended to use pipenv run. And in CI one usually use development dependencies such as pep8.

The more I look at this, the more convinced I become that you are doing it the incorrect way compared to other package managers. For the reasons specified in my first post, installing dev dependencies is far more common than to launch into production. And also the semantics of other commands than pipenv install actually seems to indicate they are aimed at being used in development (shell, run).

… Please understand I am not taking care only about you full time? I also prefer to provide more information in one message if possible, and yours require more than a couple of sentences to respond. This kind of reaction is not particularly productive :(

I am sorry you feel that way. I will take some time collecting myself before posting a better message.

There is no way we are changing pipenvs default behavior to automatically install dev dependencies. That would be a massive breaking api change on a tool used by tens of thousands of machines that rely on the behavior as is.

NPM and Yarn rely on environment variables to determine what to install and if that is the actual change being proposed you need to submit an enhancement proposal as a PR to the peeps folder with the proposed behavior change.

_Edited to fix a typo!_

@techalchemy Understandable it is a breaking change, that might be something to consider for a major release.

Is there an idea to add --dev to pipenv run and pipenv shell? As those two are most likely supposed to be used in development? Those commands seemed aimed at development and not production, right?

Honestly I had never considered it before and I doubt Kenneth had either. It doesn’t seem very intuitive to me, but it might seem ok to him and he has a clearer sense of API design on this type of thing

Was this page helpful?
0 / 5 - 0 ratings