指定在pyproject.toml中的文件未被Hatchling包括。

huangapple go评论57阅读模式
英文:

Files not being included by hatchling when specified in pyproject.toml

问题

我正在尝试使用Hatch打包我的工具,并希望在下面的目录树中包括位于/docs中的一些额外文件:

this_project
│   .gitattributes
│   .gitignore
│   LICENSE
│   MANIFEST.in
│   pyproject.toml
│   README.md
│
├───docs
│       default.primers
│
└───ribdif
      __init__.py
       __main__.py

我正在使用pip install git+https://github.com/Rob-murphys/ribdif.git安装工具,但尽管根据pyproject.toml的配置(https://hatch.pypa.io/latest/config/build/#file-selection)指定了文件,但只能获取到ribdif目录中的期望文件:

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "ribdif"
version = "1.1.2"
authors = [
  { name="Robert Murphy", email="Robert.murphy@bio.ku.dk" },
]
description = "A program to analyse and correct for the usefulness of amplicon sequences"
readme = "README.md"
requires-python = ">=3.11"
classifiers = [
    "Programming Language :: Python :: 3.11",
    "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
    "Operating System :: OS Independent",
]

[tool.hatch.build]
include = [
  "ribdif/*.py",
  "/docs",
]

[project.scripts]
ribdif = "ribdif.__main__:main"
英文:

I am trying to package my tool with Hatch and want to include some extra files found in /docs in the below directory tree:

this_project
│   .gitattributes
│   .gitignore
│   LICENSE
│   MANIFEST.in
│   pyproject.toml
│   README.md
│
├───docs
│       default.primers
│
└───ribdif
      __init__.py
       __main__.py

I am installing the tool with pip install git+https://github.com/Rob-murphys/ribdif.git but am only getting the expected file inside ribdif despite specifying in the pyproject.toml per https://hatch.pypa.io/latest/config/build/#file-selection:

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "ribdif"
version = "1.1.2"
authors = [
  { name="Robert Murphy", email="Robert.murphy@bio.ku.dk" },
]
description = "A program to analyse and correct for  the usefulness of amplicon sequences"
readme = "README.md"
requires-python = ">=3.11"
classifiers = [
    "Programming Language :: Python :: 3.11",
    "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
    "Operating System :: OS Independent",
]

[tool.hatch.build]
include = [
  "ribdif/*.py",
  "/docs",
]

[project.scripts]
ribdif = "ribdif.__main__:main"

答案1

得分: 1

当使用pip从GitHub安装时,我认为我正在将我的site-packages填充为生成的wheel的内容,鉴于我需要在运行时添加额外的文件,我需要添加到wheel而不是源分发。

[tool.hatch.build.targets.wheel.force-include]
"ribdif" = "ribdif"
"docs/default.primers" = "ribdif/default.primers"

这将default.primers文件定向到site-packagesribdif/目录,因此在运行时可用!

英文:

When installing from github using pip I believe I am populating my site-packages with the content of the produced wheel and given that I need the extra files at run time I need to add to the wheel and not the source distribution.

[tool.hatch.build.targets.wheel.force-include]
"ribdif" = "ribdif"
"docs/default.primers" = "ribdif/default.primers"

This directs the default.primers file to be in the ribdif/ directory ofthe site-packages and thus available at run time!

huangapple
  • 本文由 发表于 2023年2月8日 23:03:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75387685.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定