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

[cli] Initialize Python application without setup.py #9135

Open
2 tasks
alexpulver opened this issue Jul 17, 2020 · 8 comments
Open
2 tasks

[cli] Initialize Python application without setup.py #9135

alexpulver opened this issue Jul 17, 2020 · 8 comments
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p2 package/tools Related to AWS CDK Tools or CLI

Comments

@alexpulver
Copy link
Contributor

cdk init --language python generates setup.py file, and requirements.txt file with -e ., that installs the project in editable mode (i.e. setuptools “develop mode”) from local path. This approach is used for distributing Python code to developers - a reusable construct in CDK case. CDK application is not a reusable construct, hence shouldn't have setup.py, and only list its direct dependencies in requirements.txt.

Use Case

Make cdk init --language python scaffolding more aligned with Python guidance on packaging applications as compared to packaging libraries and tools

Proposed Solution

Remove setup.py and -e . from requirements.txt when running cdk init --language python

Other

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@alexpulver alexpulver added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jul 17, 2020
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Jul 17, 2020
@polothy
Copy link
Contributor

polothy commented Jul 17, 2020

I ran into this same problem and Intellij treats the project "funny" (read: not in a good way). I ended up removing setup.py and everything behaves a lot better.

@ghost
Copy link

ghost commented Jul 18, 2020

I always thought this was a bit unusual myself.

@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Jul 20, 2020
@shivlaks shivlaks added p1 effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md labels Aug 4, 2020
@shivlaks
Copy link
Contributor

shivlaks commented Aug 4, 2020

@alexpulver thanks for logging this feature request, I agree that we should be aligning ourselves with Python guidance on packaging applications.

@alexpulver
Copy link
Contributor Author

Hey @shivlaks, is there any update on this?

@Jacco
Copy link
Contributor

Jacco commented May 8, 2022

Verified with CDK version 2.23.0: no setup.py is generated.

I think this issue can be closed.

% cdk --version
2.23.0 (build 50444aa)
% ls -lah
total 56
drwxr-xr-x  13 jaccokulman  staff   416B  8 mei 13:18 .
drwxr-xr-x@  7 jaccokulman  staff   224B  8 mei 13:20 ..
drwxr-xr-x  12 jaccokulman  staff   384B  8 mei 13:20 .git
-rw-r--r--   1 jaccokulman  staff   119B  8 mei 13:20 .gitignore
drwxr-xr-x   6 jaccokulman  staff   192B  8 mei 13:20 .venv
-rw-r--r--   1 jaccokulman  staff   1,6K  8 mei 13:20 README.md
-rw-r--r--   1 jaccokulman  staff   935B  8 mei 13:20 app.py
-rw-r--r--   1 jaccokulman  staff   871B  8 mei 13:20 cdk.json
drwxr-xr-x   4 jaccokulman  staff   128B  8 mei 13:20 init_tst2
-rw-r--r--   1 jaccokulman  staff    14B  8 mei 13:20 requirements-dev.txt
-rw-r--r--   1 jaccokulman  staff    47B  8 mei 13:20 requirements.txt
-rw-r--r--   1 jaccokulman  staff   437B  8 mei 13:20 source.bat
drwxr-xr-x   4 jaccokulman  staff   128B  8 mei 13:20 tests

@jazzabeanie
Copy link

Std out from cdk init --language=python still says:

To add additional dependencies, for example other CDK libraries, just add
them to your `setup.py` file and rerun the `pip install -r requirements.txt`
command.

@Jacco
Copy link
Contributor

Jacco commented May 10, 2022

Std out from cdk init --language=python still says:

To add additional dependencies, for example other CDK libraries, just add
them to your `setup.py` file and rerun the `pip install -r requirements.txt`
command.

Ah yes, missed that :-) I guess that should read:

To add additional dependencies, for example other CDK libraries, just add
them to your `requirements.txt` file and rerun the `pip install -r requirements.txt`
command.

I am not too experienced in python though. In npm there is an option to save to package.json automatically.

The template can be changed here:

To add additional dependencies, for example other CDK libraries, just add
them to your `setup.py` file and rerun the `pip install -r requirements.txt`
command.

Happy to make a PR if the text above is ok :-)

@jazzabeanie
Copy link

jazzabeanie commented May 25, 2022

I don't think there is an equivalent to npn install --save. What you've got there looks good to me, although, docs do say to run
python -m pip install -r requirements.txt. I have a feeling that it's something to do with having a command that also works on Windows.

@TheRealAmazonKendra TheRealAmazonKendra added p2 and removed p1 labels Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p2 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

No branches or pull requests

8 participants