Skip to content

Remove add_directory() from ModuleWriter trait#2824

Merged
messense merged 1 commit intoPyO3:mainfrom
e-nomem:remove-add-directory
Nov 6, 2025
Merged

Remove add_directory() from ModuleWriter trait#2824
messense merged 1 commit intoPyO3:mainfrom
e-nomem:remove-add-directory

Conversation

@e-nomem
Copy link
Copy Markdown
Contributor

@e-nomem e-nomem commented Nov 4, 2025

In #2823 I considered the idea of removing add_directory() entirely from the ModuleWriter trait since it seemed error-prone to require the programmer to ensure it was called everywhere. I decided to make a PR for that as well to see what it would look like.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors directory creation in the module writer system by removing the add_directory() method from the ModuleWriter trait and making it an implementation detail handled automatically by PathWriter when adding files.

  • Removed the add_directory() method from the ModuleWriter trait interface
  • Updated PathWriter to automatically create parent directories when adding files
  • Simplified code by removing explicit directory creation calls throughout the codebase

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/module_writer.rs Removed add_directory() from trait and all implementations; added automatic parent directory creation in PathWriter.add_bytes_with_permissions()
src/source_distribution.rs Removed explicit add_directory() calls and simplified conditional logic to skip directories
src/build_context.rs Removed unnecessary add_directory() call for libs directory
tests/common/metadata.rs Removed add_directory() implementation from MockWriter and updated test expectations to exclude directory entries
Changelog.md Added changelog entry documenting the refactoring

Comment thread Changelog.md
@messense messense merged commit a6f90c8 into PyO3:main Nov 6, 2025
82 of 86 checks passed
@messense
Copy link
Copy Markdown
Member

messense commented Nov 6, 2025

Thanks!

@e-nomem e-nomem deleted the remove-add-directory branch November 6, 2025 18:01
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.

3 participants