问题
项目的目录如下
- root
- src
- model
- resnet.py
- model
- README
- .gitignore
- .git
- pyproject.toml
- src
其中 src 是项目实现的模块
假如这个模块的名称叫 my_module
我们想实现 from my_module.model.resnet import Resnet
但是 my_module 源码所在的文件夹名称是 src, 不是 my_module,怎么安装?
解决方法
在pyproject.toml 修改
[tool.poetry]
name = "mymodule"
version = "0.1.0"
description = ""
authors = ["my"]
packages = [{include = "**/*", from = "src", to = "mymodule"}][build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
然后 pip install .