Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(python): add license & classifiers to generated packages #712

Merged
merged 6 commits into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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