Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions src/providers/python_uv.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,52 @@ export default class Python_uv extends Base_pyproject {
* @param {string} workspaceDir - workspace root (for resolving editable install paths)
* @param {object} parsed - parsed pyproject.toml
* @param {Object} opts
* @returns {Promise<{directDeps: string[], graph: Map<string, {name: string, version: string, children: string[]}>}>}
* @returns {Promise<{directDeps: string[], graph: Map<string, import('./base_pyproject.js').default.GraphEntry>}>}
*/
async _getDependencyData(manifestDir, workspaceDir, parsed, opts) {
let projectName = this._getProjectName(parsed)
let uvOutput = this._getUvExportOutput(manifestDir, opts)
return this._parseUvExport(uvOutput, projectName, workspaceDir)
let { directDeps, graph } = await this._parseUvExport(uvOutput, projectName, workspaceDir)
this._attachHashesFromLockFile(path.join(workspaceDir, 'uv.lock'), graph)
return { directDeps, graph }
}

/**
* Parse uv.lock and attach SHA-256 hashes to graph entries.
* @param {string} lockFilePath - path to uv.lock
* @param {Map<string, import('./base_pyproject.js').GraphEntry>} graph
*/
_attachHashesFromLockFile(lockFilePath, graph) {
let lockContent
try {
lockContent = fs.readFileSync(lockFilePath, 'utf-8')
} catch (e) {
console.error(`uv: could not read lock file ${lockFilePath}: ${e.message}`)
return
}

let parsed
try {
parsed = parseToml(lockContent)
} catch (e) {
console.error(`uv: could not parse lock file ${lockFilePath}: ${e.message}`)
return
}

let packages = parsed.package
if (!Array.isArray(packages)) { return }

for (let pkg of packages) {
if (!pkg.name) { continue }
let hashStr = pkg.sdist?.hash || pkg.wheels?.[0]?.hash
if (!hashStr || !hashStr.startsWith('sha256:')) { continue }

let key = this._canonicalize(pkg.name)
let entry = graph.get(key)
if (!entry || entry.hashes) { continue }

entry.hashes = [{alg: "SHA-256", content: hashStr.slice(7)}]
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,39 @@
"version": "2.0.3",
"purl": "pkg:pypi/flask@2.0.3",
"type": "library",
"bom-ref": "pkg:pypi/flask@2.0.3"
"bom-ref": "pkg:pypi/flask@2.0.3",
"hashes": [
{
"alg": "SHA-256",
"content": "e1120c228ca2f553b470df4a5fa927ab66258467526069981b3eb0a91902687d"
}
]
},
{
"name": "requests",
"version": "2.25.1",
"purl": "pkg:pypi/requests@2.25.1",
"type": "library",
"bom-ref": "pkg:pypi/requests@2.25.1"
"bom-ref": "pkg:pypi/requests@2.25.1",
"hashes": [
{
"alg": "SHA-256",
"content": "27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804"
}
]
},
{
"name": "typing-extensions",
"version": "4.1.1",
"purl": "pkg:pypi/typing-extensions@4.1.1",
"type": "library",
"bom-ref": "pkg:pypi/typing-extensions@4.1.1"
"bom-ref": "pkg:pypi/typing-extensions@4.1.1",
"hashes": [
{
"alg": "SHA-256",
"content": "1a9462dcc3347a79b1f1c0271fbe79e844580bb598bafa1ed208b94da3cdcd42"
}
]
}
],
"dependencies": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,77 +18,143 @@
"version": "2.0.3",
"purl": "pkg:pypi/flask@2.0.3",
"type": "library",
"bom-ref": "pkg:pypi/flask@2.0.3"
"bom-ref": "pkg:pypi/flask@2.0.3",
"hashes": [
{
"alg": "SHA-256",
"content": "e1120c228ca2f553b470df4a5fa927ab66258467526069981b3eb0a91902687d"
}
]
},
{
"name": "requests",
"version": "2.25.1",
"purl": "pkg:pypi/requests@2.25.1",
"type": "library",
"bom-ref": "pkg:pypi/requests@2.25.1"
"bom-ref": "pkg:pypi/requests@2.25.1",
"hashes": [
{
"alg": "SHA-256",
"content": "27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804"
}
]
},
{
"name": "typing-extensions",
"version": "4.1.1",
"purl": "pkg:pypi/typing-extensions@4.1.1",
"type": "library",
"bom-ref": "pkg:pypi/typing-extensions@4.1.1"
"bom-ref": "pkg:pypi/typing-extensions@4.1.1",
"hashes": [
{
"alg": "SHA-256",
"content": "1a9462dcc3347a79b1f1c0271fbe79e844580bb598bafa1ed208b94da3cdcd42"
}
]
},
{
"name": "click",
"version": "8.3.1",
"purl": "pkg:pypi/click@8.3.1",
"type": "library",
"bom-ref": "pkg:pypi/click@8.3.1"
"bom-ref": "pkg:pypi/click@8.3.1",
"hashes": [
{
"alg": "SHA-256",
"content": "12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a"
}
]
},
{
"name": "itsdangerous",
"version": "2.0.1",
"purl": "pkg:pypi/itsdangerous@2.0.1",
"type": "library",
"bom-ref": "pkg:pypi/itsdangerous@2.0.1"
"bom-ref": "pkg:pypi/itsdangerous@2.0.1",
"hashes": [
{
"alg": "SHA-256",
"content": "9e724d68fc22902a1435351f84c3fb8623f303fffcc566a4cb952df8c572cff0"
}
]
},
{
"name": "jinja2",
"version": "3.0.3",
"purl": "pkg:pypi/jinja2@3.0.3",
"type": "library",
"bom-ref": "pkg:pypi/jinja2@3.0.3"
"bom-ref": "pkg:pypi/jinja2@3.0.3",
"hashes": [
{
"alg": "SHA-256",
"content": "611bb273cd68f3b993fabdc4064fc858c5b47a973cb5aa7999ec1ba405c87cd7"
}
]
},
{
"name": "werkzeug",
"version": "2.0.3",
"purl": "pkg:pypi/werkzeug@2.0.3",
"type": "library",
"bom-ref": "pkg:pypi/werkzeug@2.0.3"
"bom-ref": "pkg:pypi/werkzeug@2.0.3",
"hashes": [
{
"alg": "SHA-256",
"content": "b863f8ff057c522164b6067c9e28b041161b4be5ba4d0daceeaa50a163822d3c"
}
]
},
{
"name": "certifi",
"version": "2023.7.22",
"purl": "pkg:pypi/certifi@2023.7.22",
"type": "library",
"bom-ref": "pkg:pypi/certifi@2023.7.22"
"bom-ref": "pkg:pypi/certifi@2023.7.22",
"hashes": [
{
"alg": "SHA-256",
"content": "539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082"
}
]
},
{
"name": "chardet",
"version": "4.0.0",
"purl": "pkg:pypi/chardet@4.0.0",
"type": "library",
"bom-ref": "pkg:pypi/chardet@4.0.0"
"bom-ref": "pkg:pypi/chardet@4.0.0",
"hashes": [
{
"alg": "SHA-256",
"content": "0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa"
}
]
},
{
"name": "idna",
"version": "2.10",
"purl": "pkg:pypi/idna@2.10",
"type": "library",
"bom-ref": "pkg:pypi/idna@2.10"
"bom-ref": "pkg:pypi/idna@2.10",
"hashes": [
{
"alg": "SHA-256",
"content": "b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"
}
]
},
{
"name": "urllib3",
"version": "1.26.16",
"purl": "pkg:pypi/urllib3@1.26.16",
"type": "library",
"bom-ref": "pkg:pypi/urllib3@1.26.16"
"bom-ref": "pkg:pypi/urllib3@1.26.16",
"hashes": [
{
"alg": "SHA-256",
"content": "8f135f6502756bde6b2a9b28989df5fbe87c9970cecaa69041edcce7f0589b14"
}
]
}
],
"dependencies": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
"version": "2.33.1",
"purl": "pkg:pypi/requests@2.33.1",
"type": "library",
"bom-ref": "pkg:pypi/requests@2.33.1"
"bom-ref": "pkg:pypi/requests@2.33.1",
"hashes": [
{
"alg": "SHA-256",
"content": "18817f8c57c6263968bc123d237e3b8b08ac046f5456bd1e307ee8f4250d3517"
}
]
}
],
"dependencies": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,65 @@
"version": "2.33.1",
"purl": "pkg:pypi/requests@2.33.1",
"type": "library",
"bom-ref": "pkg:pypi/requests@2.33.1"
"bom-ref": "pkg:pypi/requests@2.33.1",
"hashes": [
{
"alg": "SHA-256",
"content": "18817f8c57c6263968bc123d237e3b8b08ac046f5456bd1e307ee8f4250d3517"
}
]
},
{
"name": "certifi",
"version": "2026.2.25",
"purl": "pkg:pypi/certifi@2026.2.25",
"type": "library",
"bom-ref": "pkg:pypi/certifi@2026.2.25"
"bom-ref": "pkg:pypi/certifi@2026.2.25",
"hashes": [
{
"alg": "SHA-256",
"content": "e887ab5cee78ea814d3472169153c2d12cd43b14bd03329a39a9c6e2e80bfba7"
}
]
},
{
"name": "charset-normalizer",
"version": "3.4.7",
"purl": "pkg:pypi/charset-normalizer@3.4.7",
"type": "library",
"bom-ref": "pkg:pypi/charset-normalizer@3.4.7"
"bom-ref": "pkg:pypi/charset-normalizer@3.4.7",
"hashes": [
{
"alg": "SHA-256",
"content": "ae89db9e5f98a11a4bf50407d4363e7b09b31e55bc117b4f7d80aab97ba009e5"
}
]
},
{
"name": "idna",
"version": "3.11",
"purl": "pkg:pypi/idna@3.11",
"type": "library",
"bom-ref": "pkg:pypi/idna@3.11"
"bom-ref": "pkg:pypi/idna@3.11",
"hashes": [
{
"alg": "SHA-256",
"content": "795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902"
}
]
},
{
"name": "urllib3",
"version": "2.6.3",
"purl": "pkg:pypi/urllib3@2.6.3",
"type": "library",
"bom-ref": "pkg:pypi/urllib3@2.6.3"
"bom-ref": "pkg:pypi/urllib3@2.6.3",
"hashes": [
{
"alg": "SHA-256",
"content": "1b62b6884944a57dbe321509ab94fd4d3b307075e0c2eae991ac71ee15ad38ed"
}
]
}
],
"dependencies": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,26 @@
"version": "2.0.3",
"purl": "pkg:pypi/flask@2.0.3",
"type": "library",
"bom-ref": "pkg:pypi/flask@2.0.3"
"bom-ref": "pkg:pypi/flask@2.0.3",
"hashes": [
{
"alg": "SHA-256",
"content": "e1120c228ca2f553b470df4a5fa927ab66258467526069981b3eb0a91902687d"
}
]
},
{
"name": "requests",
"version": "2.25.1",
"purl": "pkg:pypi/requests@2.25.1",
"type": "library",
"bom-ref": "pkg:pypi/requests@2.25.1"
"bom-ref": "pkg:pypi/requests@2.25.1",
"hashes": [
{
"alg": "SHA-256",
"content": "27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804"
}
]
}
],
"dependencies": [
Expand Down
Loading
Loading