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

Python Support #319

Merged
merged 130 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
4b8af49
Initial Python Runtime Support
dstufft Aug 21, 2018
fa291d7
Bump versions
dstufft Sep 5, 2018
3180d97
Upgrade for latest JSII
dstufft Sep 11, 2018
1a9297c
Handle non-primitive types being returned from JSII runtime
dstufft Sep 11, 2018
c4c652d
Switch to using a single, global Kernel
dstufft Sep 20, 2018
a162358
Rearrange imports to deal with import cycles
dstufft Sep 20, 2018
59c7876
Provide a mechanism to load JSII Assemblies
dstufft Sep 20, 2018
ad57330
Add the WIP Python target for pacmak
dstufft Sep 20, 2018
0e4225f
Prefix all of our interal names with _
dstufft Sep 21, 2018
89e4422
Write out an __all__ that lists our exported names
dstufft Sep 21, 2018
15546d7
Add support for more types
dstufft Sep 21, 2018
6b1cbd6
Fix some MyPy errors
dstufft Sep 21, 2018
882e5c7
Generate actual Python packages
dstufft Sep 21, 2018
0e34a80
Correct the name of the import JSIIAssembly
dstufft Sep 21, 2018
5ea945d
Produce packages for the JSII Python Runtime
dstufft Sep 21, 2018
8275944
Embed the jsii-runtime within the jsii-python-runtime
dstufft Sep 21, 2018
50ad810
Merge branch 'master' into python
dstufft Sep 25, 2018
21f7ecb
Handle collection types in JSII
dstufft Sep 28, 2018
e2708e0
Handle scoped packages
dstufft Sep 28, 2018
340f8e9
Handle the case where a JSII name conflicts with a Python keyword
dstufft Sep 28, 2018
ea14b3c
Work with PEP 420 style namespace pacages
dstufft Sep 28, 2018
2f93077
Deduplicate imports
dstufft Sep 28, 2018
9d6362f
Remove some debug output
dstufft Sep 28, 2018
0cb0ad5
Add support for Union types
dstufft Sep 28, 2018
90b8ebe
Add support for interfaces
dstufft Sep 28, 2018
507f787
Fix setup.py to always include JSII assembly
dstufft Sep 29, 2018
653d774
Handle recurisve generic collection types
dstufft Sep 29, 2018
52f62d8
Handle classes and interfaces without bodies
dstufft Sep 29, 2018
0408cb3
Use a better mechanism of extracting a list of types
dstufft Sep 29, 2018
b8b40c0
Add a bit of extra documentation
dstufft Sep 29, 2018
848ed7a
Bump version
dstufft Sep 29, 2018
855c2a8
Fix formatting to handle nested types
dstufft Sep 29, 2018
d4b1fe8
Refactor various toPythonXXX functions into stand alone functions
dstufft Sep 30, 2018
322f04f
Drastic refactoring to delay emiting lines until the very end
dstufft Sep 30, 2018
6f636dd
Remove code duplication amongst the many Method types
dstufft Sep 30, 2018
78d986d
Remove duplication from property types
dstufft Sep 30, 2018
ea77363
Ensure we generate inherited from classes before we inherit from them
dstufft Sep 30, 2018
4bf7672
Re-enable tslint on python.ts
dstufft Sep 30, 2018
99fa04d
Cleanup interfaces for the nodes
dstufft Sep 30, 2018
3409850
Fix sorting by dependency
dstufft Sep 30, 2018
912a593
Support passing arguments to the class constructor
dstufft Oct 10, 2018
be62f7c
Handle FQN that contain a @ sign
dstufft Oct 10, 2018
41b7025
Merge branch 'master' into python
dstufft Oct 10, 2018
44c43f4
Update the JSII Provider Version Number
dstufft Oct 10, 2018
1807128
Merge branch 'master' into python
dstufft Oct 16, 2018
bac9dc7
Interfaces only need to declare dependencies in the same module
dstufft Oct 17, 2018
379d831
Implement Enums in the Python generator
dstufft Oct 17, 2018
4fdda68
Default to None if there is no result from an Invoke
dstufft Oct 17, 2018
8f93d69
Fix a spelling mistake
dstufft Oct 17, 2018
18ba6e6
Make sure all dependencies have been imported
dstufft Oct 18, 2018
83929ef
Magical Removal
dstufft Oct 20, 2018
86b92fb
Enable Typechecking installed JSII packages
dstufft Oct 20, 2018
98875ba
Implement Python name mangling
dstufft Oct 20, 2018
dd3e31d
Refactor to remove duplication
dstufft Oct 20, 2018
4e9fc08
Always use the global kernel instead of the __jsii_kernel__ indrection
dstufft Oct 21, 2018
f1c6986
Enable subclassing of JSII Classes
dstufft Oct 21, 2018
721f677
Correct the call to the super class
dstufft Oct 21, 2018
9e03851
Use real __init__ methods to enable sublcassing of JSII classes
dstufft Oct 21, 2018
79b4d4d
Make sure that classes inherent from their bases and interfaces
dstufft Oct 21, 2018
67058b9
Correctly limit dependencies to this module, even when faced with sub…
dstufft Oct 21, 2018
f5f0ec5
Implement Dataclasses as TypedDicts
dstufft Oct 21, 2018
a2d6c50
Support typing the JSII package
dstufft Oct 21, 2018
99278c9
Better handle numbers
dstufft Oct 21, 2018
e75585c
Correctly emit class bases
dstufft Oct 21, 2018
530f6c7
Don't inhereit from Interfaces
dstufft Oct 21, 2018
e9b0250
These can be private
dstufft Oct 21, 2018
7edc04e
Handle lifting a data type into keyword arguments
dstufft Oct 21, 2018
771e923
Handle Mandatory/Optional data type members
dstufft Oct 21, 2018
25def60
Use publication to hide implementation details from end users
dstufft Oct 22, 2018
a000fb7
Refactor module dependency to use Assembly metadata
dstufft Oct 19, 2018
a964267
Handle variadic parameters
dstufft Oct 22, 2018
6144260
Merge branch 'master' into python
dstufft Oct 23, 2018
4575e85
Massive refactor to greatly simplify Python generator
dstufft Oct 24, 2018
366c44b
Fix a bug with non-builtin but standard types
dstufft Oct 24, 2018
7505b32
Make sure that __jsii_assembly__ is in __all__
dstufft Oct 24, 2018
70d15d0
Deterministic regex
dstufft Oct 25, 2018
e76d4aa
Fix support for imports from submodules
dstufft Oct 25, 2018
1288b03
Correctly pass in the klass argument to @classproperty properties
dstufft Oct 25, 2018
efcded0
Emit a None default for optional positional params
dstufft Oct 25, 2018
7e7bbc7
Don't add typing.Optional to the auto props expansion
dstufft Oct 25, 2018
6a2ec91
Use "real" forward refs if possible, even with forwardReferences = false
dstufft Oct 25, 2018
22d2a34
Implement Abstract classes
dstufft Oct 25, 2018
2987f36
Don't trust whether the JSII tells us a parameter is optional or not
dstufft Oct 26, 2018
72fb08d
Don't include Optional when emitting Any
dstufft Oct 26, 2018
785ce86
Revert "Use "real" forward refs if possible, even with forwardReferen…
dstufft Oct 26, 2018
413ec40
Ensure all of regexp strings are correctly escaped
dstufft Oct 26, 2018
90618b2
Merge branch 'master' into python
dstufft Oct 29, 2018
db2e266
Move Namespaces as classes instead of modules
dstufft Nov 1, 2018
4754fed
Explicitly use Python3
dstufft Nov 1, 2018
4cdec20
Handle return values that are data types
dstufft Nov 1, 2018
620d850
Generate Proxy class to use when JSII runtime returns an abstract class
dstufft Nov 2, 2018
55f297e
Pass overriden methods/properties into the JSII runtime
dstufft Nov 2, 2018
3c39eb1
Merge branch 'master' into python
dstufft Nov 9, 2018
1702ca8
Merge branch 'master' into python
dstufft Nov 9, 2018
cd16d00
Merge branch 'master' into python
dstufft Nov 15, 2018
b01bf3d
Deal with name collisions
dstufft Nov 15, 2018
15302f3
Update the bundled JSII version
dstufft Nov 22, 2018
e1987b8
Merge branch 'master' into python
dstufft Jan 26, 2019
b1df25e
Implement compliance test suite
dstufft Jan 28, 2019
6adde20
Merge branch 'master' into dstufft/python-support
dstufft Feb 6, 2019
2473c33
Update after fixing tests
dstufft Feb 6, 2019
cc0b274
Slight reworking to remove cyclic import
dstufft Feb 6, 2019
26a838d
Use the correct name
dstufft Feb 6, 2019
594831f
Implement round tripping datetimes
dstufft Feb 6, 2019
b7b11a3
Properly recurse into lists as well as dicts
dstufft Feb 6, 2019
ddadab3
Hold onto references ~forever
dstufft Feb 6, 2019
38a9786
Remove xfails for recursive arrays
dstufft Feb 6, 2019
0c7e223
Fix the naming of constant properties
dstufft Feb 7, 2019
3230bb4
Emit the JSII_AGENT environment variable
dstufft Feb 7, 2019
f8e920c
Properly (De)Serialize Enums
dstufft Feb 7, 2019
8e302a5
Minor linting fixes
dstufft Feb 7, 2019
4a94600
Properly serialize property_ -> property
dstufft Feb 7, 2019
086bd7d
Run our tests with JSII_DEBUG=1
dstufft Feb 7, 2019
dab2db0
Implement protected methods/properties having a _ prefix
dstufft Feb 8, 2019
e33e46a
Remove the old debug method
dstufft Feb 8, 2019
a932eb6
Opt into PEP 517 build backends
dstufft Feb 8, 2019
1953c80
When packaging, emit actual dependency information
dstufft Feb 8, 2019
615e083
Merge branch 'master' into dstufft/python-support
dstufft Feb 27, 2019
8b214b9
Fix after merge
dstufft Feb 27, 2019
9049136
Implement handling of interfaces and overrides
dstufft Feb 27, 2019
f3727f0
Implement union properties
dstufft Mar 5, 2019
b1a47b4
Fix typo
dstufft Mar 5, 2019
151467c
Implement pure native object support
dstufft Mar 5, 2019
3d2b919
Comment out the dependency on black for now
dstufft Mar 5, 2019
a989cbf
Mangle parameter names
dstufft Mar 5, 2019
b15f91f
Implement some basic error handling
dstufft Mar 5, 2019
79bd713
Temporary pip install
dstufft Mar 7, 2019
61ff7c1
Revert "Temporary pip install"
dstufft Mar 7, 2019
afa8ced
Merge branch 'master' into dstufft/python-support
dstufft Mar 11, 2019
cce6d4b
Merge branch 'master' into dstufft/python-support
dstufft Mar 12, 2019
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
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
max-line-length = 88
exclude = *.egg,*/interfaces.py,node_modules,.state
ignore = W503,E203
select = E,W,F,N
7 changes: 7 additions & 0 deletions packages/jsii-build-tools/bin/package-python
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -euo pipefail

rm -rf dist/python
mkdir -p dist/python
mv *.whl dist/python
mv *.tar.gz dist/python
3 changes: 2 additions & 1 deletion packages/jsii-build-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"package-js": "bin/package-js",
"package-java": "bin/package-java",
"package-dotnet": "bin/package-dotnet",
"package-ruby": "bin/package-ruby"
"package-ruby": "bin/package-ruby",
"package-python": "bin/package-python"
},
"scripts": {
"build": "chmod +x bin/*"
Expand Down
67 changes: 67 additions & 0 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,73 @@ export class JavaReservedWords {
public while = 'hello';
}

export class PythonReservedWords {

public and() {}

public as() {}

public assert() {}

public async() {}

public await() {}

public break() {}

public class() {}

public continue() {}

public def() {}

public del() {}

public elif() {}

public else() {}

public except() {}

public finally() {}

public for() {}

public from() {}

public global() {}

public if() {}

public import() {}

public in() {}

public is() {}

public lambda() {}

public nonlocal() {}

public not() {}

public or() {}

public pass() {}

public raise() {}

public return() {}

public try() {}

public while() {}

public with() {}

public yield() {}
}

export interface UnionProperties {
foo?: string | number;
readonly bar: AllTypes | string | number;
Expand Down
109 changes: 108 additions & 1 deletion packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -2932,6 +2932,113 @@
],
"name": "PublicClass"
},
"jsii-calc.PythonReservedWords": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.PythonReservedWords",
"initializer": {
"initializer": true
},
"kind": "class",
"methods": [
{
"name": "and"
},
{
"name": "as"
},
{
"name": "assert"
},
{
"name": "async"
},
{
"name": "await"
},
{
"name": "break"
},
{
"name": "class"
},
{
"name": "continue"
},
{
"name": "def"
},
{
"name": "del"
},
{
"name": "elif"
},
{
"name": "else"
},
{
"name": "except"
},
{
"name": "finally"
},
{
"name": "for"
},
{
"name": "from"
},
{
"name": "global"
},
{
"name": "if"
},
{
"name": "import"
},
{
"name": "in"
},
{
"name": "is"
},
{
"name": "lambda"
},
{
"name": "nonlocal"
},
{
"name": "not"
},
{
"name": "or"
},
{
"name": "pass"
},
{
"name": "raise"
},
{
"name": "return"
},
{
"name": "try"
},
{
"name": "while"
},
{
"name": "with"
},
{
"name": "yield"
}
],
"name": "PythonReservedWords"
},
"jsii-calc.ReferenceEnumFromScopedPackage": {
"assembly": "jsii-calc",
"docs": {
Expand Down Expand Up @@ -3842,5 +3949,5 @@
}
},
"version": "0.7.15",
"fingerprint": "P2Hdg9vVBT0QqTFN71VaRnkkGvJ74jnUBL7BduuDsjU="
"fingerprint": "IWSOEhdZzuvrss5K2WBjZCawXayV13yCAKTj/kJ9+mo="
}
Loading