question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pipenv seemingly not respecting conditional install_requires

See original GitHub issue

Issue description

When trying to install ruamel.yaml==0.15.0 using Python 3.6, pipenv tries to build ruamel.ordereddict even though this package is only a dependency for Python 2.7. Interestingly though, pipenv does not attempt to build ruamel.ordereddict when installing ruamel.yaml==0.15.1, which changed the way the dependency is defined:

ruamel.yaml 0.15.0 - __init__.py

install_requires=dict(
    any=[],
    py27=['ruamel.ordereddict'],
),

ruamel.yaml 0.15.1 - __init__.py

extras_require={':platform_python_implementation=="CPython" and python_version<="2.7"': [
    'ruamel.ordereddict',
    ]},

I’m not terribly familiar with python dependencies, but I’ve never seen them defined as in ruamel.yaml 0.15.0, so I’m thinking that may be the issue.

Expected result

pipenv not to attempt to build ruamel.ordereddict when running Python 3.6.

Actual result

pipenv tries to build ruamel.ordereddict, which is an issue since the ordereddict package is not only not required when running Python 3.6, but it doesn’t even build 😦.

Steps to replicate

pipenv --python 3.6
pipenv install ruamel.yaml==0.15.0

or just run pipenv install with pipfile included below.


$ pipenv --support

Pipenv version: '2018.7.1'

Pipenv location: '/usr/local/lib/python3.7/site-packages/pipenv'

Python location: '/usr/local/opt/python/bin/python3.7'

Other Python installations in PATH:

  • 2.7: /usr/local/bin/python2.7

  • 2.7: /usr/local/bin/python2.7

  • 2.7: /usr/bin/python2.7

  • 3.7: /usr/local/bin/python3.7m

  • 3.7: /usr/local/bin/python3.7

  • 2.7.15: /usr/local/bin/python

  • 2.7.10: /usr/bin/python

  • 2.7.15: /usr/local/bin/python2

  • 3.7.0: /usr/local/bin/python3

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.7.0',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '17.6.0',
 'platform_system': 'Darwin',
 'platform_version': 'Darwin Kernel Version 17.6.0: Tue May  8 15:22:16 PDT '
                     '2018; root:xnu-4570.61.1~1/RELEASE_X86_64',
 'python_full_version': '3.7.0',
 'python_version': '3.7',
 'sys_platform': 'darwin'}

System environment variables:

  • LC_ALL
  • NVM_DIR
  • LANG
  • XPC_FLAGS
  • HISTIGNORE
  • HISTCONTROL
  • HISTTIMEFORMAT
  • PYENV_ROOT
  • OLDPWD
  • TERM_SESSION_ID
  • EDITOR
  • COLORTERM
  • NVM_CD_FLAGS
  • __CF_USER_TEXT_ENCODING
  • ITERM_SESSION_ID
  • PYTHONIOENCODING
  • SSH_AUTH_SOCK
  • NODE_REPL_HISTORY_SIZE
  • USER
  • LSCOLORS
  • PWD
  • MANPAGER
  • HOME
  • TERM_PROGRAM
  • TERM_PROGRAM_VERSION
  • Apple_PubSub_Socket_Render
  • ITERM_PROFILE
  • LESS_TERMCAP_md
  • LESS_TERMCAP_me
  • TMPDIR
  • XPC_SERVICE_NAME
  • TERM
  • SHELL
  • NVM_BIN
  • SHLVL
  • COLORFGBG
  • PROMPT_COMMAND
  • LOGNAME
  • PATH
  • PS1
  • PS2
  • PS4
  • HISTSIZE
  • HISTFILESIZE
  • _
  • PYTHONDONTWRITEBYTECODE
  • PIP_PYTHON_PATH

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /Users/newtonne/.nvm/versions/node/v8.11.3/bin:/Users/newtonne/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
  • SHELL: /usr/local/bin/bash
  • EDITOR: vim
  • LANG: en_US
  • PWD: /Users/newtonne/Downloads/test

Contents of Pipfile (‘/Users/newtonne/Downloads/test/Pipfile’):

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

[packages]
"ruamel.yaml" = "==0.15.0"

[dev-packages]

[requires]
python_version = "3.6"

Contents of Pipfile.lock (‘/Users/newtonne/Downloads/test/Pipfile.lock’):

{
    "_meta": {
        "hash": {
            "sha256": "e2776e1e940389b95536ebe856f3f35f4ded3371aaba60d62ad69dfe2ffbfb4e"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.6"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "ruamel.ordereddict": {
            "hashes": [
                "sha256:08b4b19fe518d32251a5338e039c4dc9eb0876f2919f94c9b8d2f9446ea80806",
                "sha256:150ce8e6c514a2a2b62753622a75874962561f8e5eeec81a3172ab952807bf0b",
                "sha256:45541836cbfdde630033cae7bbbe35acbac87a0ceec79f944b7a3bedd940fe78",
                "sha256:aee2fa23e884249b4284b728888c553d551e5bfd4de2731f10153fd7813ec55f",
                "sha256:bf0a198c8ce5d973c24e5dba12d3abc254996788ca6ad8448eabc6aa710db149"
            ],
            "version": "==0.4.13"
        },
        "ruamel.yaml": {
            "hashes": [
                "sha256:16520c1da7a02b02df711791dfd72e9a6709f842ecab0ffcb5f0781586fad665",
                "sha256:20d239c8e61905debb85979acb0773b261651fdb2422a796e61d25ba9852ad03",
                "sha256:95371af26123c5c3a2f0a121444cf5197d3e6dac83ba76a2351499c328694471",
                "sha256:ab2dd4a86816d14027bb11ad2e41a2e59114bc48c9f9f27994b3598ccb00683e",
                "sha256:b03ac00d603e30f7a030eb2ac69787313051f6fa0c84ca09ea461fb5f67b749b",
                "sha256:b0bcd8d11bd06fc041a72e95f7bb0769483f20b3fdbefc252a3643d0b74e0bd3",
                "sha256:f9f4a50422acf4a6ab55b568ae879b3ceb62e8e62a60022cb88816c17e40782e"
            ],
            "index": "pypi",
            "version": "==0.15.0"
        }
    },
    "develop": {}
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
uranusjrcommented, Jul 16, 2018

Err, sorry, I misunderstood what ruamel.yaml did in 0.15.0. Let me try to get this straight. So there are mainly three ways packages do to specify conditional dependencies:

  1. With code, e.g. if version < (2, 7): install_requires.append(...)
  2. With extras_require
  3. With install_requires and environment markers

Pipenv only supports the last option. ruamel.yaml 0.15.0 was using option 1 (I thought it was using 3, hence the confusion), and after 0.15.1 it is using option 2, which is not supported. For Pipenv to work correctly, it needs to upgrade to use option 3.

So no, it should revert back to the old way. But it should also need to upgrade to the new, recommended way.

0reactions
KenLuicommented, Apr 2, 2019

Thanks, this was pretty helpful! I ran into this same issue while trying to migrate to pipenv. Since I’m locked into an older version of ruamel.yaml, my workaround was to use PEP 508 specifiers from the pipenv docs to mirror the py27 requirement in the Pipfile.

Pipfile snippet:

[packages]
"ruamel.yaml" = "==0.15.0"
"ruamel.ordereddict" = { version = "==0.4.13", markers = "python_version <= '2.7'" }

[requires]
python_version = "3.6"

pipenv install output:

(test) bash-3.2$ pipenv install
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✔ Success! 
Updated Pipfile.lock (d2113f)!
Installing dependencies from Pipfile.lock (d2113f)…
Ignoring ruamel.ordereddict: markers 'python_version <= "2.7"' don't match your environment
Read more comments on GitHub >

github_iconTop Results From Across the Web

Conditional Python Dependencies - Hynek Schlawack
Previous versions resolve using the Python that is running Pipenv instead using the Python from your virtualenv.
Read more >
error in pipenv setup command: 'install_requires' must be a ...
1. Not enough information. · 1. I suspect something is broken in a recent release. · 1. I was able to install with...
Read more >
Advanced Usage of Pipenv - Read the Docs
Dependencies of wheels provided in a Pipfile will not be captured by $ pipenv lock . There are some known issues with using...
Read more >
Untitled
Initial package - Fixed wrong license - Run fdupes at build time - Do not use depreciated %py_requires - Some fixes - fdups...
Read more >
Common Pipenv Errors - Towards Data Science
You can resolve pre-release version conflicts by adding the pre flag to the installation command pipenv install --pre . After this command, your ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found