英文:
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-packages
的ribdif/
目录,因此在运行时可用!
英文:
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!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论