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. diff --git a/poetry/utils/exporter.py b/poetry/utils/exporter.py index c15d4508150..636df82e5f2 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,19 @@ def export( with_credentials=with_credentials, ) + def _export_setup_py( + self, + cwd: Path, + output: Union[IO, str], + **_ # Cannot use any of the extra kwargs with the SdistBuilder + ) -> 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,