Commit a61a1def by Sébastien Eustace Committed by GitHub

Add support for custom urls in metadata (#1137)

* Add support for custom urls in metadata

* Add documentation for custom urls
parent c01f15a6
...@@ -251,6 +251,18 @@ To match the example in the setuptools documentation, you would use the followin ...@@ -251,6 +251,18 @@ To match the example in the setuptools documentation, you would use the followin
".rst" = "some_module:SomeClass" ".rst" = "some_module:SomeClass"
``` ```
## `urls`
In addition to the basic urls (`homepage`, `repository` and `documentation`), you can specify
any custom url in the `urls` section.
```toml
[tool.poetry.urls]
"Bug Tracker" = "https://github.com/sdispater/poetry/issues"
```
If you publish you package on PyPI, they will appear in the `Project Links` section.
## Poetry and PEP-517 ## Poetry and PEP-517
[PEP-517](https://www.python.org/dev/peps/pep-0517/) introduces a standard way [PEP-517](https://www.python.org/dev/peps/pep-0517/) introduces a standard way
......
...@@ -161,6 +161,15 @@ ...@@ -161,6 +161,15 @@
} }
} }
} }
},
"urls": {
"type": "object",
"patternProperties": {
"^.+$": {
"type": "string",
"description": "The full url of the custom url."
}
}
} }
}, },
"definitions": { "definitions": {
......
...@@ -14,6 +14,7 @@ class ProjectPackage(Package): ...@@ -14,6 +14,7 @@ class ProjectPackage(Package):
self.packages = [] self.packages = []
self.include = [] self.include = []
self.exclude = [] self.exclude = []
self.custom_urls = {}
if self._python_versions == "*": if self._python_versions == "*":
self._python_constraint = parse_constraint("~2.7 || >=3.4") self._python_constraint = parse_constraint("~2.7 || >=3.4")
...@@ -44,6 +45,14 @@ class ProjectPackage(Package): ...@@ -44,6 +45,14 @@ class ProjectPackage(Package):
create_nested_marker("python_version", self._python_constraint) create_nested_marker("python_version", self._python_constraint)
) )
@property
def urls(self):
urls = super(ProjectPackage, self).urls
urls.update(self.custom_urls)
return urls
def clone(self): # type: () -> ProjectPackage def clone(self): # type: () -> ProjectPackage
package = super(ProjectPackage, self).clone() package = super(ProjectPackage, self).clone()
......
...@@ -183,6 +183,10 @@ class Poetry: ...@@ -183,6 +183,10 @@ class Poetry:
if "packages" in local_config: if "packages" in local_config:
package.packages = local_config["packages"] package.packages = local_config["packages"]
# Custom urls
if "urls" in local_config:
package.custom_urls = local_config["urls"]
# Moving lock if necessary (pyproject.lock -> poetry.lock) # Moving lock if necessary (pyproject.lock -> poetry.lock)
lock = poetry_file.parent / "poetry.lock" lock = poetry_file.parent / "poetry.lock"
if not lock.exists(): if not lock.exists():
......
...@@ -42,3 +42,6 @@ time = ["pendulum"] ...@@ -42,3 +42,6 @@ time = ["pendulum"]
my-script = "my_package:main" my-script = "my_package:main"
my-2nd-script = "my_package:main2" my-2nd-script = "my_package:main2"
extra-script = {callable = "my_package.extra:main", extras = ["time"]} extra-script = {callable = "my_package.extra:main", extras = ["time"]}
[tool.poetry.urls]
"Issue Tracker" = "https://github.com/sdispater/poetry/issues"
...@@ -103,6 +103,7 @@ def test_get_metadata_content(): ...@@ -103,6 +103,7 @@ def test_get_metadata_content():
urls = parsed.get_all("Project-URL") urls = parsed.get_all("Project-URL")
assert urls == [ assert urls == [
"Documentation, https://poetry.eustace.io/docs", "Documentation, https://poetry.eustace.io/docs",
"Issue Tracker, https://github.com/sdispater/poetry/issues",
"Repository, https://github.com/sdispater/poetry", "Repository, https://github.com/sdispater/poetry",
] ]
......
...@@ -221,6 +221,7 @@ Requires-Dist: cachy[msgpack] (>=0.2.0,<0.3.0) ...@@ -221,6 +221,7 @@ Requires-Dist: cachy[msgpack] (>=0.2.0,<0.3.0)
Requires-Dist: cleo (>=0.6,<0.7) Requires-Dist: cleo (>=0.6,<0.7)
Requires-Dist: pendulum (>=1.4,<2.0); extra == "time" Requires-Dist: pendulum (>=1.4,<2.0); extra == "time"
Project-URL: Documentation, https://poetry.eustace.io/docs Project-URL: Documentation, https://poetry.eustace.io/docs
Project-URL: Issue Tracker, https://github.com/sdispater/poetry/issues
Project-URL: Repository, https://github.com/sdispater/poetry Project-URL: Repository, https://github.com/sdispater/poetry
Description-Content-Type: text/x-rst Description-Content-Type: text/x-rst
...@@ -320,6 +321,7 @@ Requires-Dist: cachy[msgpack] (>=0.2.0,<0.3.0) ...@@ -320,6 +321,7 @@ Requires-Dist: cachy[msgpack] (>=0.2.0,<0.3.0)
Requires-Dist: cleo (>=0.6,<0.7) Requires-Dist: cleo (>=0.6,<0.7)
Requires-Dist: pendulum (>=1.4,<2.0); extra == "time" Requires-Dist: pendulum (>=1.4,<2.0); extra == "time"
Project-URL: Documentation, https://poetry.eustace.io/docs Project-URL: Documentation, https://poetry.eustace.io/docs
Project-URL: Issue Tracker, https://github.com/sdispater/poetry/issues
Project-URL: Repository, https://github.com/sdispater/poetry Project-URL: Repository, https://github.com/sdispater/poetry
Description-Content-Type: text/x-rst Description-Content-Type: text/x-rst
......
...@@ -99,6 +99,7 @@ Requires-Dist: cachy[msgpack] (>=0.2.0,<0.3.0) ...@@ -99,6 +99,7 @@ Requires-Dist: cachy[msgpack] (>=0.2.0,<0.3.0)
Requires-Dist: cleo (>=0.6,<0.7) Requires-Dist: cleo (>=0.6,<0.7)
Requires-Dist: pendulum (>=1.4,<2.0); extra == "time" Requires-Dist: pendulum (>=1.4,<2.0); extra == "time"
Project-URL: Documentation, https://poetry.eustace.io/docs Project-URL: Documentation, https://poetry.eustace.io/docs
Project-URL: Issue Tracker, https://github.com/sdispater/poetry/issues
Project-URL: Repository, https://github.com/sdispater/poetry Project-URL: Repository, https://github.com/sdispater/poetry
Description-Content-Type: text/x-rst Description-Content-Type: text/x-rst
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment