-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pip_setup): Run pip setup extract in the correct directory (#8320)
- Loading branch information
Showing
5 changed files
with
42 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
import { dirname } from 'path'; | ||
import { join } from 'upath'; | ||
import dataFiles from '../../data-files.generated'; | ||
import { readLocalFile, writeLocalFile } from '../../util/fs'; | ||
import { ensureCacheDir, outputFile, readLocalFile } from '../../util/fs'; | ||
|
||
// need to match filename in `data/extract.py` | ||
const REPORT = 'renovate-pip_setup-report.json'; | ||
const EXTRACT = 'renovate-pip_setup-extract.py'; | ||
|
||
let extractPy: string | undefined; | ||
|
||
export async function copyExtractFile(): Promise<string> { | ||
if (extractPy === undefined) { | ||
extractPy = dataFiles.get('extract.py'); | ||
export async function getExtractFile(): Promise<string> { | ||
if (extractPy) { | ||
return extractPy; | ||
} | ||
|
||
await writeLocalFile(EXTRACT, extractPy); | ||
const cacheDir = await ensureCacheDir('./others/pip_setup'); | ||
extractPy = join(cacheDir, EXTRACT); | ||
await outputFile(extractPy, dataFiles.get('extract.py')); | ||
|
||
return EXTRACT; | ||
return extractPy; | ||
} | ||
|
||
export interface PythonSetup { | ||
extras_require: Record<string, string[]>; | ||
install_requires: string[]; | ||
} | ||
|
||
export async function parseReport(): Promise<PythonSetup> { | ||
const data = await readLocalFile(REPORT, 'utf8'); | ||
export async function parseReport(packageFile: string): Promise<PythonSetup> { | ||
const data = await readLocalFile(join(dirname(packageFile), REPORT), 'utf8'); | ||
return JSON.parse(data); | ||
} |