Skip to content

Commit e71fd39

Browse files
committed
fix(python): pin dependency version to the exact match
This will make it easier for downstream consumers to revert to an older version of closures. This is a temporary fix until we make further changes to forward the *exact* requirement that was expressed on the source package.
1 parent 860f742 commit e71fd39

5 files changed

Lines changed: 14 additions & 24 deletions

File tree

packages/jsii-pacmak/lib/targets/python.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Generator, GeneratorOptions } from '../generator';
1010
import { warn } from '../logging';
1111
import { md2rst } from '../markdown';
1212
import { Target } from '../target';
13-
import { shell } from '../util';
13+
import { shell, nextMajorVersion } from '../util';
1414

1515
/* eslint-disable @typescript-eslint/no-var-requires */
1616
const spdxLicenseList = require('spdx-license-list');
@@ -1140,26 +1140,16 @@ class Package {
11401140
const expectedDeps = this.metadata.dependencies || {};
11411141
for (const depName of Object.keys(expectedDeps)) {
11421142
const depInfo = expectedDeps[depName];
1143-
// We need to figure out what our version range is.
1144-
// Basically, if it starts with Zero we want to restrict things to
1145-
// ~=X.Y.Z. If it does not start with zero, then we want to do ~=X.Y,>=X.Y.Z.
1146-
const versionParts = depInfo.version.split('.');
1147-
let versionSpecifier: string;
1148-
if (versionParts[0] === '0') {
1149-
versionSpecifier = `~=${versionParts.slice(0, 3).join('.')}`;
1150-
} else {
1151-
versionSpecifier = `~=${versionParts.slice(0, 2).join('.')},>=${versionParts.slice(0, 3).join('.')}`;
1152-
}
1153-
1154-
dependencies.push(`${depInfo.targets!.python!.distName}${versionSpecifier}`);
1143+
dependencies.push(`${depInfo.targets!.python!.distName}==${depInfo.version}`);
11551144
}
11561145

11571146
code.openFile('README.md');
11581147
code.line(this.convertedReadme);
11591148
code.closeFile('README.md');
11601149

11611150
// Strip " (build abcdef)" from the jsii version
1162-
const jsiiVersionSimple = this.metadata.jsiiVersion.replace(/ .*$/, '');
1151+
const jsiiVersion = this.metadata.jsiiVersion.replace(/ .*$/, '');
1152+
const jsiiNextMajor = nextMajorVersion(jsiiVersion);
11631153

11641154
/* eslint-disable @typescript-eslint/camelcase */
11651155
const setupKwargs = {
@@ -1179,7 +1169,7 @@ class Package {
11791169
packages: modules.map(m => m.pythonName),
11801170
package_data: packageData,
11811171
python_requires: '>=3.6',
1182-
install_requires: [`jsii~=${jsiiVersionSimple}`, 'publication>=0.0.3'].concat(dependencies),
1172+
install_requires: [`jsii~=${jsiiVersion},<${jsiiNextMajor}`, 'publication>=0.0.3'].concat(dependencies),
11831173
classifiers: [
11841174
'Intended Audience :: Developers',
11851175
'Operating System :: OS Independent',

packages/jsii-pacmak/test/expected.jsii-calc-base-of-base/python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"python_requires": ">=3.6",
3232
"install_requires": [
33-
"jsii~=0.20.2",
33+
"jsii~=0.20.2,<0.21.0",
3434
"publication>=0.0.3"
3535
],
3636
"classifiers": [

packages/jsii-pacmak/test/expected.jsii-calc-base/python/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
},
3131
"python_requires": ">=3.6",
3232
"install_requires": [
33-
"jsii~=0.20.2",
33+
"jsii~=0.20.2,<0.21.0",
3434
"publication>=0.0.3",
35-
"scope.jsii-calc-base-of-base~=0.20.2"
35+
"scope.jsii-calc-base-of-base==0.20.2"
3636
],
3737
"classifiers": [
3838
"Intended Audience :: Developers",

packages/jsii-pacmak/test/expected.jsii-calc-lib/python/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
},
3131
"python_requires": ">=3.6",
3232
"install_requires": [
33-
"jsii~=0.20.2",
33+
"jsii~=0.20.2,<0.21.0",
3434
"publication>=0.0.3",
35-
"scope.jsii-calc-base~=0.20.2"
35+
"scope.jsii-calc-base==0.20.2"
3636
],
3737
"classifiers": [
3838
"Intended Audience :: Developers",

packages/jsii-pacmak/test/expected.jsii-calc/python/setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
},
3131
"python_requires": ">=3.6",
3232
"install_requires": [
33-
"jsii~=0.20.2",
33+
"jsii~=0.20.2,<0.21.0",
3434
"publication>=0.0.3",
35-
"scope.jsii-calc-base~=0.20.2",
36-
"scope.jsii-calc-base-of-base~=0.20.2",
37-
"scope.jsii-calc-lib~=0.20.2"
35+
"scope.jsii-calc-base==0.20.2",
36+
"scope.jsii-calc-base-of-base==0.20.2",
37+
"scope.jsii-calc-lib==0.20.2"
3838
],
3939
"classifiers": [
4040
"Intended Audience :: Developers",

0 commit comments

Comments
 (0)