Skip to content

Commit

Permalink
Split .tar.gz setup and source dist writing
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Dec 2, 2024
1 parent 0cdb697 commit 453be5f
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions crates/uv-build-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,25 @@ pub fn build_source_dist(
source_tree: &Path,
source_dist_directory: &Path,
uv_version: &str,
) -> Result<SourceDistFilename, Error> {
let contents = fs_err::read_to_string(source_tree.join("pyproject.toml"))?;
let pyproject_toml = PyProjectToml::parse(&contents)?;
let filename = SourceDistFilename {
name: pyproject_toml.name().clone(),
version: pyproject_toml.version().clone(),
extension: SourceDistExtension::TarGz,
};
let source_dist_path = source_dist_directory.join(filename.to_string());
let writer = TarGzWriter::new(&source_dist_path)?;
write_source_dist(source_tree, writer, uv_version)?;
Ok(filename)
}

/// Shared implementation for building and listing a source distribution.
fn write_source_dist(
source_tree: &Path,
mut writer: impl DirectoryWriter,
uv_version: &str,
) -> Result<SourceDistFilename, Error> {
let contents = fs_err::read_to_string(source_tree.join("pyproject.toml"))?;
let pyproject_toml = PyProjectToml::parse(&contents)?;
Expand All @@ -702,9 +721,6 @@ pub fn build_source_dist(
pyproject_toml.version()
);

let source_dist_path = source_dist_directory.join(filename.to_string());
let mut writer = TarGzWriter::new(&source_dist_path)?;

let metadata = pyproject_toml.to_metadata(source_tree)?;
let metadata_email = metadata.core_metadata_format();

Expand Down

0 comments on commit 453be5f

Please sign in to comment.