-
Notifications
You must be signed in to change notification settings - Fork 522
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
Create requirements.txt if it doesn't exist #647
Create requirements.txt if it doesn't exist #647
Conversation
This resolves: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt' The command '/bin/sh -c python3 -m pip install -r requirements.txt' returned a non-zero code: 1
Thanks, will take a look soon. Can you recommend a simple python project that I could base a test off of? |
This resolves: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt' The command '/bin/sh -c python3 -m pip install -r requirements.txt' returned a non-zero code: 1
You can use my hello-world at https://github.com/lloydchang/exercism-solutions/tree/master/python/hello-world Here are my steps to reproduce the error:
Initial Context: I ran into the error while following Generating Docker files from https://code.visualstudio.com/docs/azure/docker
Additional Contexts: In Visual Studio Python tutorials, Create a requirements.txt file for the environment is an optional activity; please see: Considering requirements.txt may (be optionally created manually) or may not exist (in a hello-world simple python project), I amended my pull request to create requirements.txt if it doesn't exist: |
@@ -32,6 +32,7 @@ WORKDIR /app | |||
ADD . /app | |||
|
|||
# Using pip: | |||
RUN if [ ! -f requirements.txt ]; then pip3 freeze > requirements.txt; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be added to the commented out sections for pipenv and miniconda as well?
@@ -32,6 +32,7 @@ WORKDIR /app | |||
ADD . /app | |||
|
|||
# Using pip: | |||
RUN if [ ! -f requirements.txt ]; then pip3 freeze > requirements.txt; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I try to run the built image, I get this:
docker run --rm -it -p 3000:3000/tcp hello-world:latest
/usr/local/bin/python3: No module named hello-world
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so it looks like we're picking up the module name from the name of the folder the project is in (in this case hello-world). So I guess it's by design for the current implementation, although we do a better job here on other languages. Is there an official way to properly pick this up (e.g. from a file in the project folder), for possible use later? Thx.
@brettcannon Brett, other than the questions above, this change looks good to me. Do you have any reservations? Thanks! |
@lloydchang I'm going to go ahead and merge this so we can get it into the next release. If you'd like to make updates or provide more info according to above comments, just let me know. Thanks! |
Sorry for not getting back sooner but I was travelling last week. So I actually disagree with this change as freezing should be an explicit step the developer takes, otherwise you aren't making a conscious decision of what dependencies you do (or do not) want to end up in your image. And if the decision to keep this line stands then it should be updated to follow the line it precedes, e.g. |
No problem, thanks for letting me know. I would rather show (or document) best practice first, and have it be convenient second. Does it make sense to only supply the requirements.txt file to install if it exists? Or is it better to supply it always and document that users should create it? Or something else? Thanks! |
This reverts commit d4c1b3e.
@brettcannon, @lloydchang Moved the discussion to #693. Reverting the change for the time being. |
This resolves:
Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
The command '/bin/sh -c python3 -m pip install -r requirements.txt' returned a non-zero code: 1