From 9c031c32e7c8e061babba23ddf73458c2620f556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=A7=91=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Thu, 16 Mar 2023 15:12:32 +0100 Subject: [PATCH] fix(pacmak): runtime dependency should match pacmak release The code generated by `jsii-pacmak` has a dependency on jsii runtime versions that are expected to match that of `jsii-pacmak` itself. This fixes the .NET and Python generators using the assembly's `jsiiVersion` property, which is a metadata field supposed to only indicate what version of the compiler was used to build the assembly. --- packages/jsii-pacmak/generate.sh | 4 ++-- .../lib/targets/dotnet/filegenerator.ts | 6 ++---- packages/jsii-pacmak/lib/targets/python.ts | 9 ++------- .../prerelease-identifiers.test.js.snap | 16 ++++++++-------- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/packages/jsii-pacmak/generate.sh b/packages/jsii-pacmak/generate.sh index 35af21b858..1584183c43 100644 --- a/packages/jsii-pacmak/generate.sh +++ b/packages/jsii-pacmak/generate.sh @@ -14,10 +14,10 @@ VERSION=$(node -p "require('./package.json').version.replace(/\\+[0-9a-f]+\$/, ' cat > lib/version.ts < { if (value.partOfCompilation) { diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index 0a7a010423..e5915a99a1 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -18,6 +18,7 @@ import { warn } from '../logging'; import { md2rst } from '../markdown'; import { Target, TargetOptions } from '../target'; import { shell } from '../util'; +import { VERSION } from '../version'; import { renderSummary, PropertyDefinition } from './_utils'; import { NamingContext, @@ -2080,12 +2081,6 @@ class Package { ); code.closeFile('README.md'); - // Strip " (build abcdef)" from the jsii version - const jsiiVersionSimple = toReleaseVersion( - this.metadata.jsiiVersion.replace(/ .*$/, ''), - TargetName.PYTHON, - ); - const setupKwargs = { name: this.name, version: this.version, @@ -2109,7 +2104,7 @@ class Package { package_data: packageData, python_requires: '~=3.7', install_requires: [ - `jsii${toPythonVersionRange(`^${jsiiVersionSimple}`)}`, + `jsii${toPythonVersionRange(`^${VERSION}`)}`, 'publication>=0.0.3', 'typeguard~=2.13.3', ] diff --git a/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.js.snap b/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.js.snap index fb35301af4..7323da788f 100644 --- a/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.js.snap +++ b/packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.js.snap @@ -84,7 +84,7 @@ exports[`foo@1.2.3 depends on bar@^2.0.0-rc.42: /dotnet/Com.Acme.Foo/Com - + @@ -453,7 +453,7 @@ kwargs = json.loads( "python_requires": "~=3.7", "install_requires": [ "bar>=2.0.0.rc42, <3.0.0", - "jsii>=1337.42.1337, <1338.0.0", + "jsii<0.0.1", "publication>=0.0.3", "typeguard~=2.13.3" ], @@ -595,7 +595,7 @@ exports[`foo@1.2.3 depends on bar@^4.5.6-pre.1337: /dotnet/Com.Acme.Foo/ - + @@ -964,7 +964,7 @@ kwargs = json.loads( "python_requires": "~=3.7", "install_requires": [ "bar>=4.5.6.dev1337, <5.0.0", - "jsii>=1337.42.1337, <1338.0.0", + "jsii<0.0.1", "publication>=0.0.3", "typeguard~=2.13.3" ], @@ -1106,7 +1106,7 @@ exports[`foo@2.0.0-rc.42: /dotnet/Com.Acme.Foo/Com.Acme.Foo.csproj 1`] = - + @@ -1454,7 +1454,7 @@ kwargs = json.loads( }, "python_requires": "~=3.7", "install_requires": [ - "jsii>=1337.42.1337, <1338.0.0", + "jsii<0.0.1", "publication>=0.0.3", "typeguard~=2.13.3" ], @@ -1594,7 +1594,7 @@ exports[`foo@4.5.6-pre.1337: /dotnet/Com.Acme.Foo/Com.Acme.Foo.csproj 1` - + @@ -1942,7 +1942,7 @@ kwargs = json.loads( }, "python_requires": "~=3.7", "install_requires": [ - "jsii>=1337.42.1337, <1338.0.0", + "jsii<0.0.1", "publication>=0.0.3", "typeguard~=2.13.3" ],