Skip to content

Commit

Permalink
fix(python): pin dependency version to the exact match
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RomainMuller committed Nov 11, 2019
1 parent 860f742 commit e71fd39
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 24 deletions.
20 changes: 5 additions & 15 deletions packages/jsii-pacmak/lib/targets/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Generator, GeneratorOptions } from '../generator';
import { warn } from '../logging';
import { md2rst } from '../markdown';
import { Target } from '../target';
import { shell } from '../util';
import { shell, nextMajorVersion } from '../util';

/* eslint-disable @typescript-eslint/no-var-requires */
const spdxLicenseList = require('spdx-license-list');
Expand Down Expand Up @@ -1140,26 +1140,16 @@ class Package {
const expectedDeps = this.metadata.dependencies || {};
for (const depName of Object.keys(expectedDeps)) {
const depInfo = expectedDeps[depName];
// We need to figure out what our version range is.
// Basically, if it starts with Zero we want to restrict things to
// ~=X.Y.Z. If it does not start with zero, then we want to do ~=X.Y,>=X.Y.Z.
const versionParts = depInfo.version.split('.');
let versionSpecifier: string;
if (versionParts[0] === '0') {
versionSpecifier = `~=${versionParts.slice(0, 3).join('.')}`;
} else {
versionSpecifier = `~=${versionParts.slice(0, 2).join('.')},>=${versionParts.slice(0, 3).join('.')}`;
}

dependencies.push(`${depInfo.targets!.python!.distName}${versionSpecifier}`);
dependencies.push(`${depInfo.targets!.python!.distName}==${depInfo.version}`);
}

code.openFile('README.md');
code.line(this.convertedReadme);
code.closeFile('README.md');

// Strip " (build abcdef)" from the jsii version
const jsiiVersionSimple = this.metadata.jsiiVersion.replace(/ .*$/, '');
const jsiiVersion = this.metadata.jsiiVersion.replace(/ .*$/, '');
const jsiiNextMajor = nextMajorVersion(jsiiVersion);

/* eslint-disable @typescript-eslint/camelcase */
const setupKwargs = {
Expand All @@ -1179,7 +1169,7 @@ class Package {
packages: modules.map(m => m.pythonName),
package_data: packageData,
python_requires: '>=3.6',
install_requires: [`jsii~=${jsiiVersionSimple}`, 'publication>=0.0.3'].concat(dependencies),
install_requires: [`jsii~=${jsiiVersion},<${jsiiNextMajor}`, 'publication>=0.0.3'].concat(dependencies),
classifiers: [
'Intended Audience :: Developers',
'Operating System :: OS Independent',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"python_requires": ">=3.6",
"install_requires": [
"jsii~=0.20.2",
"jsii~=0.20.2,<0.21.0",
"publication>=0.0.3"
],
"classifiers": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
},
"python_requires": ">=3.6",
"install_requires": [
"jsii~=0.20.2",
"jsii~=0.20.2,<0.21.0",
"publication>=0.0.3",
"scope.jsii-calc-base-of-base~=0.20.2"
"scope.jsii-calc-base-of-base==0.20.2"
],
"classifiers": [
"Intended Audience :: Developers",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
},
"python_requires": ">=3.6",
"install_requires": [
"jsii~=0.20.2",
"jsii~=0.20.2,<0.21.0",
"publication>=0.0.3",
"scope.jsii-calc-base~=0.20.2"
"scope.jsii-calc-base==0.20.2"
],
"classifiers": [
"Intended Audience :: Developers",
Expand Down
8 changes: 4 additions & 4 deletions packages/jsii-pacmak/test/expected.jsii-calc/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
},
"python_requires": ">=3.6",
"install_requires": [
"jsii~=0.20.2",
"jsii~=0.20.2,<0.21.0",
"publication>=0.0.3",
"scope.jsii-calc-base~=0.20.2",
"scope.jsii-calc-base-of-base~=0.20.2",
"scope.jsii-calc-lib~=0.20.2"
"scope.jsii-calc-base==0.20.2",
"scope.jsii-calc-base-of-base==0.20.2",
"scope.jsii-calc-lib==0.20.2"
],
"classifiers": [
"Intended Audience :: Developers",
Expand Down

0 comments on commit e71fd39

Please sign in to comment.