Skip to content

Commit

Permalink
pyproject: backport Poetry changes 2020 – 2022 (#2443)
Browse files Browse the repository at this point in the history
* python-poetry/poetry-core@fc4ae2d (`develop` prop)

This backports commit fc4ae2d [1] from poetry-core.

[1]: python-poetry/poetry-core@fc4ae2d#diff-839572324cb5fa179a516814717c716dbbf38d9f21b54004e4c838aa151568ed

* python-poetry/poetry-core@08964d5 (allow setup.py)

This backports commit 08964d5 [1] from poetry-core.

[1]: python-poetry/poetry-core@08964d5#diff-839572324cb5fa179a516814717c716dbbf38d9f21b54004e4c838aa151568ed

* python-poetry/poetry-core@356de20 (inline tables)

This backports commit 356de20 [1] from poetry-core, including a test
fixture from that commit.

[1]: python-poetry/poetry-core@356de20#diff-839572324cb5fa179a516814717c716dbbf38d9f21b54004e4c838aa151568ed

* python-poetry/poetry-core@f3e3792 (source.links)

This backports commit f3e3792 [1] from poetry-core.

[1]: python-poetry/poetry-core@f3e3792

* python-poetry/poetry-core@8b1cc5e (file scripts)

This backports commit 8b1cc5e [1] from poetry-core, including a test
fixture from that commit.

[1]: python-poetry/poetry-core@8b1cc5e#diff-839572324cb5fa179a516814717c716dbbf38d9f21b54004e4c838aa151568ed

* python-poetry/poetry-core@f3215b7 (groups support)

This backports commit f3215b7 [1] from poetry-core, including a test
fixture from that commit.

[1]: python-poetry/poetry-core@f3215b7#diff-839572324cb5fa179a516814717c716dbbf38d9f21b54004e4c838aa151568ed

* python-poetry/poetry-core@3144f1f (VCS subdirs)

This backports commit 3144f1f [1] from poetry-core.

[1]: python-poetry/poetry-core@3144f1f#diff-839572324cb5fa179a516814717c716dbbf38d9f21b54004e4c838aa151568ed

* python-poetry/poetry-core@5994fa8 (no newlines)

This backports commit 5994fa8 [1] from poetry-core and includes a small
negative test.

[1]: python-poetry/poetry-core@5994fa8#diff-839572324cb5fa179a516814717c716dbbf38d9f21b54004e4c838aa151568ed

* python-poetry/poetry-core@6215dd1 (multi READMEs)

This backports commit 6215dd1 [1] from poetry-core, including a test
fixture from that commit.

[1]: python-poetry/poetry-core@6215dd1#diff-ef679a5f97d5c886f98ef4d25e0dc0b64dbb5612a8eb1794e623d2fd8a23e3dd

* python-poetry/poetry-core@9e3796b (legacy repos)

This backports commit 9e3796b [1] from poetry-core.

[1]: python-poetry/poetry-core@9e3796b

* python-poetry/poetry-core@c9348e8 (`authors`)

This backports commit c9348e8 [1] from poetry-core.

[1]: python-poetry/poetry-core@c9348e8#diff-ef679a5f97d5c886f98ef4d25e0dc0b64dbb5612a8eb1794e623d2fd8a23e3dd

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
claui and pre-commit-ci[bot] authored Aug 29, 2022
1 parent 15f7934 commit a32ba97
Show file tree
Hide file tree
Showing 7 changed files with 341 additions and 62 deletions.
5 changes: 5 additions & 0 deletions src/negative_test/pyproject/poetry-bad-multiline.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tool.poetry]
name = "bad-multiline"
version = "1.2.3"
description = "Some multi-\nline string"
authors = ["Poetry <[email protected]>"]
227 changes: 166 additions & 61 deletions src/schemas/json/pyproject.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,29 @@
"$ref": "#/definitions/poetry-author-pattern"
}
},
"poetry-include-path": {
"type": "string",
"description": "Path to file or directory to include."
},
"poetry-package-format": {
"type": "string",
"enum": ["sdist", "wheel"],
"description": "A Python packaging format."
},
"poetry-package-formats": {
"oneOf": [
{
"$ref": "#/definitions/poetry-package-format"
},
{
"type": "array",
"items": {
"$ref": "#/definitions/poetry-package-format"
}
}
],
"description": "The format(s) for which the package must be included."
},
"poetry-dependency-any": {
"oneOf": [
{
Expand Down Expand Up @@ -151,6 +174,10 @@
"type": "string",
"description": "The revision to checkout."
},
"subdirectory": {
"type": "string",
"description": "The relative path to the directory where the package is located."
},
"python": {
"type": "string",
"description": "The python versions for which the dependency should be installed."
Expand Down Expand Up @@ -181,6 +208,10 @@
"items": {
"type": "string"
}
},
"develop": {
"type": "boolean",
"description": "Whether to install the dependency in development mode."
}
}
},
Expand Down Expand Up @@ -316,32 +347,53 @@
]
}
},
"poetry-scripts": {
"poetry-script-table": {
"type": "object",
"patternProperties": {
"^[a-zA-Z-_.0-9]+$": {
"oneOf": [
{
"$ref": "#/definitions/poetry-script"
},
{
"$ref": "#/definitions/poetry-extra-script"
}
]
"oneOf": [
{
"$ref": "#/definitions/poetry-extra-script-legacy"
},
{
"$ref": "#/definitions/poetry-extra-scripts"
}
}
]
},
"poetry-script": {
"poetry-script-legacy": {
"type": "string",
"description": "A simple script pointing to a callable object."
},
"poetry-extra-script": {
"poetry-extra-scripts": {
"type": "object",
"description": "Either a console entry point or a script file that'll be included in the distribution package.",
"additionalProperties": false,
"properties": {
"reference": {
"type": "string",
"description": "If type is file this is the relative path of the script file, if console it is the module name."
},
"type": {
"description": "Value can be either file or console.",
"type": "string",
"enum": ["file", "console"]
},
"extras": {
"type": "array",
"description": "The required extras for this script. Only applicable if type is console.",
"items": {
"type": "string"
}
}
},
"required": ["reference", "type"]
},
"poetry-extra-script-legacy": {
"type": "object",
"description": "A script that should be installed only if extras are activated.",
"additionalProperties": false,
"properties": {
"callable": {
"$ref": "#/definitions/poetry-script"
"$ref": "#/definitions/poetry-script-legacy",
"description": "The entry point of the script. Deprecated in favour of reference."
},
"extras": {
"type": "array",
Expand All @@ -352,29 +404,35 @@
}
}
},
"poetry-repository": {
"poetry-build-script": {
"type": "string",
"description": "The python script file used to build extensions."
},
"poetry-build-config": {
"type": "object",
"description": "Build specific configurations.",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "The name of the repository"
},
"url": {
"type": "string",
"description": "The url of the repository",
"format": "uri"
},
"default": {
"generate-setup-file": {
"type": "boolean",
"description": "Make this repository the default (disable PyPI)"
"description": "Generate and include a setup.py file in sdist.",
"default": true
},
"secondary": {
"type": "boolean",
"description": "Declare this repository as secondary, i.e. it will only be looked up last for packages."
"script": {
"$ref": "#/definitions/poetry-build-script"
}
}
},
"poetry-build-section": {
"oneOf": [
{
"$ref": "#/definitions/poetry-build-script"
},
{
"$ref": "#/definitions/poetry-build-config"
}
]
},
"BuildSystem": {
"title": "Project build system configuration",
"$comment": "see PEP 517 (https://peps.python.org/pep-0517/) and PEP 518 (https://peps.python.org/pep-0518/)",
Expand Down Expand Up @@ -443,8 +501,8 @@
"properties": {
"poetry": {
"type": "object",
"additionalProperties": false,
"required": ["name", "version", "description"],
"additionalProperties": true,
"required": ["name", "version", "description", "authors"],
"properties": {
"name": {
"type": "string",
Expand All @@ -456,7 +514,8 @@
},
"description": {
"type": "string",
"description": "Short package description."
"description": "Short package description.",
"pattern": "^[^\n]*$"
},
"keywords": {
"type": "array",
Expand Down Expand Up @@ -491,8 +550,19 @@
"$ref": "#/definitions/poetry-maintainers"
},
"readme": {
"type": "string",
"description": "The path to the README file"
"anyOf": [
{
"type": "string",
"description": "The path to the README file."
},
{
"type": "array",
"description": "A list of paths to the readme files.",
"items": {
"type": "string"
}
}
]
},
"classifiers": {
"type": "array",
Expand All @@ -508,33 +578,41 @@
"required": ["include"],
"properties": {
"include": {
"type": "string",
"description": "What to include in the package."
"$ref": "#/definitions/poetry-include-path"
},
"from": {
"type": "string",
"description": "Where the source directory of the package resides."
},
"format": {
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
],
"description": "The format(s) for which the package must be included."
"$ref": "#/definitions/poetry-package-formats"
}
}
}
},
"include": {
"type": "array",
"description": "A list of files and folders to include."
"description": "A list of files and folders to include.",
"items": {
"anyOf": [
{
"$ref": "#/definitions/poetry-include-path"
},
{
"type": "object",
"additionalProperties": false,
"required": ["path"],
"properties": {
"path": {
"$ref": "#/definitions/poetry-include-path"
},
"format": {
"$ref": "#/definitions/poetry-package-formats"
}
}
}
]
}
},
"exclude": {
"type": "array",
Expand Down Expand Up @@ -577,23 +655,50 @@
}
}
},
"build": {
"type": "string",
"description": "The file used to build extensions."
},
"source": {
"type": "array",
"description": "A set of additional repositories where packages can be found.",
"items": {
"$ref": "#/definitions/poetry-repository"
"group": {
"type": "object",
"description": "This represents groups of dependencies",
"patternProperties": {
"^[a-zA-Z-_.0-9]+$": {
"type": "object",
"description": "This represents a single dependency group",
"required": ["dependencies"],
"properties": {
"optional": {
"type": "boolean",
"description": "Whether the dependency group is optional or not"
},
"dependencies": {
"type": "object",
"description": "The dependencies of this dependency group",
"patternProperties": {
"^[a-zA-Z-_.0-9]+$": {
"$ref": "#/definitions/poetry-dependency-any"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
}
},
"build": {
"$ref": "#/definitions/poetry-build-section"
},
"scripts": {
"type": "object",
"description": "A hash of scripts to be installed.",
"patternProperties": {
"^.+$": {
"type": "string"
"^[a-zA-Z-_.0-9]+$": {
"oneOf": [
{
"$ref": "#/definitions/poetry-script-legacy"
},
{
"$ref": "#/definitions/poetry-script-table"
}
]
}
}
},
Expand Down
48 changes: 48 additions & 0 deletions src/test/pyproject/poetry-complete.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[tool.poetry]
name = "poetry"
version = "0.5.0"
description = "Python dependency management and packaging made easy."
authors = ["Sébastien Eustace <[email protected]>"]
license = "MIT"

readme = "README.rst"

homepage = "https://python-poetry.org/"
repository = "https://github.com/python-poetry/poetry"
documentation = "https://python-poetry.org/docs"

keywords = ["packaging", "dependency", "poetry"]

# Requirements
[tool.poetry.dependencies]
python = "~2.7 || ^3.2" # Compatible python versions must be declared here
toml = "^0.9"
# Dependencies with extras
requests = { version = "^2.13", extras = ["security"] }
# Python specific dependencies with prereleases allowed
pathlib2 = { version = "^2.2", python = "~2.7", allows-prereleases = true }
# Git dependencies
cleo = { git = "https://github.com/sdispater/cleo.git", branch = "master" }

# Optional dependencies (extras)
pendulum = { version = "^1.4", optional = true }

[tool.poetry."this key is not in the schema"]
"but that’s" = "ok"

[tool.poetry.extras]
time = ["pendulum"]

[tool.poetry.dev-dependencies]
pytest = "^3.0"
pytest-cov = "^2.4"

[tool.poetry.scripts]
my-script = 'my_package:main'
sample_pyscript = { reference = "script-files/sample_script.py", type = "file" }
sample_shscript = { reference = "script-files/sample_script.sh", type = "file" }


[[tool.poetry.source]]
name = "foo"
url = "https://bar.com"
Loading

0 comments on commit a32ba97

Please sign in to comment.