-
-
Notifications
You must be signed in to change notification settings - Fork 308
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
Make the movie lister example work on Windows #458
base: develop
Are you sure you want to change the base?
Changes from 2 commits
3888c4c
4206c33
be24fb9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,9 @@ | |
|
||
|
||
def create_csv(movies_data, path): | ||
with open(path, 'w') as opened_file: | ||
with open(path, 'w', newline='') as opened_file: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you remember what error you got before making this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error message was: The movies.csv file was like this:
|
||
writer = csv.writer(opened_file) | ||
for row in movies_data: | ||
writer.writerow(row) | ||
writer.writerows(movies_data) | ||
|
||
|
||
def create_sqlite(movies_data, path): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ | |
|
||
from dependency_injector.wiring import inject, Provide | ||
|
||
from .listers import MovieLister | ||
from .containers import Container | ||
from movies.listers import MovieLister | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked for any specific behavior of relative imports on Windows, but didn't find anything. Seems like you've had a problem with it. Do you remember how you ran it and what was the problem? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was a problem when using VS Code.. |
||
from movies.containers import Container | ||
|
||
|
||
@inject | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
echo on | ||
set PYTHON37=%UserProfile%\AppData\Local\Programs\Python\Python37\python.exe | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm unsure if it's ok to use a specific version of Python in the documentation. The idea is that this example should work for all supported Python versions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line could be removed and a comment added that the assumption is made that PATH environment variable is pointing to the python installation. |
||
|
||
REM set variabless | ||
set ENV_NAME=wslenv2-win | ||
set VENV_DIR=%ENV_NAME%\Scripts | ||
set PYTHON_VENV=%VENV_DIR%\python.exe | ||
|
||
%PYTHON37% -m venv %ENV_NAME% | ||
|
||
Start /WAIT cmd /k "%VENV_DIR%\activate & %PYTHON_VENV% -m pip install --upgrade pip & %PYTHON_VENV% -m pip install -r .\requirements.txt & set MOVIE_FINDER_TYPE=csv& %PYTHON_VENV% -m movies & set MOVIE_FINDER_TYPE=sqlite& %PYTHON_VENV% -m movies&%VENV_DIR%\deactivate & pause & exit 0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to split this line to multiple? Kind of hard to scroll it now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes.. it is, by adding a ^as a multiline command separator. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash -ef | ||
|
||
rm -rf wslenv2 | ||
|
||
python3 -m venv wslenv2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, this is basically doing what is done in the readme, correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. |
||
. wslenv2/bin/activate | ||
pip install -r requirements.txt | ||
|
||
wslenv2/bin/python data/fixtures.py | ||
|
||
MOVIE_FINDER_TYPE=csv wslenv2/bin/python -m movies | ||
MOVIE_FINDER_TYPE=sqlite wslenv2/bin/python -m movies | ||
|
||
source deactivate |
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.
I'm unsure we need these imports here
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.
This is how the virtual environment is created under Windows.