Skip to content

Commit

Permalink
feat(python): add license & classifiers to generated packages (#712)
Browse files Browse the repository at this point in the history
* 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

* pass licence to setuptools
  • Loading branch information
RomainMuller authored and mergify[bot] committed Nov 11, 2019
1 parent 511dfc4 commit 84fd8bb
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/jsii-pacmak/lib/targets/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import { md2rst } from '../markdown';
import { Target } from '../target';
import { shell } from '../util';

/* eslint-disable @typescript-eslint/no-var-requires */
const spdxLicenseList = require('spdx-license-list');
/* eslint-enable @typescript-eslint/no-var-requires */

export default class Python extends Target {
protected readonly generator = new PythonGenerator();

Expand Down Expand Up @@ -1162,6 +1166,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 + (
Expand All @@ -1175,9 +1180,32 @@ class Package {
package_data: packageData,
python_requires: '>=3.6',
install_requires: [`jsii~=${jsiiVersionSimple}`, 'publication>=0.0.3'].concat(dependencies),
classifiers: [
'Intended Audience :: Developers',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
],
};
/* eslint-enable @typescript-eslint/camelcase */

switch (this.metadata.docs && this.metadata.docs.stability) {
case spec.Stability.Experimental:
setupKwargs.classifiers.push('Development Status :: 4 - Beta');
break;
case spec.Stability.Stable:
setupKwargs.classifiers.push('Development Status :: 5 - Production/Stable');
break;
case spec.Stability.Deprecated:
setupKwargs.classifiers.push('Development Status :: 7 - Inactive');
break;
default:
// No 'Development Status' trove classifier for you!
}

if (spdxLicenseList[this.metadata.license] && spdxLicenseList[this.metadata.license].osiApproved) {
setupKwargs.classifiers.push('License :: OSI Approved');
}

// We Need a setup.py to make this Package, actually a Package.
// TODO:
// - License
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"name": "scope.jsii-calc-base-of-base",
"version": "0.20.2",
"description": "An example transitive dependency for jsii-calc.",
"license": "Apache-2.0",
"url": "https://github.com/aws/jsii",
"long_description_content_type": "text/markdown",
"author": "Amazon Web Services",
Expand All @@ -31,6 +32,12 @@
"install_requires": [
"jsii~=0.20.2",
"publication>=0.0.3"
],
"classifiers": [
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"License :: OSI Approved"
]
}
""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"name": "scope.jsii-calc-base",
"version": "0.20.2",
"description": "An example direct dependency for jsii-calc.",
"license": "Apache-2.0",
"url": "https://github.com/aws/jsii",
"long_description_content_type": "text/markdown",
"author": "Amazon Web Services",
Expand All @@ -32,6 +33,12 @@
"jsii~=0.20.2",
"publication>=0.0.3",
"scope.jsii-calc-base-of-base~=0.20.2"
],
"classifiers": [
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"License :: OSI Approved"
]
}
""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"name": "scope.jsii-calc-lib",
"version": "0.20.2",
"description": "A simple calcuator library built on JSII.",
"license": "Apache-2.0",
"url": "https://github.com/aws/jsii",
"long_description_content_type": "text/markdown",
"author": "Amazon Web Services",
Expand All @@ -32,6 +33,13 @@
"jsii~=0.20.2",
"publication>=0.0.3",
"scope.jsii-calc-base~=0.20.2"
],
"classifiers": [
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Development Status :: 7 - Inactive",
"License :: OSI Approved"
]
}
""")
Expand Down
8 changes: 8 additions & 0 deletions packages/jsii-pacmak/test/expected.jsii-calc/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"name": "jsii-calc",
"version": "0.20.2",
"description": "A simple calcuator built on JSII.",
"license": "Apache-2.0",
"url": "https://github.com/aws/jsii",
"long_description_content_type": "text/markdown",
"author": "Amazon Web Services",
Expand Down Expand Up @@ -34,6 +35,13 @@
"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",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Development Status :: 4 - Beta",
"License :: OSI Approved"
]
}
""")
Expand Down

0 comments on commit 84fd8bb

Please sign in to comment.