Skip to content

Commit

Permalink
Merge pull request #225 from mbalatsko/init-offline-cli-option
Browse files Browse the repository at this point in the history
Adjust no-smart-version option to enable offline builds
  • Loading branch information
vemel authored Sep 7, 2023
2 parents cbf33c8 + aca7ca8 commit 172fd5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions mypy_boto3_builder/cli_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ def parse_args(args: Sequence[str]) -> Namespace:
)
parser.add_argument(
"--no-smart-version",
action="store_true",
help="Disable version bump if package is already published",
action="store_false",
help=(
"Disable version bump based od last PyPI version. "
"Set this flag to run packages build in offline mode. "
"skip-published flag is ignored in this case."
),
)
parser.add_argument(
"--panic",
Expand Down
6 changes: 3 additions & 3 deletions mypy_boto3_builder/generators/base_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class BaseGenerator(ABC):
output_path -- Path to write generated files
generate_setup -- Whether to create package or installed module
skip_published -- Whether to skip packages that are already published
disable_smart_version -- Whether to create a new postrelease if version is already published
disable_smart_version -- Whether to create a new postrelease based on latest PyPI version
version -- Package build version
"""

Expand Down Expand Up @@ -68,15 +68,15 @@ def get_library_version(self) -> str:
raise NotImplementedError()

def _get_package_version(self, pypi_name: str, version: str) -> str | None:
if self.disable_smart_version:
return version
pypi_manager = PyPIManager(pypi_name)
if not pypi_manager.has_version(version):
return version

if self.skip_published:
self.logger.info(f"Skipping {pypi_name} {version}, already on PyPI")
return None
if self.disable_smart_version:
return version

return pypi_manager.get_next_version(version)

Expand Down

0 comments on commit 172fd5b

Please sign in to comment.