({
workPath,
uvPath,
pythonBin,
env,
onStdout,
onStderr,
}: DevPythonOptions)
| 134 | } |
| 135 | |
| 136 | async function syncDependencies({ |
| 137 | workPath, |
| 138 | uvPath, |
| 139 | pythonBin, |
| 140 | env, |
| 141 | onStdout, |
| 142 | onStderr, |
| 143 | }: DevPythonOptions): Promise<void> { |
| 144 | const pythonPackage = await discoverPackage({ |
| 145 | entrypointDir: workPath, |
| 146 | rootDir: workPath, |
| 147 | }); |
| 148 | |
| 149 | const installInfo = detectInstallSource(pythonPackage, workPath); |
| 150 | |
| 151 | const { manifestType } = installInfo; |
| 152 | let { manifestPath } = installInfo; |
| 153 | const manifest = pythonPackage.manifest; |
| 154 | |
| 155 | if (!manifestType || !manifestPath) { |
| 156 | debug('No Python project manifest found, skipping dependency sync'); |
| 157 | return; |
| 158 | } |
| 159 | |
| 160 | // Store converted into manifest requirements, so we can run the sync |
| 161 | if (manifest?.origin && manifestType === 'pyproject.toml') { |
| 162 | const syncDir = join(workPath, '.vercel', 'python', 'sync'); |
| 163 | mkdirSync(syncDir, { recursive: true }); |
| 164 | const tempPyproject = join(syncDir, 'pyproject.toml'); |
| 165 | const content = stringifyManifest(manifest.data); |
| 166 | writeFileSync(tempPyproject, content, 'utf8'); |
| 167 | manifestPath = tempPyproject; |
| 168 | debug( |
| 169 | `Wrote converted ${manifest.origin.kind} manifest to ${tempPyproject}` |
| 170 | ); |
| 171 | } |
| 172 | |
| 173 | const writeOut = (msg: string) => { |
| 174 | if (onStdout) { |
| 175 | onStdout(Buffer.from(msg)); |
| 176 | } else { |
| 177 | process.stdout.write(msg); |
| 178 | } |
| 179 | }; |
| 180 | |
| 181 | const writeErr = (msg: string) => { |
| 182 | if (onStderr) { |
| 183 | onStderr(Buffer.from(msg)); |
| 184 | } else { |
| 185 | process.stderr.write(msg); |
| 186 | } |
| 187 | }; |
| 188 | |
| 189 | // Silence the output, but capture it for failures |
| 190 | const captured: Array<['stdout' | 'stderr', Buffer]> = []; |
| 191 | |
| 192 | try { |
| 193 | await runSync({ |
no test coverage detected