Skip to content

Commit 22fdaac

Browse files
committed
boulder: Normalize python providers
Boulder generates providers by using the module's name. If module's name contains a '_', it will cause a provider/dependency mismatch. This is solved by simply adding additional providers by replacing '_' with '-' in the module's name.
1 parent c0457e1 commit 22fdaac

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

boulder/src/package/analysis/handler.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ pub fn python(bucket: &mut BucketMut<'_>, info: &mut PathInfo) -> Result<Respons
144144
name: python_name.to_string(),
145145
});
146146

147+
if python_name.contains("_") {
148+
/* Insert normalized generic provider */
149+
bucket.providers.insert(Provider {
150+
kind: dependency::Kind::Python,
151+
name: python_name.replace("_", "-").to_string(),
152+
});
153+
}
154+
147155
let output = Command::new("/usr/bin/python3")
148156
.arg("-c")
149157
.arg("import platform; print(f'{platform.python_version_tuple()[0]}.{platform.python_version_tuple()[1]}')")
@@ -157,6 +165,18 @@ pub fn python(bucket: &mut BucketMut<'_>, info: &mut PathInfo) -> Result<Respons
157165
name: format!("{python_name}({})", &python_version.to_string().trim_end()),
158166
});
159167

168+
if python_name.contains("_") {
169+
/* Insert normalized versioned provider */
170+
bucket.providers.insert(Provider {
171+
kind: dependency::Kind::Python,
172+
name: format!(
173+
"{}({})",
174+
python_name.replace("_", "-").to_string(),
175+
&python_version.to_string().trim_end()
176+
),
177+
});
178+
}
179+
160180
/* Now parse dependencies */
161181
let dist_path = info
162182
.path

0 commit comments

Comments
 (0)