Skip to content

Commit

Permalink
Move lite packages to a separate product
Browse files Browse the repository at this point in the history
  • Loading branch information
vemel committed Nov 27, 2024
1 parent 3c818ae commit ef08520
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 67 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/integration_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ jobs:
--product boto3 boto3-full \
-s s3 ec2 \
--no-smart-version \
--skip-lite \
--output-type=wheel
uv run mypy_boto3_builder mypy_boto3_output \
--product aioboto3 aiobotocore aiobotocore-full \
-s s3 \
--no-smart-version \
--skip-lite \
--output-type=wheel
- name: Install full packages
run: |
Expand Down
7 changes: 0 additions & 7 deletions mypy_boto3_builder/cli_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class CLINamespace:
skip_published: bool = False
disable_smart_version: bool = False
download_static_stubs: bool = True
skip_lite_package: bool = False


def parse_args(args: Sequence[str]) -> CLINamespace:
Expand Down Expand Up @@ -214,11 +213,6 @@ def parse_args(args: Sequence[str]) -> CLINamespace:
action="store_true",
help="List supported boto3 service names.",
)
parser.add_argument(
"--skip-lite",
action="store_true",
help="Skip generation for *-lite packages.",
)
result = parser.parse_args(args)

if result.installed:
Expand All @@ -236,5 +230,4 @@ def parse_args(args: Sequence[str]) -> CLINamespace:
skip_published=result.skip_published,
disable_smart_version=result.no_smart_version,
download_static_stubs=result.download_static_stubs,
skip_lite_package=result.skip_lite,
)
16 changes: 14 additions & 2 deletions mypy_boto3_builder/enums/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ class Product(Enum):
"""

boto3 = "boto3"
boto3_lite = "boto3-lite"
boto3_services = "boto3-services"
boto3_full = "boto3-full"
boto3_docs = "boto3-docs"
aiobotocore = "aiobotocore"
aiobotocore_lite = "aiobotocore-lite"
aiobotocore_services = "aiobotocore-services"
aiobotocore_docs = "aiobotocore-docs"
aiobotocore_full = "aiobotocore-full"
aioboto3 = "aioboto3"
aioboto3_lite = "aioboto3-lite"
aioboto3_docs = "aioboto3-docs"

def __str__(self) -> str:
Expand All @@ -37,16 +40,23 @@ def get_library(self) -> ProductLibrary:
Get library name.
"""
match self:
case Product.boto3 | Product.boto3_services | Product.boto3_full | Product.boto3_docs:
case (
Product.boto3
| Product.boto3_lite
| Product.boto3_services
| Product.boto3_full
| Product.boto3_docs
):
return ProductLibrary.boto3
case (
Product.aiobotocore
| Product.aiobotocore_lite
| Product.aiobotocore_services
| Product.aiobotocore_full
| Product.aiobotocore_docs
):
return ProductLibrary.aiobotocore
case Product.aioboto3 | Product.aioboto3_docs:
case Product.aioboto3 | Product.aioboto3_lite | Product.aioboto3_docs:
return ProductLibrary.aioboto3

def get_type(self) -> ProductType:
Expand All @@ -56,6 +66,8 @@ def get_type(self) -> ProductType:
match self:
case Product.boto3 | Product.aiobotocore | Product.aioboto3:
return ProductType.stubs
case Product.boto3_lite | Product.aiobotocore_lite | Product.aioboto3_lite:
return ProductType.stubs_lite
case Product.boto3_services | Product.aiobotocore_services:
return ProductType.service_stubs
case Product.boto3_docs | Product.aiobotocore_docs | Product.aioboto3_docs:
Expand Down
1 change: 1 addition & 0 deletions mypy_boto3_builder/enums/product_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ProductType(Enum):
"""

stubs = "stubs"
stubs_lite = "stubs_lite"
service_stubs = "service_stubs"
docs = "docs"
full = "full"
Expand Down
25 changes: 14 additions & 11 deletions mypy_boto3_builder/generators/aioboto3_generator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
AioBoto3 stubs generator.
Generator for types-aioboto3 packages.
Copyright 2024 Vlad Emelianov
"""
Expand Down Expand Up @@ -27,7 +27,7 @@

class AioBoto3Generator(BaseGenerator):
"""
AioBoto3 stubs generator.
Generator for types-aioboto3 packages.
"""

service_package_data = TypesAioBoto3PackageData
Expand All @@ -38,7 +38,7 @@ def _get_static_files_path(self) -> Path:
StaticStubsPullURL.types_aioboto3,
)

def get_postprocessor(self, service_package: ServicePackage) -> AioBoto3Postprocessor:
def _get_postprocessor(self, service_package: ServicePackage) -> AioBoto3Postprocessor:
"""
Get postprocessor for service package.
"""
Expand All @@ -48,17 +48,20 @@ def generate_stubs(self) -> list[Package]:
"""
Generate `types-aioboto3` package.
"""
packages: list[Package] = []
package: Package | None = self._generate_stubs()
package = self._generate_stubs()
if package:
packages.append(package)
return [package]

if not self.config.skip_lite_package:
package = self._generate_stubs_lite()
if package:
packages.append(package)
return []

return packages
def generate_stubs_lite(self) -> list[Package]:
"""
Generate `types-aioboto3-lite` package.
"""
package = self._generate_stubs_lite()
if package:
return [package]
return []

def _generate_stubs(self) -> TypesAioBoto3Package | None:
package_data = TypesAioBoto3PackageData
Expand Down
29 changes: 16 additions & 13 deletions mypy_boto3_builder/generators/aiobotocore_generator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
AioBotocore stubs/docs generator.
Generator for types-aiobotocore packages.
Copyright 2024 Vlad Emelianov
"""
Expand Down Expand Up @@ -32,7 +32,7 @@

class AioBotocoreGenerator(BaseGenerator):
"""
AioBotocore stubs/docs generator.
Generator for types-aiobotocore packages.
"""

service_package_data = TypesAioBotocorePackageData
Expand All @@ -44,27 +44,30 @@ def _get_static_files_path(self) -> Path:
StaticStubsPullURL.types_aiobotocore,
)

def get_postprocessor(self, service_package: ServicePackage) -> AioBotocorePostprocessor:
def _get_postprocessor(self, service_package: ServicePackage) -> AioBotocorePostprocessor:
"""
Get postprocessor for service package.
"""
return AioBotocorePostprocessor(service_package, self.master_service_names)

def generate_stubs(self) -> list[Package]:
"""
Generate `aiobotocore-stubs` package.
Generate `types-aiobotocore` package.
"""
packages: list[Package] = []
package: Package | None = self._generate_stubs()
package = self._generate_stubs()
if package:
packages.append(package)
return [package]

if not self.config.skip_lite_package:
package = self._generate_stubs_lite()
if package:
packages.append(package)
return []

return packages
def generate_stubs_lite(self) -> list[Package]:
"""
Generate `types-aiobotocore-lite` package.
"""
package = self._generate_stubs_lite()
if package:
return [package]
return []

def _generate_stubs(self) -> TypesAioBotocorePackage | None:
package_data = TypesAioBotocorePackageData
Expand Down Expand Up @@ -127,7 +130,7 @@ def generate_docs(self) -> None:

def generate_full_stubs(self) -> list[Package]:
"""
Generate full stubs.
Generate `types-aiobotocore-full` package.
"""
package_data = TypesAioBotocoreFullPackageData
try:
Expand Down
18 changes: 12 additions & 6 deletions mypy_boto3_builder/generators/base_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(
self.master_service_names = master_service_names
self.config = config
self.logger = get_logger()
self.version = version or self.get_library_version()
self.version = version or self._get_library_version()
self.cleanup = cleanup
self.package_writer = PackageWriter(
output_path=self.output_path,
Expand Down Expand Up @@ -125,12 +125,12 @@ def _get_or_download_static_files_path(
return self._downloaded_static_files_path

@abstractmethod
def get_postprocessor(self, service_package: ServicePackage) -> BasePostprocessor:
def _get_postprocessor(self, service_package: ServicePackage) -> BasePostprocessor:
"""
Get postprocessor for service package.
"""

def get_library_version(self) -> str:
def _get_library_version(self) -> str:
"""
Get underlying library version.
"""
Expand All @@ -153,14 +153,18 @@ def generate_stubs(self) -> Sequence[Package]:
"""
Generate main stubs.
"""
raise NotImplementedError("Method should be implemented in child class")

@abstractmethod
def generate_stubs_lite(self) -> Sequence[Package]:
"""
Generate main stubs.
"""

@abstractmethod
def generate_full_stubs(self) -> Sequence[Package]:
"""
Generate full stubs.
"""
raise NotImplementedError("Method should be implemented in child class")

@abstractmethod
def generate_custom_stubs(self) -> Sequence[Package]:
Expand Down Expand Up @@ -210,6 +214,8 @@ def generate_product(self, product_type: ProductType) -> None:
match product_type:
case ProductType.stubs:
packages.extend(self.generate_stubs())
case ProductType.stubs_lite:
packages.extend(self.generate_stubs_lite())
case ProductType.service_stubs:
packages.extend(self.generate_service_stubs())
case ProductType.docs:
Expand Down Expand Up @@ -237,7 +243,7 @@ def _parse_service_package(
parser = ServicePackageParser(service_name, package_data, version)
service_package = parser.parse()

postprocessor = self.get_postprocessor(service_package)
postprocessor = self._get_postprocessor(service_package)
postprocessor.generate_docstrings()
postprocessor.process_package()

Expand Down
32 changes: 18 additions & 14 deletions mypy_boto3_builder/generators/boto3_generator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Boto3 stubs/docs generator.
Generator for boto3-stubs packages.
Copyright 2024 Vlad Emelianov
"""
Expand Down Expand Up @@ -35,13 +35,13 @@

class Boto3Generator(BaseGenerator):
"""
Boto3 stubs/docs generator.
Generator for boto3-stubs packages.
"""

service_package_data = Boto3StubsPackageData
service_template_path = TemplatePath.boto3_stubs_service

def get_postprocessor(self, service_package: ServicePackage) -> BotocorePostprocessor:
def _get_postprocessor(self, service_package: ServicePackage) -> BotocorePostprocessor:
"""
Get postprocessor for service package.
"""
Expand Down Expand Up @@ -72,7 +72,7 @@ def _get_static_files_path(self) -> Path:
StaticStubsPullURL.boto3_stubs,
)

def _generate_boto3_stubs(self) -> Boto3StubsPackage | None:
def _generate_stubs(self) -> Boto3StubsPackage | None:
package_data = Boto3StubsPackageData
try:
version = self._get_package_version(package_data.PYPI_NAME, self.version)
Expand All @@ -89,7 +89,7 @@ def _generate_boto3_stubs(self) -> Boto3StubsPackage | None:
static_files_path=self._get_static_files_path(),
)

def _generate_boto3_stubs_lite(self) -> Boto3StubsPackage | None:
def _generate_stubs_lite(self) -> Boto3StubsPackage | None:
package_data = Boto3StubsLitePackageData
try:
version = self._get_package_version(package_data.PYPI_NAME, self.version)
Expand All @@ -108,27 +108,31 @@ def _generate_boto3_stubs_lite(self) -> Boto3StubsPackage | None:

def generate_stubs(self) -> list[Package]:
"""
Generate main stubs.
Generate `boto3-stubs` package.
"""
result: list[Package] = []
package: Package | None = None

package = self._generate_boto3_stubs()
package = self._generate_stubs()
if package:
result.append(package)

if not self.config.skip_lite_package and self.is_package():
if not self.is_package():
package = self._generate_master()
if package:
result.append(package)

if not self.config.skip_lite_package:
package = self._generate_boto3_stubs_lite()
if package:
result.append(package)

return result

def generate_stubs_lite(self) -> list[Package]:
"""
Generate `boto3-stubs-lite` package.
"""
package = self._generate_stubs_lite()
if package:
return [package]
return []

def generate_docs(self) -> None:
"""
Generate service and master docs.
Expand Down Expand Up @@ -156,7 +160,7 @@ def generate_docs(self) -> None:

def generate_full_stubs(self) -> list[Package]:
"""
Generate full stubs.
Generate `boto3-stubs-full` package.
"""
package_data = Boto3StubsFullPackageData
try:
Expand Down
Loading

0 comments on commit ef08520

Please sign in to comment.