From ff76a148c1dbc9d1635eafd541b70867d2b17c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Wed, 14 Aug 2019 17:42:38 -0700 Subject: [PATCH 1/2] feat(python): add classifiers to generated packages Adds three classifiers to generated packages: - Programming Language (Python 3) - Operating System (Independent) - License (from SPDX name) Fixes #707 --- packages/jsii-pacmak/lib/targets/python.ts | 34 +++++++++++++++++-- .../expected.jsii-calc-base/python/setup.py | 5 +++ .../expected.jsii-calc-lib/python/setup.py | 6 ++++ .../test/expected.jsii-calc/python/setup.py | 6 ++++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index cd0b262943..1f1befc0bc 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -11,6 +11,9 @@ import { propertySpec } from '../reflect-hacks'; import { Target, TargetOptions } from '../target'; import { shell } from '../util'; +// tslint:disable-next-line:no-var-requires +const spdxLicenseList = require('spdx-license-list'); + export default class Python extends Target { protected readonly generator = new PythonGenerator(); @@ -1135,6 +1138,25 @@ class Package { // Strip " (build abcdef)" from the jsii version const jsiiVersionSimple = this.metadata.jsiiVersion.replace(/ .*$/, ''); + const classifiers = [ + `License :: ${getLicense(this.metadata.license)}`, + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 3', + ]; + switch (this.metadata.docs && this.metadata.docs.stability) { + case spec.Stability.Experimental: + classifiers.push('Development Status :: 4 - Beta'); + break; + case spec.Stability.Stable: + classifiers.push('Development Status :: 5 - Production/Stable'); + break; + case spec.Stability.Deprecated: + classifiers.push('Development Status :: 7 - Inactive'); + break; + default: + // No 'Development Status' classifier in those cases + } + const setupKwargs = { name: this.name, version: this.version, @@ -1152,12 +1174,10 @@ class Package { package_data: packageData, python_requires: ">=3.6", install_requires: [`jsii~=${jsiiVersionSimple}`, "publication>=0.0.3"].concat(dependencies), + classifiers, }; // We Need a setup.py to make this Package, actually a Package. - // TODO: - // - License - // - Classifiers code.openFile("setup.py"); code.line("import json"); code.line("import setuptools"); @@ -1187,6 +1207,14 @@ class Package { code.openFile("MANIFEST.in"); code.line("include pyproject.toml"); code.closeFile("MANIFEST.in"); + + function getLicense(licenseName: string): string { + const spdx = spdxLicenseList[licenseName]; + if (spdx.osiApproved) { + return `OSI Approved :: ${spdx.name}`; + } + return spdx.name; + } } } diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-base/python/setup.py b/packages/jsii-pacmak/test/expected.jsii-calc-base/python/setup.py index 246f80788e..739437126b 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-base/python/setup.py +++ b/packages/jsii-pacmak/test/expected.jsii-calc-base/python/setup.py @@ -32,6 +32,11 @@ "jsii~=0.15.0", "publication>=0.0.3", "scope.jsii-calc-base-of-base~=0.15.0" + ], + "classifiers": [ + "License :: OSI Approved :: Apache License 2.0", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3" ] } """) diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-lib/python/setup.py b/packages/jsii-pacmak/test/expected.jsii-calc-lib/python/setup.py index a6b099d15d..d995ea15c0 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-lib/python/setup.py +++ b/packages/jsii-pacmak/test/expected.jsii-calc-lib/python/setup.py @@ -32,6 +32,12 @@ "jsii~=0.15.0", "publication>=0.0.3", "scope.jsii-calc-base~=0.15.0" + ], + "classifiers": [ + "License :: OSI Approved :: Apache License 2.0", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Development Status :: 7 - Inactive" ] } """) diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/python/setup.py b/packages/jsii-pacmak/test/expected.jsii-calc/python/setup.py index 5cc8bbf40d..d596036e87 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/python/setup.py +++ b/packages/jsii-pacmak/test/expected.jsii-calc/python/setup.py @@ -34,6 +34,12 @@ "scope.jsii-calc-base~=0.15.0", "scope.jsii-calc-base-of-base~=0.15.0", "scope.jsii-calc-lib~=0.15.0" + ], + "classifiers": [ + "License :: OSI Approved :: Apache License 2.0", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Development Status :: 4 - Beta" ] } """) From e79f62c6632c7f5963eec87fb46ef9062dabe21c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BC=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier-Muller?= Date: Fri, 8 Nov 2019 16:50:24 +0100 Subject: [PATCH 2/2] pass licence to setuptools --- packages/jsii-pacmak/lib/targets/python.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/jsii-pacmak/lib/targets/python.ts b/packages/jsii-pacmak/lib/targets/python.ts index 1f1befc0bc..e182abbb41 100644 --- a/packages/jsii-pacmak/lib/targets/python.ts +++ b/packages/jsii-pacmak/lib/targets/python.ts @@ -1139,6 +1139,7 @@ class Package { const jsiiVersionSimple = this.metadata.jsiiVersion.replace(/ .*$/, ''); const classifiers = [ + 'Intended Audience :: Developers', `License :: ${getLicense(this.metadata.license)}`, 'Operating System :: OS Independent', 'Programming Language :: Python :: 3', @@ -1161,6 +1162,7 @@ class Package { name: this.name, version: this.version, description: this.metadata.description, + license: this.metadata.license, url: this.metadata.homepage, long_description_content_type: "text/markdown", author: this.metadata.author.name + (