Can't compile to Python when package.json `description` contains new lines
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 267
- Avg merge
- 1d 25m
- Merged PRs (30d)
- 14
Description
## :bug: Bug Report
### Affected Languages
- [x] `TypeScript` or `Javascript`
- [x] `Python`
- [ ] `Java`
- [ ] .NET (`C#`, `F#`, ...)
- [ ] `Go`
### General Information
* **JSII Version:** unknown
* **Platform:** unknown
### What is the problem?
_Transferred from https://github.com/projen/projen/issues/1333_
Description:
Using description from the Node project and inserting new lines fails python compile.
Steps to reproduce:
INFO: Based on https://github.com/mmuller88/cdk-prowler
1) configure python compile e.g.
```
publishToPypi: {
distName: 'cdk-prowler',
module: 'cdk_prowler',
},
...
```
2) Use description which contains a new line like:
```
const project = new awscdk.AwsCdkConstructLibrary({
author: 'Martin Mueller',
authorAddress: 'damadden88@googlemail.com',
jsiiFqn: 'projen.AwsCdkConstructLibrary',
cdkVersion,
cdkVersionPinning: false,
description: 'That is with \n newline' ,
...
```
3) yarn compile
Expected: Successful compile
Actual Restult:
```
👾 build » package | jsii-pacmak
[jsii-pacmak] [WARN] Failed building python
[jsii-pacmak] [WARN] python failed
Error: Command (/tmp/npm-pack2I9AVe/.env-XHf0Lg/bin/python setup.py sdist --dist-dir /home/martin/git/cdk-prowler/dist/python) failed with status 1:
#STDERR> Traceback (most recent call last):
#STDERR> File "setup.py", line 4, in
#STDERR> kwargs = json.loads(
#STDERR> File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
#STDERR> return _default_decoder.decode(s)
#STDERR> File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
#STDERR> obj, end = self.raw_decode(s, idx=_w(s, 0).end())
#STDERR> File "/usr/lib/python3.8/json/decoder.py", line 353, in raw_decode
#STDERR> obj, end = self.scan_once(s, idx)
#STDERR> json.decoder.JSONDecodeError: Invalid control character at: line 5 column 34 (char 87)
#STDERR>
#STDOUT>
at ChildProcess. (/home/martin/git/cdk-prowler/node_modules/jsii-pacmak/lib/util.js:119:27)
at Object.onceWrapper (events.js:520:26)
at ChildProcess.emit (events.js:400:28)
at maybeClose (internal/child_process.js:1058:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
```
Workaround: Remove new lines :D
### Verbose Log
Contributor guide
Research direction
Reproduce the failure with a package.json description containing a newline and inspect the jsii-pacmak path shown in lib/util.js, along with the generated setup.py. Confirm the fix by running yarn compile and checking that Python package generation succeeds with the multiline description.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100