-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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 init template does not work on Windows #2181
Comments
Does the init command fail? Or does it just not create the virtualenv? |
It fails as is cannot find python3: C:>mkdir hello-cdk C:>cd hello-cdk C:\hello-cdk>cdk init --language python |
But does it create the git repo and copy the files over? If so, can you just manually run the virtualenv command and proceed or does it leave things in a funky state? |
I get: C:\hello-cdk>dir Directory of C:\hello-cdk 04/04/2019 12:20 PM .04/04/2019 12:20 PM .. 04/04/2019 12:20 PM 156 app.py 10/26/1985 01:15 AM 32 cdk.json 04/04/2019 12:20 PM hello-cdk 10/26/1985 01:15 AM 1,082 README.md 10/26/1985 01:15 AM 5 requirements.txt 04/04/2019 12:20 PM 1,025 setup.py 5 File(s) 2,300 bytes 3 Dir(s) 718,458,163,200 bytes free C:\hello-cdk>dir hello-cdk Directory of C:\hello-cdk\hello-cdk 04/04/2019 12:20 PM .04/04/2019 12:20 PM .. 04/04/2019 12:20 PM 212 hello-cdk_stack.py 10/26/1985 01:15 AM 0 init.py 2 File(s) 212 bytes |
and .git |
Okay, trying to get this to work on Windows is more trouble than doing it all by hand. For now I recommend we follow instructions similar to what we used back in 0.20.0, https://awslabs.github.io/aws-cdk/versions/0.20.0/getting-started.html:
|
I guess I don't really see how that's easier. You just run the |
I installed cdk v 0.28.0 as the Python init template was not available until 0.28.0 I created hello-cdk directory and cd'd into it I ran "cdk init --language python" and got the error message discussed previously I changed "python3" to "python" in cdk.json and app.py I ran "pip install -r requirements.txt" I ran "cdk synth" and got an error:
To: HelloCdkStack(app, "hello-cdk-cdk-1") And reran "cdk synth". No love. I got a similar error:
So I just changed app.py to: #!/usr/bin/env python from aws_cdk import cdk class HelloCdkStack(cdk.Stack):
app = cdk.App() app.run() And re-ran "cdk synth". This time I got: Traceback (most recent call last): Needless to say, I'm quitting now. |
Also, you might want to try I'll fire up a Windows machine to test with. |
I tried adding sample-app, but similar results, although at least app.py had the correct reference to the stack class. |
I linked python3.exe to python.exe on my Windows box ("mklink python3.exe python.exe" as admin) and ran "cdk init --language python" and got: Applying project template app for python So I ran "python -m venv .env", then "cdk ls" and got: File "app.py", line 5 Any ideas? |
Okay, I finally got a Windows EC2 instance all configured to do some testing. Here's what I did.
This definitely looks like a bug in the Python JSII kernel when it tries to start the JSII process using the |
Can we (try to) predict whether the correct invocation is I'd rather fix that as well since even though it's a minor thing, it is bound to confuse and trip up people. |
Maybe use this ? |
I agree that fixing the The We could try I kind of feel like the Windows installer for Python is broken if it doesn't install a I don't see a way around doing a bunch of platform-specific stuff in the |
@garnaat I got the same error you got following your instructions. |
From the docs looks like And yes, we'd have to switch on the platform. But looks like the python distro from python.org doesn't install python3.exe? |
The above commit fixes the problem I have shown above (the same one @Doug-AWS was able to reproduce). So, progress. It turns out the shebang So, the remaining problem is the explicit calls to In addition, the Python packager in JSII does this all over the place and those explicit calls will fail on Windows and so those, too, need to be platform-aware or packaging will not work on Windows. I think I will fix the |
I'm still getting the type error in 0.29.0: TypeError: argument of type 'WindowsPath' is not iterable |
I missed a step on Windows: .env\Scripts\activate.bat |
@garnaat were you able to fix the JSII issue? I am running into the same error. is there a fix out yet? |
Python 3.7 installs python.exe, not python3.exe
There is no 'source' command in Windows
The paths shown in the README.md file are Linux/Unix/Mac, not Windows paths
The text was updated successfully, but these errors were encountered: