Repository navigation
Add output option to build and dist-dir option to publish command
#8828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b0225ed
add output to build command
benjamin-callonnec de6d1b0
add test for build with output option
benjamin-callonnec bfa13a7
update documentation
benjamin-callonnec ca6b0e2
add dist-dir option to publish command
benjamin-callonnec ef58af1
add with_multiple_dist_dir fixture
benjamin-callonnec 342ae6c
update test publish
benjamin-callonnec c692cc3
fix uploader when runned without publish
benjamin-callonnec 097563e
make dist-dir optional argument of init Uploader
benjamin-callonnec 31dda41
add new test build with output option
benjamin-callonnec aa3fe9a
remove dist dir and change to simple_project fixture
benjamin-callonnec 9c9c143
trim trailing ws
benjamin-callonnec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,26 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import TYPE_CHECKING | ||
| from pathlib import Path | ||
|
|
||
| from cleo.helpers import option | ||
|
|
||
| from poetry.console.commands.env_command import EnvCommand | ||
| from poetry.utils.env import build_environment | ||
|
|
||
|
|
||
| if TYPE_CHECKING: | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| class BuildCommand(EnvCommand): | ||
| name = "build" | ||
| description = "Builds a package, as a tarball and a wheel by default." | ||
|
|
||
| options = [ | ||
| option("format", "f", "Limit the format to either sdist or wheel.", flag=False) | ||
| option("format", "f", "Limit the format to either sdist or wheel.", flag=False), | ||
| option( | ||
| "output", | ||
| "o", | ||
| "Set output directory for build artifacts. Default is `dist`.", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normally, we don't use backticks here (only in the docs), but I do not have strong feelings and did not found a reference for something else so 🤷 |
||
| default="dist", | ||
| flag=False, | ||
| ), | ||
| ] | ||
|
|
||
| loggers = [ | ||
|
|
@@ -48,11 +51,14 @@ def _build( | |
| def handle(self) -> int: | ||
| with build_environment(poetry=self.poetry, env=self.env, io=self.io) as env: | ||
| fmt = self.option("format") or "all" | ||
| dist_dir = Path(self.option("output")) | ||
| package = self.poetry.package | ||
| self.line( | ||
| f"Building <c1>{package.pretty_name}</c1> (<c2>{package.version}</c2>)" | ||
| ) | ||
|
|
||
| self._build(fmt, executable=env.python) | ||
| if not dist_dir.is_absolute(): | ||
| dist_dir = self.poetry.pyproject_path.parent / dist_dir | ||
| self._build(fmt, executable=env.python, target_dir=dist_dir) | ||
|
|
||
| return 0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| My Package | ||
| ========== |
Binary file added
BIN
+1.29 KB
tests/fixtures/with_multiple_dist_dir/dist/simple_project-1.2.3-py2.py3-none-any.whl
Binary file not shown.
Binary file added
BIN
+1.08 KB
tests/fixtures/with_multiple_dist_dir/dist/simple_project-1.2.3.tar.gz
Binary file not shown.
Binary file added
BIN
+1.29 KB
...fixtures/with_multiple_dist_dir/other_dist/dist/simple_project-1.2.3-py2.py3-none-any.whl
Binary file not shown.
Binary file added
BIN
+1.08 KB
tests/fixtures/with_multiple_dist_dir/other_dist/dist/simple_project-1.2.3.tar.gz
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| [tool.poetry] | ||
| name = "simple-project" | ||
| version = "1.2.3" | ||
| description = "Some description." | ||
| authors = [ | ||
| "Sébastien Eustace <sebastien@eustace.io>" | ||
| ] | ||
| 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"] | ||
|
|
||
| classifiers = [ | ||
| "Topic :: Software Development :: Build Tools", | ||
| "Topic :: Software Development :: Libraries :: Python Modules" | ||
| ] | ||
|
|
||
| # Requirements | ||
| [tool.poetry.dependencies] | ||
| python = "~2.7 || ^3.4" | ||
|
|
||
| [tool.poetry.scripts] | ||
| foo = "foo:bar" | ||
| baz = "bar:baz.boom.bim" | ||
| fox = "fuz.foo:bar.baz" | ||
|
|
||
|
|
||
| [build-system] | ||
| requires = ["poetry-core>=1.1.0a7"] | ||
| build-backend = "poetry.core.masonry.api" |
Empty file.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.