@vercel/python 35.0.1-snapshot-3c48721091f5 → 36.0.0-snapshot-4bb5562899c1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +34 -15
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -5811,21 +5811,18 @@ async function getUvBinaryForBundling(pythonPath) {
5811
5811
  var UV_LINUX_TARGET = "x86_64-unknown-linux-gnu";
5812
5812
  async function downloadUvBinaryForTarget(cacheDir) {
5813
5813
  const destDir = (0, import_path2.join)(cacheDir, `uv-${UV_VERSION}-${UV_LINUX_TARGET}`);
5814
- const destBinary = (0, import_path2.join)(destDir, "uv");
5815
- try {
5816
- await import_fs2.default.promises.access(destBinary, import_fs2.default.constants.X_OK);
5817
- (0, import_build_utils2.debug)(`Using cached uv binary at ${destBinary}`);
5818
- return destBinary;
5819
- } catch {
5820
- }
5821
5814
  const tarballName = `uv-${UV_LINUX_TARGET}.tar.gz`;
5815
+ const tarballPath = (0, import_path2.join)(destDir, tarballName);
5816
+ if (await matchesUvChecksum(tarballPath)) {
5817
+ (0, import_build_utils2.debug)(`Extracting cached uv binary from ${tarballPath}`);
5818
+ return extractUvTarball(tarballPath, destDir);
5819
+ }
5822
5820
  const url = `https://github.com/astral-sh/uv/releases/download/${UV_VERSION}/${tarballName}`;
5823
5821
  (0, import_build_utils2.debug)(`Downloading uv ${UV_VERSION} from ${url}`);
5824
5822
  console.log(
5825
5823
  `Downloading uv ${UV_VERSION} (linux x86_64) for runtime dependency installation...`
5826
5824
  );
5827
5825
  await import_fs2.default.promises.mkdir(destDir, { recursive: true });
5828
- const tarballPath = (0, import_path2.join)(destDir, tarballName);
5829
5826
  await downloadUvTarball(url, tarballPath);
5830
5827
  const actualHash = await sha256File(tarballPath);
5831
5828
  if (actualHash !== UV_BINARY_CHECKSUM) {
@@ -5836,25 +5833,47 @@ async function downloadUvBinaryForTarget(cacheDir) {
5836
5833
  message: `checksum mismatch for ${tarballName}: expected ${UV_BINARY_CHECKSUM}, got ${actualHash}`
5837
5834
  });
5838
5835
  }
5836
+ const destBinary = await extractUvTarball(tarballPath, destDir);
5837
+ (0, import_build_utils2.debug)(`Downloaded uv binary to ${destBinary}`);
5838
+ return destBinary;
5839
+ }
5840
+ async function matchesUvChecksum(tarballPath) {
5841
+ try {
5842
+ return await sha256File(tarballPath) === UV_BINARY_CHECKSUM;
5843
+ } catch {
5844
+ return false;
5845
+ }
5846
+ }
5847
+ async function extractUvTarball(tarballPath, destDir) {
5848
+ const destBinary = (0, import_path2.join)(destDir, "uv");
5849
+ const stagingDir = `${destDir}.${process.pid}.${Date.now()}.tmp`;
5850
+ await import_fs2.default.promises.mkdir(stagingDir, { recursive: true });
5839
5851
  try {
5840
5852
  await (0, import_execa2.default)("tar", [
5841
5853
  "xzf",
5842
5854
  tarballPath,
5843
5855
  "--strip-components=1",
5844
5856
  "-C",
5845
- destDir
5857
+ stagingDir
5846
5858
  ]);
5859
+ const stagedBinary = (0, import_path2.join)(stagingDir, "uv");
5860
+ await import_fs2.default.promises.chmod(stagedBinary, 493);
5861
+ try {
5862
+ await import_fs2.default.promises.rename(stagedBinary, destBinary);
5863
+ } catch {
5864
+ await import_fs2.default.promises.rm(destBinary, { force: true });
5865
+ await import_fs2.default.promises.rename(stagedBinary, destBinary);
5866
+ }
5867
+ return destBinary;
5847
5868
  } catch (err) {
5848
5869
  throw new import_build_utils2.NowBuildError({
5849
5870
  code: "RUNTIME_DEPENDENCY_INSTALLATION_FAILED",
5850
- message: `could not extract ${tarballName}: ${err instanceof Error ? err.message : String(err)}`
5871
+ message: `could not extract ${(0, import_path2.basename)(tarballPath)}: ${err instanceof Error ? err.message : String(err)}`
5872
+ });
5873
+ } finally {
5874
+ await import_fs2.default.promises.rm(stagingDir, { recursive: true, force: true }).catch(() => {
5851
5875
  });
5852
5876
  }
5853
- await import_fs2.default.promises.chmod(destBinary, 493);
5854
- await import_fs2.default.promises.unlink(tarballPath).catch(() => {
5855
- });
5856
- (0, import_build_utils2.debug)(`Downloaded uv binary to ${destBinary}`);
5857
- return destBinary;
5858
5877
  }
5859
5878
  async function downloadUvTarball(url, dest) {
5860
5879
  const tmpDest = `${dest}.${process.pid}.${Date.now()}.tmp`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "35.0.1-snapshot-3c48721091f5",
3
+ "version": "36.0.0-snapshot-4bb5562899c1",
4
4
  "main": "./dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -17,7 +17,7 @@
17
17
  "@vercel/python-analysis": "0.16.0"
18
18
  },
19
19
  "peerDependencies": {
20
- "@vercel/build-utils": "15.7.0"
20
+ "@vercel/build-utils": "15.8.0-snapshot-4bb5562899c1"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@renovatebot/pep440": "4.2.1",
@@ -37,9 +37,9 @@
37
37
  "smol-toml": "1.5.2",
38
38
  "vitest": "4.1.10",
39
39
  "which": "3.0.0",
40
- "@vercel/build-utils": "15.7.0",
41
- "@vercel/python-runtime": "0.26.0",
42
- "@vercel/error-utils": "2.2.1"
40
+ "@vercel/build-utils": "15.8.0-snapshot-4bb5562899c1",
41
+ "@vercel/error-utils": "2.2.1",
42
+ "@vercel/python-runtime": "0.26.0"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "node ../../utils/build-builder.mjs",