支持诗歌项目中的子项目
Background & Rationale
This request is inspired by RPM Package Manger’s capability to build subpackages from the same Spec File. Here, I want to propose and discuss replicating a version of this capability within poetry to allow for a simplified user experience for a Python project maintainer, especially when maintaining namespace packages and/or multi-project source trees. While strict project separation is a good thing in most cases, it might not always be the more pragmatic scenario for package maintainers. For our purposes here, we can refer to each of these packages as a subproject. And all subprojects are managed under a single poetry project. This means that there is only a single pyproject.toml file and a shared project root directory with either a shared source tree or independent source trees (subdirectory) for each subproject. ### Description Let us consider the scenario of multiple namespace packages being maintained in a single repository with the following structure. console namespace-project/ └── src └── namespace └── package ├── one └── init.py ├── three └── init.py └── two └── init.py Note that this will still apply even if different source directories exist within the root directory for each subproject. Here the intention could be that we want to distribute 3 packages, namely, namespace-package-one, namespace-package-two and namespace-package-three. For the purpose of this example, let us assume that namespace-package-three depends on namespace-package-one. The pyproject.toml file could look something like this. New sections are annotated with comments detailing them and expected behaviour. toml [build-system] requires = ["poetry-core>=1.0"] build-backend = "poetry.core.masonry.api" [tool.poetry] name = "namespace-package" version = "1.0.0-alpha.0" description = "" authors = [ "Bender Rodriguez [email protected]" ] license = "MIT" readme = "README.md" repository = "https://git.planetexpress.com/bender/Python-namespace-package" keywords = [] classifiers = [ "Intended Audience :: Developers", "Operating System :: OS Independent", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.8", ] # this section remains as is, but now specifies shared dependencies [tool.poetry.dependencies] Python = "^3.8" [tool.poetry.dev-dependencies] pre-commit = "^2.1" flake8 = "^3.7" black = "^19.10b0" pytest = "^5.2" # the following are package specific section [tool.poetry.packages.one] name = "namespace-package-one" # this is optional as name would be derrived from the package name [tool.poetry.packages.two] name = "namespace-package-two" [tool.poetry.packages.three] name = "namespace-package-three" # this is optional as name would be derrived from the package name
内容来源: python-poetry/poetry