python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.82k stars 2.28k forks source link

install wheels on windows #6522

Closed zillionare closed 2 years ago

zillionare commented 2 years ago

the pyproject.toml:

[[tool.poetry.source]]
name = "ali"
url = "https://mirrors.aliyun.com/pypi/simple/"
secondary = true

[tool.poetry.dev-dependencies]
[tool.poetry]
name = "zillionare-omicron"
packages = [
    {include = "omicron"}
]
version = "2.0.0a47"
description = "Core Library for Zillionare"
authors = ["jieyu <code@jieyu.ai>"]
license = "MIT"
readme = "README.md"
homepage = "https://zillionare-omicron.readthedocs.io"
repository = "https://github.com/zillionare/omicron"
documentation = "https://zillionare-omicron.readthedocs.io"
keywords = ["AI", "quant", "trade", "stock"]
classifiers = [
    "Development Status :: 3 - Alpha",
    "Intended Audience :: Developers",
    "License :: OSI Approved :: MIT License",
    "Natural Language :: English",
    "Programming Language :: Python :: 3.8",
]
include = [
    "LICENSE",
    "README.md",
    "HISTORY.md",
    "AUTHORS.md",
    "docs/*",
    "tests/*",
    "packages/TA_Lib-0.4.24-cp38-cp38-win_amd64.whl"
]

[tool.poetry.dependencies]
python = ">=3.8,<3.9"
sh = "1.14.1"
aiohttp = "^3.8.0"
cfg4py = ">=0.9"
numpy = "^1.22"
aioredis = "1.3.1"
aiosmtplib = "^1.1.6"
pandas = "^1.3.5"
zillionare-core-types = "^0.5.2"
ciso8601 = "^2.2.0"
Bottleneck = "^1.3.4"
scikit-learn = "^1.0.2"
empyrical-reloaded = "^0.5.8"
zigzag = "^0.3"

black = {version = "^22.3.0", optional = true}
isort  = { version = "5.10.1", optional = true}
flake8  = { version = "4.0.1", optional = true}
flake8-docstrings = { version = "^1.6.0", optional = true }
pytest  = { version = "^7.0.1", optional = true}
pytest-cov  = { version = "^3.0.0", optional = true}
tox  = { version = "^3.24.5", optional = true}
pip  = { version = "^22.0.3", optional = true}
psutil  = { version = "^5.7.3", optional = true}

mkdocs  = { version = "^1.3.0", optional = true}
mkdocs-include-markdown-plugin  = { version = "^3.2.3", optional = true}
mkdocs-material  = { version = "^8.1.11", optional = true}
mkdocstrings  = { version = "^0.18.0", optional = true}
mkdocs-material-extensions  = { version = "^1.0.3", optional = true}
twine  = { version = "^3.8.0", optional = true}
mkdocs-autorefs = {version = "^0.3.1", optional = true}
pre-commit = {version = "^2.17.0", optional = true}
toml = {version = "^0.10.2", optional = true}
livereload = {version = "^2.6.3", optional = true}
pyreadline = {version = "^2.1", optional = true}
mike = { version="^1.1.2", optional=true}
freezegun = {version = "^1.2.1", optional = true}
httpx = "^0.23.0"
deprecation = "^2.1.0"
arrow = "^1.2"
plotly = "^5.10.0"
ckwrap = "^0.1.10"
TA-Lib = {version = "^0.4.25", platform = "linux"}
ta-lib = {path = "./packages/TA_Lib-0.4.24-cp38-cp38-win_amd64.whl", platform = "win32"}

[tool.poetry.extras]
test = [
    "pytest",
    "black",
    "isort",
    "flake8",
    "flake8-docstrings",
    "pytest-cov",
    "psutil",
    "freezegun"
    ]

dev = ["tox", "pre-commit", "pip", "twine", "toml"]

doc = [
    "mkdocs",
    "mkdocs-include-markdown-plugin",
    "mkdocs-material",
    "mkdocstrings",
    "mkdocs-material-extension",
    "mkdocs-autorefs",
    "Jinja2",
    "livereload",
    "mike"
    ]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.black]
line-length = 88
include = '\.pyi?$'
exclude = '''
/(
    \.eggs
  | \.git
  | \.hg
  | \.mypy_cache
  | \.tox
  | \.venv
  | \.history
  | _build
  | buck-out
  | build
  | dist
)/
'''
[tool.isort]
profile = "black"

the problem I tried to solving is to install ta-lib, which involves native talib.lib. On windows there's pre-built wheels available, and I decide to include it to my package, so I add this by:

poetry add path/to/ta-lib*wheel --platform win32

and put the wheel to ./packages folder (which is at same level as pyproject.toml, and included by:

include = [
    "packages/TA_Lib-0.4.24-cp38-cp38-win_amd64.whl"
]

things works well until now. However, when I tried to install my package (which name is omicron), it always failed with:

pip._vendor.pkg_resources.RequirementParseError: Invalid URL: packages/TA_Lib-0.4.24-cp38-cp38-win_amd64.whl

I wonder the path sep should be '\' instead of '/' ? however, with '\', it doesn't work too.

dimbleby commented 2 years ago

You cannot create a useful package that depends on local file dependencies. This is not a poetry thing, it's just how the world is.

However you express the dependency, and whether or not you try to bundle a wheel within a wheel: the path that you point at simply won't exist for the user trying to install the package.

What you are trying to do cannot work.

zillionare commented 2 years ago

You cannot create a useful package that depends on local file dependencies. This is not a poetry thing, it's just how the world is.

However you express the dependency, and whether or not you try to bundle a wheel within a wheel: the path that you point at simply won't exist for the user trying to install the package.

What you are trying to do cannot work.

Hi dimbleby: thanks for replying.

from poetry's document (https://poetry.eustace.io/docs/versions/#multiple-constraints-dependencies) and https://github.com/python-poetry/poetry/issues/1616, I think poetry should already supported this usage, just it doesn't work on my case (or, i don't know how to make it work).

and I had already packed the required wheels to release package by specify it in "include" section, as my pyproject.toml says. poetry build doesn't complain about this at all and I have checked omicron.whl, the required package (which is ta-libwin64.whl) already in it.

hope it's more clear now.

zillionare commented 2 years ago

by the way, if this is not a case poetry should support, what the use case when we add local file dependency by poetry add? Just for development mode?

dimbleby commented 2 years ago

poetry supports file dependencies for local development.

However you cannot expect to build a wheel that has a file dependency and then install that wheel. This bit:

include = [
    "packages/TA_Lib-0.4.24-cp38-cp38-win_amd64.whl"
]

cannot help

zillionare commented 2 years ago

poetry supports file dependencies for local development.

However you cannot expect to build a wheel that has a file dependency and then install that wheel. This bit:

include = [
    "packages/TA_Lib-0.4.24-cp38-cp38-win_amd64.whl"
]

cannot help

understand. Would you please address this in documentation if it's not addressed already?

zillionare commented 2 years ago

poetry supports file dependencies for local development.

However you cannot expect to build a wheel that has a file dependency and then install that wheel. This bit:

include = [
    "packages/TA_Lib-0.4.24-cp38-cp38-win_amd64.whl"
]

cannot help

still not understood, sorry. What's the point that we add this deps to pyproject file just for local development? I guess after poetry build, we still cannot install that package locally?

dimbleby commented 2 years ago

to reiterate, this is not a poetry question. No tool can build a useful wheel with a file dependency, because a path on your machine will not exist or contain the same items as a path on some other user's machine.

neersighted commented 2 years ago

Poetry can be used as the only tool to manage/install your application (in which case file/URL direct dependencies are something you can reason about), or as a tool to develop a package to distribute and depend on elsewhere. For the latter use case, you cannot use direct dependencies as they will not be available to all users.

You should use a constraint and publish your package to an index if you want to depend on it in your package.

github-actions[bot] commented 8 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.