Skip to content

Commit

Permalink
Fix missing headers for old python versions on darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoH2O1999 committed Feb 2, 2023
1 parent e842c78 commit 16dccc5
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions src/builder/darwin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export default class MacOSBuilder extends Builder {
});
sqlite = sqlite.trim();
core.info(`sqlite3 module path: ${sqlite}`);
process.env['LDFLAGS'] += ` -L${sqlite}/lib`;
process.env['CFLAGS'] += ` -I${sqlite}/include`;
process.env['LDFLAGS'] += `-L${sqlite}/lib `;
process.env['CFLAGS'] += `-I${sqlite}/include `;
process.env['CPPFLAGS'] += `-I${sqlite}/include`;
}
if (semver.gte(this.specificVersion, '3.7.0')) {
Expand Down Expand Up @@ -166,10 +166,10 @@ export default class MacOSBuilder extends Builder {
if (semver.lt(this.specificVersion, '3.7.0')) {
process.env[
'LDFLAGS'
] += `-L${this.sslPath}/lib -L${zlibPath}/lib -L${readLinePath}/lib`;
] += `-L${this.sslPath}/lib -L${zlibPath}/lib -L${readLinePath}/lib `;
process.env[
'CFLAGS'
] += `-I${this.sslPath}/include -I${zlibPath}/include -I${readLinePath}/lib`;
] += `-I${this.sslPath}/include -I${zlibPath}/include -I${readLinePath}/include `;
}
core.info(`OpenSSL path: ${this.sslPath}`);

Expand All @@ -185,6 +185,34 @@ export default class MacOSBuilder extends Builder {
process.env['SVNVERSION'] = 'Unversioned directory';
}

// Fix for missing header files

if (
semver.gte(this.specificVersion, '3.0.0') &&
semver.lt(this.specificVersion, '3.1.0')
) {
core.info(
'Detected Python version==3.0.x. Applying fix for missing headers...'
);
let headerPath = '';
await exec.exec('xcrun --sdk macosx --show-sdk-path', [], {
listeners: {
stdout: (buffer: Buffer) => {
headerPath = headerPath.concat(buffer.toString());
}
}
});
headerPath = headerPath.trim();
await exec.exec('ln -x', [
path.join(headerPath, 'usr', 'lib', 'netinet'),
'/usr/lib/netinet'
]);
await exec.exec('ln -x', [
path.join(headerPath, 'usr', 'include', 'netinet'),
'/usr/include/netinet'
]);
}

core.endGroup();
}

Expand Down

0 comments on commit 16dccc5

Please sign in to comment.