Skip to content

[python] compartmentalize generation-subdir#10254

Open
iscai-msft wants to merge 2 commits intomicrosoft:mainfrom
iscai-msft:python/generationSubdirContainment
Open

[python] compartmentalize generation-subdir#10254
iscai-msft wants to merge 2 commits intomicrosoft:mainfrom
iscai-msft:python/generationSubdirContainment

Conversation

@iscai-msft
Copy link
Copy Markdown
Member

right now, we're modifying files above the specified generation-subdir. My belief is that when a user specifies generation-subidr, we don't touch anything. We might want to touch the packaging files, that is debatable though.

@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label Apr 2, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 2, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-python@10254

commit: 9388122

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

All changed packages have been documented.

  • @typespec/http-client-python
Show changes

@typespec/http-client-python - fix ✏️

Contain emitter changes when used with generation-subdir to solely within that subdirectory

@azure-sdk
Copy link
Copy Markdown
Collaborator

azure-sdk commented Apr 2, 2026

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension


# 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generation_dir / Path("_types.py"),
TypesSerializer(code_model=self.code_model, env=env).serialize(),
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@msyyc msyyc self-requested a review April 9, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants