Skip to content
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

Refactor collect_package_data to make logic clearer #120

Merged
merged 7 commits into from
Jan 29, 2024

Conversation

srittau
Copy link
Contributor

@srittau srittau commented Jan 8, 2024

Depends on #119

This is a preliminary refactoring for fixing python/typeshed#11254. The idea is that the new class `PackageData` encapsulates all data concerning packages and their contents. This allows us later to find the top-level non-namespace packages, instead of just the top-level packages as we are doing now.
@srittau srittau marked this pull request as draft January 8, 2024 05:14
Comment on lines +233 to +242
elif entry.is_file() and entry.suffix == ".pyi":
pkg_name = entry.stem
# Module -> package transformation is done while copying.
package_data[pkg_name] = ["__init__.pyi"]
stub_files = ["__init__.pyi"]
elif entry.is_dir():
pkg_name = entry.name
stub_files = find_stub_files(str(entry))
else:
if entry.name == TESTS_NAMESPACE:
continue
pkg_name = entry.name + SUFFIX
package_data[pkg_name] = find_stub_files(str(entry))
package_data[pkg_name].append(META)
raise ValueError(f"Only stub files are allowed, not {entry.name!r}")
package_data[pkg_name + SUFFIX] = [*stub_files, META]
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you won't wanna do that now, but since you're touching this area of code I'll mention it:
With #112 (setuptools v69) , the stub_files logic could become unnecessary.

According to https://setuptools.pypa.io/en/stable/userguide/miscellaneous.html#controlling-files-in-the-distribution this is an opt-out feature, so you shouldn't need to add anything new either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's punt this to a separate PR to keep this as a simple refactoring.

Base automatically changed from pkg-data to main January 11, 2024 03:54
@srittau srittau marked this pull request as ready for review January 12, 2024 10:42
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.

New logic checks out and is easier to reason about.

@srittau srittau merged commit 6f4313f into main Jan 29, 2024
6 checks passed
@srittau srittau deleted the refactor-collect-pkg-data branch January 29, 2024 17:37
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