[python] compartmentalize generation-subdir#10254
[python] compartmentalize generation-subdir#10254iscai-msft wants to merge 2 commits intomicrosoft:mainfrom
Conversation
commit: |
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
|
|
||
| # write _version.py | ||
| self._serialize_and_write_version_file(general_serializer) | ||
| # if there's a subdir, we need to write another version file in the subdir |
There was a problem hiding this comment.
pyproject.toml get version info for _versoin.py which is from root namespace like https://github.com/Azure/autorest.python/blob/f684c1d65081a905004d21be8dc2e7d6efb902ee/packages/typespec-python/test/azure/generated/routes/pyproject.toml#L46. In the future, if emitter user does not create this file, the install will fail.
I think for most emitter users, they will complain why python emitter can't work instead of create the file by themselves.
| # write the empty py.typed file | ||
| pytyped_value = "# Marker file for PEP 561." | ||
| self.write_file(root_dir / Path("py.typed"), pytyped_value) | ||
| self.write_file(generation_dir / Path("py.typed"), pytyped_value) |
There was a problem hiding this comment.
MANIFEST.in pack py.typed at root namespace like https://github.com/Azure/autorest.python/blob/f684c1d65081a905004d21be8dc2e7d6efb902ee/packages/typespec-python/test/azure/generated/routes/MANIFEST.in instead of generation subdir
| if any(og for client in self.code_model.clients for og in client.operation_groups if og.need_validation): | ||
| self.write_file( | ||
| root_dir / Path("_validation.py"), | ||
| generation_dir / Path("_validation.py"), |
There was a problem hiding this comment.
we don't have enough test about _validation.py in generation-subdir scenario, and this change may influence import since current emitter always assume _validation.py is in root namespace.
| if self.code_model.named_unions: | ||
| self.write_file( | ||
| root_dir / Path("_types.py"), | ||
| generation_dir / Path("_types.py"), |
There was a problem hiding this comment.
| generation_dir / Path("_types.py"), | ||
| TypesSerializer(code_model=self.code_model, env=env).serialize(), | ||
| ) | ||
|
|
There was a problem hiding this comment.
for _version.py/py.typed which actually does not influence package strcture, I advise we just keep them at root namespace.
For _validation.py/_types.py, I am OK to move them into generation-subdir but we may need update import logic related with them and add test case to cover similar scenario.
right now, we're modifying files above the specified
generation-subdir. My belief is that when a user specifiesgeneration-subidr, we don't touch anything. We might want to touch the packaging files, that is debatable though.