diff --git a/.chronus/changes/python-generationSubdirContainment-2026-3-2-15-8-40.md b/.chronus/changes/python-generationSubdirContainment-2026-3-2-15-8-40.md new file mode 100644 index 00000000000..d0b6fd6e0fb --- /dev/null +++ b/.chronus/changes/python-generationSubdirContainment-2026-3-2-15-8-40.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/http-client-python" +--- + +Contain emitter changes when used with `generation-subdir` to solely within that subdirectory \ No newline at end of file diff --git a/packages/http-client-python/generator/pygen/codegen/serializers/__init__.py b/packages/http-client-python/generator/pygen/codegen/serializers/__init__.py index a95b1fd2f27..b49c45e5904 100644 --- a/packages/http-client-python/generator/pygen/codegen/serializers/__init__.py +++ b/packages/http-client-python/generator/pygen/codegen/serializers/__init__.py @@ -498,18 +498,17 @@ def _serialize_and_write_top_level_folder(self, env: Environment, namespace: str general_serializer = GeneralSerializer(code_model=self.code_model, env=env, async_mode=False) # write _version.py + # Always write at root namespace since pyproject.toml references it there self._serialize_and_write_version_file(general_serializer) - # if there's a subdir, we need to write another version file in the subdir if self.code_model.options.get("generation-subdir"): self._serialize_and_write_version_file(general_serializer, namespace) # write the empty py.typed file + # Always write at root namespace since MANIFEST.in references it there pytyped_value = "# Marker file for PEP 561." self.write_file(root_dir / Path("py.typed"), pytyped_value) # write _validation.py - # Use generation_dir so that relative imports from operations/clients - # within a generation-subdir resolve correctly. if any(og for client in self.code_model.clients for og in client.operation_groups if og.need_validation): self.write_file( generation_dir / Path("_validation.py"),