Skip to content

Commit

Permalink
Merge branch 'master' into rmuller/no-parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Aug 17, 2020
2 parents 95253c3 + 26be2b6 commit 002b37d
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 9 deletions.
24 changes: 23 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,22 @@ The `python` target requires two configuration entries:
* `module` - the name of the generated **Python** module, which will be used by
users in `import` directives.
* `distName` - the [PyPI] distribution name for the package.
* `classifiers` - a list of [trove classifiers] to declare on the package. It is
the user's responsibility to specify *valid* values (the authoritative list of
valid [trove classifiers] is masted in the [pypa/trove-classifiers] package).
* Some classifiers are automatically included (and should not be added to the
`classifiers` property) based on relevant configuration from the
`package.json` file:
* `Development Status :: ` is determined based on the package's `stability`
* `License ::` is determined based on the package's `license`
* `Operating System :: OS Independent` is always set
* `Typing :: Typed` is always set
* Additionally, the following `Programming Language ::` classifiers are
already set (more could be added by the user if relevant):
* `Programming Language :: Python :: 3 :: Only`
* `Programming Language :: Python :: 3.6`
* `Programming Language :: Python :: 3.7`
* `Programming Language :: Python :: 3.8`

Example:
```js
Expand All @@ -162,7 +178,11 @@ Example:
"targets": {
"python": {
"module": "hello_jsii", // Required
"distName": "hello-jsii" // Required
"distName": "hello-jsii", // Required
"classifiers": [ // Optional
"Framework :: AWS CDK",
"Framework :: AWS CDK :: 1"
]
},
// ...
}
Expand All @@ -175,6 +195,8 @@ Example:
The resulting package can be published to [PyPI].

[PyPI]: https://pypi.org/
[trove classifiers]: https://www.python.org/dev/peps/pep-0301/#distutils-trove-classification
[pypa/trove-classifiers]: https://github.com/pypa/trove-classifiers

#### Configuring `Java`

Expand Down
6 changes: 5 additions & 1 deletion packages/@jsii/kernel/test/kernel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,11 @@ defineTest(
},
},
js: { npm: 'jsii-calc' },
python: { distName: 'jsii-calc', module: 'jsii_calc' },
python: {
distName: 'jsii-calc',
module: 'jsii_calc',
classifiers: ['Test :: Classifier :: Is Dummy'],
},
});
expect(sandbox.naming({ assembly: '@scope/jsii-calc-lib' }).naming).toEqual(
{
Expand Down
5 changes: 4 additions & 1 deletion packages/jsii-calc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@
},
"python": {
"distName": "jsii-calc",
"module": "jsii_calc"
"module": "jsii_calc",
"classifiers": [
"Test :: Classifier :: Is Dummy"
]
}
},
"metadata": {
Expand Down
5 changes: 4 additions & 1 deletion packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@
"npm": "jsii-calc"
},
"python": {
"classifiers": [
"Test :: Classifier :: Is Dummy"
],
"distName": "jsii-calc",
"module": "jsii_calc"
}
Expand Down Expand Up @@ -13819,5 +13822,5 @@
}
},
"version": "0.0.0",
"fingerprint": "NsqdwWgXi+kjrpLQtQ27eA/znULJ7TtXy03ht68N9Ms="
"fingerprint": "TXGVwLZ10oZ08NxDzu6i+fqPtaw5aEqME8+d+KEhL08="
}
50 changes: 47 additions & 3 deletions packages/jsii-pacmak/lib/targets/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1709,10 +1709,54 @@ class Package {
setupKwargs.classifiers.push('License :: OSI Approved');
}

const additionalClassifiers = this.metadata.targets?.python?.classifiers;
if (additionalClassifiers != null) {
if (!Array.isArray(additionalClassifiers)) {
throw new Error(
`The "jsii.targets.python.classifiers" value must be an array of strings if provided, but found ${JSON.stringify(
additionalClassifiers,
null,
2,
)}`,
);
}
// We discourage using those since we automatically set a value for them
for (let classifier of additionalClassifiers.sort()) {
if (typeof classifier !== 'string') {
throw new Error(
`The "jsii.targets.python.classifiers" value can only contain strings, but found ${JSON.stringify(
classifier,
null,
2,
)}`,
);
}
// We'll split on `::` and re-join later so classifiers are "normalized" to a standard spacing
const parts = classifier.split('::').map((part) => part.trim());
const reservedClassifiers = [
'Development Status',
'License',
'Operating System',
'Typing',
];
if (reservedClassifiers.includes(parts[0])) {
warn(
`Classifiers starting with ${reservedClassifiers
.map((x) => `"${x} ::"`)
.join(
', ',
)} are automatically set and should not be manually configured`,
);
}
classifier = parts.join(' :: ');
if (setupKwargs.classifiers.includes(classifier)) {
continue;
}
setupKwargs.classifiers.push(classifier);
}
}

// 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');
Expand Down

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

0 comments on commit 002b37d

Please sign in to comment.