-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
introduce sync
command and deprecate install --sync
#9801
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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 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 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 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 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,31 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
from typing import ClassVar | ||
|
||
from poetry.console.commands.self.install import SelfInstallCommand | ||
|
||
|
||
if TYPE_CHECKING: | ||
from cleo.io.inputs.option import Option | ||
|
||
|
||
class SelfSyncCommand(SelfInstallCommand): | ||
name = "self sync" | ||
description = ( | ||
"Sync Poetry's own environment according to the locked packages (incl. addons)" | ||
" required by this Poetry installation." | ||
) | ||
options: ClassVar[list[Option]] = [ | ||
opt for opt in SelfInstallCommand.options if opt.name != "sync" | ||
] | ||
help = f"""\ | ||
The <c1>self sync</c1> command ensures all additional (and no other) packages \ | ||
specified are installed in the current runtime environment. | ||
|
||
This is managed in the \ | ||
<comment>{SelfInstallCommand.get_default_system_pyproject_file()}</> file. | ||
|
||
You can add more packages using the <c1>self add</c1> command and remove them using \ | ||
the <c1>self remove</c1> command. | ||
""" |
This file contains 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,36 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
from typing import ClassVar | ||
|
||
from poetry.console.commands.install import InstallCommand | ||
|
||
|
||
if TYPE_CHECKING: | ||
from cleo.io.inputs.option import Option | ||
|
||
|
||
class SyncCommand(InstallCommand): | ||
name = "sync" | ||
description = "Update the project's environment according to the lockfile." | ||
|
||
options: ClassVar[list[Option]] = [ | ||
opt for opt in InstallCommand.options if opt.name != "sync" | ||
Secrus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
] | ||
|
||
help = """\ | ||
The <info>sync</info> command makes sure that the project's environment is in sync with | ||
the <comment>poetry.lock</> file. | ||
It is equivalent to running <info>poetry install --sync</info>. | ||
<info>poetry sync</info> | ||
By default, the above command will also install the current project. To install only the | ||
dependencies and not including the current project, run the command with the | ||
<info>--no-root</info> option like below: | ||
<info> poetry sync --no-root</info> | ||
If you want to use Poetry only for dependency management but not for packaging, | ||
you can set the "package-mode" to false in your pyproject.toml file. | ||
""" |
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider moving the deprecation date to a configuration constant
Hardcoded dates in strings make future updates more difficult and error-prone. Consider moving this to a constant or configuration value.
Suggested implementation:
Note: If there are other parts of the codebase that need to reference this deprecation date, you might want to consider moving the constant to a more central location, such as a
constants.py
file or a configuration module. The exact location would depend on your project's structure and conventions.