如何跨平台安装包 pipenv,方法取决于平台?

How to cross-platform install a package pipenv, method depending on the platform?

我正在尝试安装 Christoph Gohlke 的 Shapely package to a cross-platform project using pipenv. However, on Windows, shapely can't be installed using a simple pipenv install shapely, it throws errors for a missing dependent dll. For this purpose, there is a pre-built wheel available from the famous unofficial package wheels

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

[packages]
shapely = {file = "https://download.lfd.uci.edu/pythonlibs/n5jyqt7p/Shapely-1.6.4.post2-cp37-cp37m-win_amd64.whl", sys_platform = "== 'win32'"}

[dev-packages]

[requires]
python_version = "3.7"

这个轮子非常适合 Windows,但只适合 Windows。那么我如何在 Pipfile 中指定 only 如果平台是 linux,它可以简单地 pipenv install shapely 为:

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

[packages]
shapely = "==1.6.4.post2"

[dev-packages]

[requires]
python_version = "3.7"

或者使用 pipenv 是不可能的?还是我拼凑一个 Pipfile.Windows 文件,我不幸的 Windows 同事可以将其重命名为 Pipfile

非常感谢任何指点。

wheel 分布也适用于 linux,抱歉,不了解你的 linux 发行版,但你可以试试这个:

[packages]
# for linux
shapely = {file = "https://files.pythonhosted.org/packages/97/36/1af447160f713d72f35dd7e749788367b7a13285c4af2fbd675128aa4e99/Shapely-1.6.4.post2-cp37-cp37m-manylinux1_x86_64.whl", platform_system="Linux"}

# for windows
shapely_win = {file = "https://download.lfd.uci.edu/pythonlibs/n5jyqt7p/Shapely-1.6.4.post2-cp37-cp37m-win_amd64.whl", platform_system="Windows"}

shapely_win名称不影响包安装