Skip to content

Fix py.typed in namespace packages #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 29, 2024
Merged

Fix py.typed in namespace packages #122

merged 3 commits into from
Jan 29, 2024

Conversation

srittau
Copy link
Member

@srittau srittau commented Jan 12, 2024

Previously, the py.typed file was incorrectly put in the namespace package, instead of the non-namespace sub-packages.

Previously, the py.typed file was incorrectly put in the namespace package, instead of the non-namespace sub-packages.
@srittau
Copy link
Member Author

srittau commented Jan 12, 2024

Cc @Avasam

@srittau
Copy link
Member Author

srittau commented Jan 24, 2024

Could someone review this? The google packages are still broken.

@Avasam
Copy link
Contributor

Avasam commented Jan 24, 2024

I am back from vacation / AGDQ, I'll try to review as soon as I can, thanks for the bump

Copy link
Contributor

@Avasam Avasam left a comment

Choose a reason for hiding this comment

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

I have one optional suggestion and one request for an additional test concerning py.typed files. Otherwise LGTM.

distribution: str, expected_packages: list[str]
) -> None:
pkg_data = build_wheel.collect_package_data(THIRD_PARTY_PATH / distribution)
assert pkg_data.top_level_non_namespace_packages == expected_packages
Copy link
Contributor

@Avasam Avasam Jan 26, 2024

Choose a reason for hiding this comment

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

I just noticed, I think there's no test to validate that py.typed is added to the right location(s) (top_level_non_namespace_packages), only that we properly list the locations it should go. Could we add unit tests for the if metadata.partial branch of generate_setup_file calling add_partial_markers?

image

Edit: Unless you wanna do that as part of #121

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea, but I think it makes more sense as part of #121, considering the current command/query mixture.

srittau and others added 2 commits January 29, 2024 12:08
@srittau srittau merged commit c7e93a9 into main Jan 29, 2024
@srittau srittau deleted the fix-py-typed branch January 29, 2024 16:42
@srittau
Copy link
Member Author

srittau commented Jan 29, 2024

Unfortunately, it seems that py.typed is now dropped completely from the package. I'll look into it later.

@Avasam
Copy link
Contributor

Avasam commented Jan 29, 2024

Unfortunately, it seems that py.typed is now dropped completely from the package. I'll look into it later.

Odd. The markers are generated in the right location when I run the test_build_wheel test locally
image

@srittau
Copy link
Member Author

srittau commented Jan 29, 2024

It's been a few weeks, but I also remember testing this locally where it seemed to work. Probably best to just work on #121 instead of trying to find this bug.

@Avasam
Copy link
Contributor

Avasam commented Jan 30, 2024

@srittau Should I wait before merging PRs relating to partial stubs? (ie python/typeshed#11255)
iirc would affect type-checking users that also use modules missing from typeshed.

Our inclusion or partial py.typed marker is relatively new anyway, so realistically it won't affect many users.

@srittau
Copy link
Member Author

srittau commented Jan 30, 2024

I would actually be interested if it also affects partial non-namespace packages.

@Avasam
Copy link
Contributor

Avasam commented Jan 30, 2024

I would actually be interested if it also affects partial non-namespace packages.

pyopenssl was released 20h ago and contains the marker file
https://pypi.org/project/types-pyOpenSSL/#history
image

I believe this PR was merged 29h ago?

If that's still too close/unsure, you'll know for sure once tensorflow (modified 3h ago) deploys.


I think I understand what you're thinking of: maybe only namespace packages are missing the py.typed file. Which could be caused, for example, by an incorrect path added to package_data (or some other distribution-specific issue)

Edit: yep, tensorflow has the marker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants