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

Fix py.typed file creation #121

Closed
srittau opened this issue Jan 12, 2024 · 1 comment · Fixed by #129
Closed

Fix py.typed file creation #121

srittau opened this issue Jan 12, 2024 · 1 comment · Fixed by #129
Assignees
Labels
bug Something isn't working

Comments

@srittau
Copy link
Contributor

srittau commented Jan 12, 2024

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:

  • Conceptually, generate_setup_file() makes no modifications. It just returns the setup.py file as a string. The exception being creating the py.typed file if necessary.
  • The build process now modifies the typeshed directory, when it should be considered "read-only".
  • This also means that the build process can't be started twice before cleaning the typeshed dir.
  • This is especially problematic in local development environments, where your local typeshed directory gets modified and you can't run the integration tests twice.

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

Avasam commented Feb 9, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants