diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b9c17b9b3..dd33b5f469 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [1.97.0](https://github.com/aws/jsii/compare/v1.96.0...v1.97.0) (2024-04-08) + + +### Bug Fixes + +* **jsii-pacmak:** fully support the Python Version Identification part of PEP440 ([#4462](https://github.com/aws/jsii/issues/4462)) ([c8483fb](https://github.com/aws/jsii/commit/c8483fb5c3b2efc75a123fd4816859758b8612dd)) + ## [1.96.0](https://github.com/aws/jsii/compare/v1.95.0...v1.96.0) (2024-03-22) diff --git a/gh-pages/requirements-dev.txt b/gh-pages/requirements-dev.txt index 4c0166fe3f..ca4d421ba3 100644 --- a/gh-pages/requirements-dev.txt +++ b/gh-pages/requirements-dev.txt @@ -1,4 +1,4 @@ mkdocs~=1.5.3 mkdocs-awesome-pages-plugin~=2.9.2 -mkdocs-material~=9.5.14 +mkdocs-material~=9.5.17 mkdocs-git-revision-date-plugin~=0.3.2 diff --git a/lerna.json b/lerna.json index e1374a6116..2ad0493913 100644 --- a/lerna.json +++ b/lerna.json @@ -12,6 +12,6 @@ "rejectCycles": true } }, - "version": "1.96.0", + "version": "1.97.0", "$schema": "node_modules/lerna/schemas/lerna-schema.json" } diff --git a/packages/@jsii/go-runtime-test/project/go.mod b/packages/@jsii/go-runtime-test/project/go.mod index 20c25c0327..ddd6115f5a 100644 --- a/packages/@jsii/go-runtime-test/project/go.mod +++ b/packages/@jsii/go-runtime-test/project/go.mod @@ -9,7 +9,7 @@ require ( github.com/aws/jsii/jsii-calc/go/scopejsiicalclib v0.0.0-devpreview github.com/stretchr/testify v1.9.0 golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 - golang.org/x/tools v0.19.0 + golang.org/x/tools v0.20.0 ) require ( @@ -21,8 +21,8 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/yuin/goldmark v1.4.13 // indirect - golang.org/x/mod v0.16.0 // indirect - golang.org/x/sys v0.18.0 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/sys v0.19.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/packages/@jsii/go-runtime-test/project/go.sum b/packages/@jsii/go-runtime-test/project/go.sum index 4268c59bb8..4af089da53 100644 --- a/packages/@jsii/go-runtime-test/project/go.sum +++ b/packages/@jsii/go-runtime-test/project/go.sum @@ -28,10 +28,13 @@ golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -42,6 +45,8 @@ golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= @@ -50,6 +55,8 @@ golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= +golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= +golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/packages/@jsii/go-runtime/jsii-runtime-go/go.mod b/packages/@jsii/go-runtime/jsii-runtime-go/go.mod index 635e5c91e0..12cd095211 100644 --- a/packages/@jsii/go-runtime/jsii-runtime-go/go.mod +++ b/packages/@jsii/go-runtime/jsii-runtime-go/go.mod @@ -8,7 +8,7 @@ require ( github.com/mattn/go-isatty v0.0.20 github.com/stretchr/testify v1.9.0 golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 - golang.org/x/tools v0.19.0 + golang.org/x/tools v0.20.0 ) require ( @@ -16,8 +16,8 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/yuin/goldmark v1.4.13 // indirect - golang.org/x/mod v0.16.0 // indirect - golang.org/x/sys v0.18.0 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/sys v0.19.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/packages/@jsii/go-runtime/jsii-runtime-go/go.sum b/packages/@jsii/go-runtime/jsii-runtime-go/go.sum index 1c2320c4e4..d42a5d2e7c 100644 --- a/packages/@jsii/go-runtime/jsii-runtime-go/go.sum +++ b/packages/@jsii/go-runtime/jsii-runtime-go/go.sum @@ -20,22 +20,22 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= -golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= -golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= +golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= +golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/packages/@jsii/python-runtime/requirements.txt b/packages/@jsii/python-runtime/requirements.txt index 6b2fb137c6..b4bb4d076e 100644 --- a/packages/@jsii/python-runtime/requirements.txt +++ b/packages/@jsii/python-runtime/requirements.txt @@ -4,7 +4,7 @@ pip~=24.0 pytest~=8.1 pytest-mypy~=0.10 setuptools~=69.2.0 -types-python-dateutil~=2.8 +types-python-dateutil~=2.9 wheel~=0.43 -e . diff --git a/packages/jsii-pacmak/lib/targets/version-utils.ts b/packages/jsii-pacmak/lib/targets/version-utils.ts index 9aeada27cf..7c1b6b62c2 100644 --- a/packages/jsii-pacmak/lib/targets/version-utils.ts +++ b/packages/jsii-pacmak/lib/targets/version-utils.ts @@ -93,42 +93,80 @@ export function toReleaseVersion( } switch (target) { case TargetName.PYTHON: + const baseVersion = `${version.major}.${version.minor}.${version.patch}`; + // Python supports a limited set of identifiers... And we have a mapping table... // https://packaging.python.org/guides/distributing-packages-using-setuptools/#pre-release-versioning - const [label, sequence, ...rest] = version.prerelease; - if (rest.filter((elt) => elt !== 0).length > 0 || sequence == null) { + const releaseLabels: Record = { + alpha: 'a', + beta: 'b', + rc: 'rc', + post: 'post', + dev: 'dev', + pre: 'pre', + }; + + const validationErrors: string[] = []; + + // Ensure that prerelease composed entirely of [label, sequence] pairs + version.prerelease.forEach((elem, idx, arr) => { + const next: string | number | undefined = arr[idx + 1]; + if (typeof elem === 'string') { + if (!Object.keys(releaseLabels).includes(elem)) { + validationErrors.push( + `Label ${elem} is not one of ${Object.keys(releaseLabels).join( + ',', + )}`, + ); + } + if (next === undefined || !Number.isInteger(next)) { + validationErrors.push( + `Label ${elem} must be followed by a positive integer`, + ); + } + } + }); + + if (validationErrors.length > 0) { throw new Error( `Unable to map prerelease identifier (in: ${assemblyVersion}) components to python: ${inspect( version.prerelease, - )}. The format should be 'X.Y.Z-label.sequence', where sequence is a positive integer, and label is "dev", "pre", "alpha", beta", or "rc"`, + )}. The format should be 'X.Y.Z-[label.sequence][.post.sequence][.(dev|pre).sequence]', where sequence is a positive integer and label is one of ${inspect( + Object.keys(releaseLabels), + )}. Validation errors encountered: ${validationErrors.join(', ')}`, ); } - if (!Number.isInteger(sequence)) { - throw new Error( - `Unable to map prerelease identifier (in: ${assemblyVersion}) to python, as sequence ${inspect( - sequence, - )} is not an integer`, - ); - } - const baseVersion = `${version.major}.${version.minor}.${version.patch}`; - // See PEP 440: https://www.python.org/dev/peps/pep-0440/#pre-releases - switch (label) { - case 'dev': - case 'pre': - return `${baseVersion}.dev${sequence}`; - case 'alpha': - return `${baseVersion}.a${sequence}`; - case 'beta': - return `${baseVersion}.b${sequence}`; - case 'rc': - return `${baseVersion}.rc${sequence}`; - default: - throw new Error( - `Unable to map prerelease identifier (in: ${assemblyVersion}) to python, as label ${inspect( - label, - )} is not mapped (only "dev", "pre", "alpha", "beta" and "rc" are)`, - ); - } + + // PEP440 supports multiple labels in a given version, so + // we should attempt to identify and map as many labels as + // possible from the given prerelease input + // e.g. 1.2.3-rc.123.dev.456.post.789 => 1.2.3.rc123.dev456.post789 + const postIdx = version.prerelease.findIndex( + (v) => v.toString() === 'post', + ); + const devIdx = version.prerelease.findIndex((v) => + ['dev', 'pre'].includes(v.toString()), + ); + const preReleaseIdx = version.prerelease.findIndex((v) => + ['alpha', 'beta', 'rc'].includes(v.toString()), + ); + const prereleaseVersion = [ + preReleaseIdx > -1 + ? `${releaseLabels[version.prerelease[preReleaseIdx]]}${ + version.prerelease[preReleaseIdx + 1] ?? 0 + }` + : undefined, + postIdx > -1 + ? `post${version.prerelease[postIdx + 1] ?? 0}` + : undefined, + devIdx > -1 ? `dev${version.prerelease[devIdx + 1] ?? 0}` : undefined, + ] + .filter((v) => v) + .join('.'); + + return version.build.length > 0 + ? `${baseVersion}.${prereleaseVersion}+${version.build.join('.')}` + : `${baseVersion}.${prereleaseVersion}`; case TargetName.DOTNET: case TargetName.GO: case TargetName.JAVA: diff --git a/packages/jsii-pacmak/test/targets/version-utils.test.ts b/packages/jsii-pacmak/test/targets/version-utils.test.ts index 8564706e2d..129ec494f0 100644 --- a/packages/jsii-pacmak/test/targets/version-utils.test.ts +++ b/packages/jsii-pacmak/test/targets/version-utils.test.ts @@ -127,6 +127,13 @@ describe(toReleaseVersion, () => { python: /Unable to map prerelease identifier \(in: 1\.2\.3-pre\) components to python: \[ 'pre' \]/, }, + '1.2.3-dev.123.0+abc123.foo.bar': { + dotnet: '1.2.3-dev.123.0+abc123.foo.bar', + go: '1.2.3-dev.123.0+abc123.foo.bar', + java: '1.2.3-dev.123.0+abc123.foo.bar', + js: '1.2.3-dev.123.0+abc123.foo.bar', + python: '1.2.3.dev123+abc123.foo.bar', + }, '1.2.3-alpha.1337': { dotnet: '1.2.3-alpha.1337', go: '1.2.3-alpha.1337', @@ -148,6 +155,21 @@ describe(toReleaseVersion, () => { js: '1.2.3-rc.9', python: '1.2.3.rc9', }, + '1.2.3-rc.123.post.456.dev.789': { + dotnet: '1.2.3-rc.123.post.456.dev.789', + go: '1.2.3-rc.123.post.456.dev.789', + java: '1.2.3-rc.123.post.456.dev.789', + js: '1.2.3-rc.123.post.456.dev.789', + python: '1.2.3.rc123.post456.dev789', + }, + '1.2.3-rc.alpha': { + dotnet: '1.2.3-rc.alpha', + go: '1.2.3-rc.alpha', + java: '1.2.3-rc.alpha', + js: '1.2.3-rc.alpha', + python: + /Unable to map prerelease identifier \(in: 1.2.3-rc.alpha\) components to python: \[ 'rc', 'alpha' \]/, + }, }; for (const [version, targets] of Object.entries(examples)) { diff --git a/yarn.lock b/yarn.lock index 7459f177d0..210344317a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4074,9 +4074,9 @@ flatted@^3.2.7, flatted@^3.2.9: integrity sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ== follow-redirects@^1.15.0: - version "1.15.4" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.4.tgz#cdc7d308bf6493126b17ea2191ea0ccf3e535adf" - integrity sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw== + version "1.15.6" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b" + integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA== for-each@^0.3.3: version "0.3.3"