Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions docs/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 15 additions & 1 deletion poetry/utils/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down