Skip to content
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
pydist/**/bin/python
pydist/**/bin/python3
pydist/**/bin/pip
pydist/**/bin/venv
pydist/**/bin/pip3

# pydist/3.12.6/macosx-x64/<python package root>
Expand Down
30 changes: 29 additions & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ async function getPortableWindows(version, archType, installDir) {
const archiveName = `python-${version}-embed-amd64.zip`;
const pythonZipFile = path.join(packageDist, archiveName);
const pythonZipUrl = `https://www.python.org/ftp/python/${version}/${archiveName}`;

const pipUrl = 'https://bootstrap.pypa.io/pip/pip.pyz';
const pipName = 'pip.pyz';
const pipFile = path.join(packageDist, pipName);
Expand Down Expand Up @@ -236,14 +237,22 @@ import site
);

runCommand(path.join(pyBinRoot, 'python.exe'), [pipFile, 'install', 'pip']);
runCommand(path.join(pyBinRoot, 'python.exe'), [pipFile, 'install', 'virtualenv']);
// drop pip binaries, as they are 'bound' to absolute paths on host and will not work after pl package installation anyway
fs.rmSync(path.join(pyBinRoot, 'Scripts'), { recursive: true });

// Also make python binary to be available via python3 name, like we have
// in Linux and Mac OS X (just for consistency).
fs.copyFileSync(
path.join(pyBinRoot, 'python.exe'),
path.join(pyBinRoot, 'python3.exe')
path.join(pyBinRoot, 'python3.exe'),
);

// We have to support the same tool set for all operation systems.
// Will rename virtualenv to venv.
copyDirSync(
path.join(pyBinRoot, 'Lib', 'site-packages', 'virtualenv'),
path.join(pyBinRoot, 'Lib', 'site-packages', 'venv')
);

// TODO: check this package really works as we expect. I did not test windows package yet
Expand Down Expand Up @@ -374,6 +383,25 @@ function downloadPackages(pyBin, dependenciesFile, destinationDir, osType, archT
}
}

function copyDirSync(src, dest) {
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest, { recursive: true });
}

const entries = fs.readdirSync(src, { withFileTypes: true });

for (let entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);

if (entry.isDirectory()) {
copyDirSync(srcPath, destPath); // recursive copy
} else {
fs.copyFileSync(srcPath, destPath); // copy file
}
}
}

/*
* Script body
*/
Expand Down
Loading