typeshed-internal / stub_uploader

Scripts and actions to auto-upload typeshed stubs to PyPI
Apache License 2.0
21 stars 16 forks source link

Fix py.typed file creation #121

Closed srittau closed 5 months ago

srittau commented 8 months ago

Currently, when building a distribution, if a py.typed file needs to be created, this happens during the generate_setup_file() step. The file is added to the typeshed directory and will get copied to the tmp dir during the copy_stubs() step. This is problematic for a few reasons:

The solution is to create a new step between copy_stubs() and copy_changelog() that creates the py.typed marker directly in the tmpdir. I'll send a PR after the current batch of PRs was processed.

Avasam commented 7 months ago

Btw I found why py.typed files are missing from namespace packages. The path added to package_data is just wrong. Something like this outta do it: image

top_level, *sub_packages = package.split(".")
entry_path = self.package_path(package)
entry_path.mkdir(exist_ok=True)
(entry_path / filename).write_text(file_contents)
self.package_data[top_level].append(os.path.join(*sub_packages, filename))

This issue is about refactoring that part of the code anyway. So I'll leave this here.