From 25370bd31088fcc73c3eea7f65f560c8ad65f9ba Mon Sep 17 00:00:00 2001 From: Jason Atallah Date: Thu, 18 Feb 2021 20:06:58 -0700 Subject: [PATCH 1/3] added setup.py exporter --- poetry/utils/exporter.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/poetry/utils/exporter.py b/poetry/utils/exporter.py index c15d4508150..5de48c5a110 100644 --- a/poetry/utils/exporter.py +++ b/poetry/utils/exporter.py @@ -17,8 +17,9 @@ class Exporter(object): """ FORMAT_REQUIREMENTS_TXT = "requirements.txt" + FORMAT_SETUP_PY = "setup.py" #: The names of the supported export formats. - ACCEPTED_FORMATS = (FORMAT_REQUIREMENTS_TXT,) + ACCEPTED_FORMATS = (FORMAT_REQUIREMENTS_TXT, FORMAT_SETUP_PY) ALLOWED_HASH_ALGORITHMS = ("sha256", "sha384", "sha512") def __init__(self, poetry: Poetry) -> None: @@ -46,6 +47,22 @@ def export( with_credentials=with_credentials, ) + def _export_setup_py( + self, + cwd: Path, + output: Union[IO, str], + with_hashes: bool = True, + dev: bool = False, + extras: Optional[Union[bool, Sequence[str]]] = None, + with_credentials: bool = False, + ) -> None: + from poetry.core.masonry.builders.sdist import SdistBuilder + + builder = SdistBuilder(self._poetry) + content = builder.build_setup() + + self._output(content, cwd, output) + def _export_requirements_txt( self, cwd: Path, From eae1b836499a8eefbb69b639984c406ffe464ec3 Mon Sep 17 00:00:00 2001 From: Jason Atallah Date: Thu, 18 Feb 2021 20:14:39 -0700 Subject: [PATCH 2/3] updated export docs to include setup.py --- docs/docs/cli.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/docs/cli.md b/docs/docs/cli.md index 4675ce1023b..28e847ed06e 100644 --- a/docs/docs/cli.md +++ b/docs/docs/cli.md @@ -485,14 +485,10 @@ This command exports the lock file to other formats. poetry export -f requirements.txt --output requirements.txt ``` -!!!note - - Only the `requirements.txt` format is currently supported. - ### Options * `--format (-f)`: The format to export to (default: `requirements.txt`). - Currently, only `requirements.txt` is supported. + Currently, only `requirements.txt` and `setup.py` are supported. * `--output (-o)`: The name of the output file. If omitted, print to standard output. * `--dev`: Include development dependencies. From 70be32dae535a97481f997096c3041dfd87003e4 Mon Sep 17 00:00:00 2001 From: Jason Atallah Date: Thu, 18 Feb 2021 20:22:22 -0700 Subject: [PATCH 3/3] ignoring kwargs --- poetry/utils/exporter.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/poetry/utils/exporter.py b/poetry/utils/exporter.py index 5de48c5a110..636df82e5f2 100644 --- a/poetry/utils/exporter.py +++ b/poetry/utils/exporter.py @@ -51,10 +51,7 @@ def _export_setup_py( self, cwd: Path, output: Union[IO, str], - with_hashes: bool = True, - dev: bool = False, - extras: Optional[Union[bool, Sequence[str]]] = None, - with_credentials: bool = False, + **_ # Cannot use any of the extra kwargs with the SdistBuilder ) -> None: from poetry.core.masonry.builders.sdist import SdistBuilder