Skip to content

Commit

Permalink
fix(pacmak): runtime dependency should match pacmak release (#4013)
Browse files Browse the repository at this point in the history
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.



---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
  • Loading branch information
RomainMuller committed Mar 16, 2023
1 parent fbe0cbe commit 37c29f7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 21 deletions.
4 changes: 2 additions & 2 deletions packages/jsii-pacmak/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ VERSION=$(node -p "require('./package.json').version.replace(/\\+[0-9a-f]+\$/, '
cat > lib/version.ts <<HERE
// Generated at $(date -u +"%Y-%m-%dT%H:%M:%SZ") by generate.sh
/** The short version number for this JSII compiler (e.g: \`X.Y.Z\`) */
/** The short version number for this jsii-pacmak release (e.g: \`X.Y.Z\`) */
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
export const VERSION: string = '${VERSION}';
/** The qualified version number for this JSII compiler (e.g: \`X.Y.Z (build #######)\`) */
/** The qualified version number for this jsii-pacmak release (e.g: \`X.Y.Z (build #######)\`) */
export const VERSION_DESC = '${VERSION} (build ${commit:0:7}${suffix:-})';
HERE
6 changes: 2 additions & 4 deletions packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as xmlbuilder from 'xmlbuilder';

import { TargetName } from '..';
import * as logging from '../../logging';
import { VERSION } from '../../version';
import { TARGET_FRAMEWORK } from '../dotnet';
import { toNuGetVersionRange, toReleaseVersion } from '../version-utils';
import { DotNetNameUtils } from './nameutils';
Expand Down Expand Up @@ -119,13 +120,10 @@ export class FileGenerator {
const embeddedResource = itemGroup1.ele('EmbeddedResource');
embeddedResource.att('Include', this.tarballFileName);

// Strip " (build abcdef)" from the jsii version
const jsiiVersion = assembly.jsiiVersion.replace(/ .*$/, '');

const itemGroup2 = rootNode.ele('ItemGroup');
const packageReference = itemGroup2.ele('PackageReference');
packageReference.att('Include', 'Amazon.JSII.Runtime');
packageReference.att('Version', toNuGetVersionRange(`^${jsiiVersion}`));
packageReference.att('Version', toNuGetVersionRange(`^${VERSION}`));

dependencies.forEach((value: DotNetDependency) => {
if (value.partOfCompilation) {
Expand Down
9 changes: 2 additions & 7 deletions packages/jsii-pacmak/lib/targets/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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',
]
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 37c29f7

Please sign in to comment.