Skip to content

Unable to install for multi platforms. markers and sys_platform is ignored #6354

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

Open
danrossi opened this issue Mar 6, 2025 · 2 comments
Open

Comments

@danrossi
Copy link

danrossi commented Mar 6, 2025

This is an old issue that was supposably fixed but when configuring mac wheels on windows it's still trying to install them and run into errors like this when running pipenv install

ERROR: cffi-1.16.0-cp312-cp312-macosx_11_0_universal2.whl is not a supported

And vice versa on mac I have to remove the windows selected package for the same reason.

On mac having these two lines in the file fails from a supposed fix.

Pillow = { version = "*", markers="sys_platform == 'win32'" }
cffi = { version = "*", markers="sys_platform == 'win32'" }

With errors like

    raise InstallationError(msg)
pipenv.patched.pip._internal.exceptions.InstallationError: Invalid requirement: 'cffi*': Expected end or semicolon (after name and no valid version specifier)

Full pipenv file

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

[packages]
starlette = "*"
starlette-jwt = "*"
pystray = "*"
Events = "*"
altgraph = "*"
anyio = "==4.4.0"
asgiref = "*"
click = "*"
colorama = "*"
future = "*"
h11 = "*"
httptools = "*"
idna = "*"
pyinstaller-hooks-contrib = "*"
python-dotenv = "*"
pywin32-ctypes = "*"
six = "*"
sniffio = "*"
watchgod = "*"
MarkupSafe = "*"
PyYAML = "*"
icnsutil = "*"
macholib = "*"
pefile = "*"
pyjwt = "*"
cryptography = "*"
appdirs = "*"
pyinstaller = "*"
uvicorn = {extras = ["standard"], version = "*"}
python-decouple = "*"
pyinstaller-versionfile = "*"
toml = "*"
boto3 = "*"
rich = "*"
gitpython = "*"
wheel-filename = "*"
delocate = "*"
Pillow = { version = "*", markers="sys_platform == 'win32'" }
cffi = { version = "*", markers="sys_platform == 'win32'" }
pyobjc = { version = "*", markers="sys_platform == 'darwin'" }
pillow_mac = {file = "build/mac/Pillow-10.1.0-cp312-cp312-macosx_11_0_universal2.whl", markers="sys_platform == 'darwin'" }
cffi_mac = {file = "build/mac/cffi-1.16.0-cp312-cp312-macosx_11_0_universal2.whl", markers="sys_platform == 'darwin'"}
websockets_mac = {file = "build/mac/websockets-12.0-cp312-cp312-macosx_11_0_universal2.whl", markers="sys_platform == 'darwin'"}
[dev-packages]

[requires]
python_version = "3.13"
@danrossi
Copy link
Author

danrossi commented Mar 7, 2025

I'm not sure if this is the same issue. I have git pipenv installed. These local universal2 wheels pipenv is trying to install the pip version not the local wheel when running pipenv install from a fresh shell. And so was reporting not a fat binary and couldn't figure out why. For the websockets wheel mostly.

pillow_mac = {file = "build/mac/Pillow-11.1.0-cp313-cp313-macosx_11_0_universal2.whl", markers="sys_platform == 'darwin'" }
cffi_mac = {file = "build/mac/cffi-1.17.1-cp313-cp313-macosx_11_0_universal2.whl", markers="sys_platform == 'darwin'"}
websockets_mac = {file = "build/mac/websockets-15.0.1-cp313-cp313-macosx_11_0_universal2.whl", markers="sys_platform == 'darwin'"}

Running the wheel install manually worked. Lipo reported the included libraries as fat binaries.

pipenv run pip install --force-reinstall build/mac/websockets-15.0.1-cp313-cp313-macosx_11_0_universal2.whl

@matteius
Copy link
Member

matteius commented Apr 25, 2025

After examining the code, I can identify the issue with platform-specific dependencies and local wheel files in Pipenv. Let me explain what's happening and propose a solution.

The Issue
The problem occurs when you have platform-specific local wheel files in your Pipfile. There are two main issues:

Platform Marker Handling: When Pipenv processes the Pipfile entries with both a file path and markers, it's not correctly applying the platform markers to the local wheel files during dependency resolution.

Package Name Conflicts: The way you've named your packages is causing conflicts. When you have both cffi and cffi_mac in your Pipfile, Pipenv is trying to install both on macOS, even though only cffi_mac should be installed.

The Solution
The solution is to change how you structure your Pipfile to avoid these conflicts. Instead of having separate entries for Windows and macOS versions of the same package, use the same package name with platform-specific markers:

[packages]
# Use the same package name with different sources based on platform
Pillow = {version = "*", markers="sys_platform == 'win32'"}
Pillow = {file = "build/mac/Pillow-11.1.0-cp313-cp313-macosx_11_0_universal2.whl", markers="sys_platform == 'darwin'"}

cffi = {version = "*", markers="sys_platform == 'win32'"}
cffi = {file = "build/mac/cffi-1.17.1-cp313-cp313-macosx_11_0_universal2.whl", markers="sys_platform == 'darwin'"}

websockets = {version = "*", markers="sys_platform == 'win32'"}
websockets = {file = "build/mac/websockets-15.0.1-cp313-cp313-macosx_11_0_universal2.whl", markers="sys_platform == 'darwin'"}

macOS-only dependency

pyobjc = {version = "*", markers="sys_platform == 'darwin'"}
However, TOML doesn't allow duplicate keys, so you'll need to use an alternative approach. Here's what you should do:

Use a single entry with conditional markers:

[packages]
Pillow = {file = "build/mac/Pillow-11.1.0-cp313-cp313-macosx_11_0_universal2.whl", markers="sys_platform == 'darwin'", version = "*"}
cffi = {file = "build/mac/cffi-1.17.1-cp313-cp313-macosx_11_0_universal2.whl", markers="sys_platform == 'darwin'", version = "*"}
websockets = {file = "build/mac/websockets-15.0.1-cp313-cp313-macosx_11_0_universal2.whl", markers="sys_platform == 'darwin'", version = "*"}
pyobjc = {version = "*", markers="sys_platform == 'darwin'"}

The key insight is that by including both file and version in the same entry, Pipenv will use the local wheel file on macOS (due to the marker) and fall back to the PyPI version on Windows.

Why This Works
When Pipenv processes a dependency with both a file path and a version, it prioritizes the file path when the platform marker matches, and falls back to the version when it doesn't. This approach avoids the naming conflicts that were causing the issues.

Additional Notes
Make sure your local wheel files are compatible with your Python version. The error message suggests you're using Python 3.13, so ensure your wheel files are built for that version.

If you're still having issues, you can try manually installing the wheel files first:

pipenv run pip install --force-reinstall build/mac/websockets-15.0.1-cp313-cp313-macosx_11_0_universal2.whl
The error Invalid requirement: 'cffi*': Expected end or semicolon suggests there might be a syntax issue in your Pipfile. Make sure there are no extra characters or formatting issues.

This approach should resolve the platform-specific dependency issues you're experiencing with Pipenv.

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

2 participants