Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipenv install with platform markers doesn't work #2378

Closed
yoni1 opened this issue Jun 18, 2018 · 2 comments
Closed

pipenv install with platform markers doesn't work #2378

yoni1 opened this issue Jun 18, 2018 · 2 comments

Comments

@yoni1
Copy link

yoni1 commented Jun 18, 2018

Describe the issue briefly here.

I want to install a package with platform-specific markers, for example by doing:
pipenv install "nsenter ; platform_system == 'Linux'"
This doesn't work (raises an exception). When doing this with pipenv install -r requirements.txt, the package is installed, ignoring the markers.

I'm showing Windows output below, but the same behavior happens on Linux as well.

Please run $ python -m pipenv.help, and paste the results here.

$ python -m pipenv.help output

Pipenv version: '2018.05.18'

Pipenv location: 'C:\\Python36\\lib\\site-packages\\pipenv'

Python location: 'C:\\Python36\\python.exe'

Other Python installations in PATH:

  • 2.7: C:\Python27-64\python.exe

  • 3.6: C:\Python36\python.exe

  • 3.6.5: C:\Python36\python.exe

  • 2.7.12: C:\Python27-64\python.exe

  • 3.6.5: C:\Windows\py.exe

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.6.5',
 'os_name': 'nt',
 'platform_machine': 'AMD64',
 'platform_python_implementation': 'CPython',
 'platform_release': '10',
 'platform_system': 'Windows',
 'platform_version': '10.0.17134',
 'python_full_version': '3.6.5',
 'python_version': '3.6',
 'sys_platform': 'win32'}

System environment variables:

  • ALLUSERSPROFILE
  • APPDATA
  • COMMONPROGRAMFILES
  • COMMONPROGRAMFILES(X86)
  • COMMONPROGRAMW6432
  • COMPUTERNAME
  • COMSPEC
  • DRIVERDATA
  • FPS_BROWSER_APP_PROFILE_STRING
  • FPS_BROWSER_USER_PROFILE_STRING
  • FP_NO_HOST_CHECK
  • HOMEDRIVE
  • HOMEPATH
  • LOCALAPPDATA
  • LOGONSERVER
  • MOZ_PLUGIN_PATH
  • NUMBER_OF_PROCESSORS
  • ONEDRIVE
  • OS
  • PATH
  • PATHEXT
  • PROCESSOR_ARCHITECTURE
  • PROCESSOR_IDENTIFIER
  • PROCESSOR_LEVEL
  • PROCESSOR_REVISION
  • PROGRAMDATA
  • PROGRAMFILES
  • PROGRAMFILES(X86)
  • PROGRAMW6432
  • PROMPT
  • PSMODULEPATH
  • PUBLIC
  • QT_OPENGL
  • SESSIONNAME
  • SYSTEMDRIVE
  • SYSTEMROOT
  • TEMP
  • TMP
  • USERDOMAIN
  • USERDOMAIN_ROAMINGPROFILE
  • USERNAME
  • USERPROFILE
  • VBOX_MSI_INSTALL_PATH
  • VS110COMNTOOLS
  • VS120COMNTOOLS
  • VS140COMNTOOLS
  • WINDIR
  • _NT_SYMBOL_PATH
  • PYTHONDONTWRITEBYTECODE
  • PIP_PYTHON_PATH

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: C:\Python36\Scripts\;C:\Python36\;C:\Program Files (x86)\Windows Resource Kits\Tools\;C:\ProgramData\Oracle\Java\javapath;C:\Python27-64\;C:\Python27-64\Scripts;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Program Files (x86)\WinSCP\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\OpenVPN\bin;C:\Program Files\Git\cmd;C:\WINDOWS\Syst;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\CMake\bin;C:\Users\Yoni\AppData\Local\Microsoft\WindowsApps;

Contents of Pipfile ('C:\Temp\blahtest\Pipfile'):

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

[packages]
nsenter = "*"

[dev-packages]

[requires]
python_version = "3.6"

Contents of Pipfile.lock ('C:\Temp\blahtest\Pipfile.lock'):

{
    "_meta": {
        "hash": {
            "sha256": "3b555b6f88a7631a6b64a338b0e2d578ebb5ea36d5df047ec2541f431f9d7535"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.6"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "argparse": {
            "hashes": [
                "sha256:62b089a55be1d8949cd2bc7e0df0bddb9e028faefc8c32038cc84862aefdd6e4",
                "sha256:c31647edb69fd3d465a847ea3157d37bed1f95f19760b11a47aa91c04b666314"
            ],
            "version": "==1.4.0"
        },
        "contextlib2": {
            "hashes": [
                "sha256:509f9419ee91cdd00ba34443217d5ca51f5a364a404e1dce9e8979cea969ca48",
                "sha256:f5260a6e679d2ff42ec91ec5252f4eeffdcf21053db9113bd0a8e4d953769c00"
            ],
            "version": "==0.5.5"
        },
        "nsenter": {
            "hashes": [
                "sha256:876a18cb03de85948e4cd72fd4cfda4879561b7264f5722603f6437d452a25cb",
                "sha256:d44ba70199f9b454139f2093141e63218bca5b1285c65fcf6e4b139116088867"
            ],
            "index": "pypi",
            "version": "==0.2"
        },
        "pathlib": {
            "hashes": [
                "sha256:6940718dfc3eff4258203ad5021090933e5c04707d5ca8cc9e73c94a7894ea9f"
            ],
            "version": "==1.0.1"
        }
    },
    "develop": {}
}

Expected result

I expected the Pipfile to be populated with the line nsenter = { version = "*", markers = "platform_system == 'Linux'" }, and the package to be installed or not installed based the platform.

Actual result

When not using requirements.txt, I got this exception:

Traceback (most recent call last):
  File "c:\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python36\Scripts\pipenv.exe\__main__.py", line 9, in <module>
  File "c:\python36\lib\site-packages\pipenv\vendor\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "c:\python36\lib\site-packages\pipenv\vendor\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\python36\lib\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\python36\lib\site-packages\pipenv\vendor\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\python36\lib\site-packages\pipenv\vendor\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\python36\lib\site-packages\pipenv\cli.py", line 402, in install
    selective_upgrade=selective_upgrade,
  File "c:\python36\lib\site-packages\pipenv\core.py", line 1982, in do_install
    converted = convert_deps_from_pip(package_name)
  File "c:\python36\lib\site-packages\pipenv\utils.py", line 639, in convert_deps_from_pip
    if isinstance(dependency[req.name], six.string_types):
KeyError: 'nsenter'

When using pipenv install -r requirements.txt, it just installed the package, ignoring the platform marker, and added nsenter = "*" to the Pipfile. The contents of my requirements.txt are:
nsenter ; platform_system == 'Linux'

Steps to replicate

Option 1:

pipenv install "nsenter ; platform_system == 'Linux'"

Option 2:

echo "nsenter ; platform_system == 'Linux'" > requirements.txt
pipenv install -r requirements.txt
@techalchemy
Copy link
Member

Hm yep, that seems like it would be a thing that happens. Another unfortunate consequence of some early lack of foresight about how much command line interaction requirements parsing might take for pipfiles.

@techalchemy
Copy link
Member

This actually now works (as of the 2018.06.25 release, just confirmed it:

/t/test      pipenv install "nsenter ; platform_system == 'Linux'"
Installing nsenter ; platform_system == 'Linux'...
Collecting nsenter
  Downloading https://files.pythonhosted.org/packages/8d/6d/65e257cd8cc42a68894292e28c8d25dcb5a6b8f959cfdd8c69cdc555efd1/nsenter-0.2-py3-none-any.whl
Collecting contextlib2 (from nsenter)
  Downloading https://files.pythonhosted.org/packages/a2/71/8273a7eeed0aff6a854237ab5453bc9aa67deb49df4832801c21f0ff3782/contextlib2-0.5.5-py2.py3-none-any.whl
Collecting pathlib (from nsenter)
  Downloading https://files.pythonhosted.org/packages/ac/aa/9b065a76b9af472437a0059f77e8f962fe350438b927cb80184c32f075eb/pathlib-1.0.1.tar.gz (49kB)
Collecting argparse (from nsenter)
  Downloading https://files.pythonhosted.org/packages/f2/94/3af39d34be01a24a6e65433d19e107099374224905f1e0cc6bbe1fd22a2f/argparse-1.4.0-py2.py3-none-any.whl
Building wheels for collected packages: pathlib
  Running setup.py bdist_wheel for pathlib: started
  Running setup.py bdist_wheel for pathlib: finished with status 'done'
  Stored in directory: /home/hawk/.cache/pipenv/wheels/f9/b2/4a/68efdfe5093638a9918bd1bb734af625526e849487200aa171
Successfully built pathlib
Installing collected packages: contextlib2, pathlib, argparse, nsenter
Successfully installed argparse-1.4.0 contextlib2-0.5.5 nsenter-0.2 pathlib-1.0.1

Adding nsenter ; platform_system == 'Linux' to Pipfile's [packages]...
Pipfile.lock (fe220f) out of date, updating to (29cc54)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Updated Pipfile.lock (29cc54)!
Installing dependencies from Pipfile.lock (29cc54)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 12/12 — 00:00:01
To activate this project's virtualenv, run pipenv shell.
Alternativaly, run a command inside the virtualenv with pipenv run.
    grep -A6 nsenter Pipfile.lock
        "nsenter": {
            "hashes": [
                "sha256:876a18cb03de85948e4cd72fd4cfda4879561b7264f5722603f6437d452a25cb",
                "sha256:d44ba70199f9b454139f2093141e63218bca5b1285c65fcf6e4b139116088867"
            ],
            "index": "pypi",
            "markers": "platform_system == 'Linux'",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants