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

How to specify different version requirements of a package for multiple platforms? #4240

Open
darkvertex opened this issue May 5, 2020 · 4 comments

Comments

@darkvertex
Copy link

darkvertex commented May 5, 2020

(I promise I searched StackOverflow and google and failed to find an example of what I need.)

I have a normal looking Pipfile with one requirement like so:

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

[packages]
ujson = "*"

[requires]
python_version = "2.7"

I wanted to pin ujson on Windows only to version 1.35 but use the latest on Linux.

Syntactically, is that even possible? I tried this but pipenv didn't likey:

[packages]
ujson = {version = "*",sys_platform = "!= 'win32'"}
ujson = {version = "==1.35",sys_platform = "== 'win32'"}

It doesn't want me to declare a package twice, so how would I join my marker conditionals? Can it be done?


$ pipenv --support

Pipenv version: '2020.4.1b1'

Pipenv location: '/home/alan/.local/lib/python2.7/site-packages/pipenv'

Python location: '/usr/bin/python2'

Python installations found:

  • 3.6.9: /usr/bin/python3.6
  • 3.6.9: /usr/bin/python3.6m
  • 3.6.9: /usr/bin/python3
  • 3.5.2: /usr/bin/python3.5
  • 3.5.2: /usr/bin/python3.5m
  • 2.7.17: /usr/bin/python2.7
  • 2.7.17: /usr/bin/python2

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '0',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '4.15.0-99-generic',
 'platform_system': 'Linux',
 'platform_version': '#100-Ubuntu SMP Wed Apr 22 20:32:56 UTC 2020',
 'python_full_version': '2.7.17',
 'python_version': '2.7',
 'sys_platform': 'linux2'}

System environment variables:

  • _
  • GOPATH
  • PIP_PYTHON_PATH
  • QT_QPA_PLATFORMTHEME
  • PIP_SHIMS_BASE_MODULE
  • QT4_IM_MODULE
  • GOROOT
  • GOBIN
  • WINDOWPATH
  • XDG_CURRENT_DESKTOP
  • XDG_SESSION_TYPE
  • QT_IM_MODULE
  • LOGNAME
  • USER
  • PATH
  • XDG_VTNR
  • HOME
  • DISPLAY
  • SSH_AGENT_PID
  • LANG
  • TERM
  • SHELL
  • XAUTHORITY
  • LANGUAGE
  • SESSION_MANAGER
  • XDG_DATA_DIRS
  • MANDATORY_PATH
  • QT_ACCESSIBILITY
  • DRONE_TOKEN
  • PYLINTHOME
  • CLUTTER_IM_MODULE
  • TEXTDOMAIN
  • GNOME_TERMINAL_SERVICE
  • EDITOR
  • XMODIFIERS
  • GOARCH
  • GPG_AGENT_INFO
  • GJS_DEBUG_OUTPUT
  • DISTRO
  • GTK2_MODULES
  • XDG_SESSION_DESKTOP
  • XDG_RUNTIME_DIR
  • GTK_IM_MODULE
  • PYTHONPATH
  • SSH_AUTH_SOCK
  • DRONE_SERVER
  • VTE_VERSION
  • USERNAME
  • IM_CONFIG_PHASE
  • TEXTDOMAINDIR
  • GNOME_SHELL_SESSION_MODE
  • PYTHONDONTWRITEBYTECODE
  • XDG_CONFIG_DIRS
  • GOOS
  • LESSOPEN
  • XDG_SESSION_ID
  • DBUS_SESSION_BUS_ADDRESS
  • NUKE_PATH
  • GTK_MODULES
  • GDMSESSION
  • DESKTOP_SESSION
  • LESSCLOSE
  • DEFAULTS_PATH
  • XDG_SEAT
  • PIP_DISABLE_PIP_VERSION_CHECK
  • SHLVL
  • PWD
  • PYTHONFINDER_IGNORE_UNSUPPORTED
  • COLORTERM
  • XDG_MENU_PREFIX
  • GNOME_DESKTOP_SESSION_ID
  • LS_COLORS
  • GJS_DEBUG_TOPICS
  • GNOME_TERMINAL_SCREEN

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /home/alan/go/bin:/home/alan/google-cloud-sdk/bin:/home/alan/.poetry/bin:/home/alan/.local/bin:/home/alan/bin:/home/alan/.poetry/bin:/home/alan/bin:/home/alan/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
  • SHELL: /bin/bash
  • EDITOR: code
  • LANG: en_CA.UTF-8
  • PWD: /home/alan

@darkvertex
Copy link
Author

I found this article which is almost what I need:

https://dev.to/tomoyukiaota/creating-a-pipfile-which-has-different-installation-instructions-depending-on-operating-systems-pytorch-v041-as-an-example-56i8

... but it's not clear how I can get around the package name being the same when not having a url of the wheel (which I don't in my case.)

@kohanyirobert
Copy link

I ran into the following issue, here's what I've found @darkvertex Seems to work for now.

@darkvertex
Copy link
Author

I ran into the following issue, here's what I've found @darkvertex Seems to work for now.

That article suggests:

[packages]
pymssql-win= {path = "./install/pymssql-2.1.4-cp36-cp36m-win_amd64.whl", os_name = "=='nt'"}
pymssql = {version = "*", os_name = "=='posix'"}

...but this only works because the keys are different between the two lines, and the name doesn't matter for the one installing from a .whl file because it's using a file.

That's a quasi-valid workaround but it means for one OS I cannot use pipenv's own version resolver since I would need to embed the url to the .whl

What I would prefer, if it were possible, would be some syntax like:

[packages]
ujson = {version = "*",sys_platform = "!= 'win32'"}
ujson-windows = {name = "ujson", version = "==1.35",sys_platform = "== 'win32'"}

...but AFAIK overriding the package name is not allowed.

@matteius
Copy link
Member

Since removing requirementslib dependency, it would actually be relatively straight forward to add a name override now.

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

No branches or pull requests

3 participants