diff --git a/.gitignore b/.gitignore index e2195edff..43967294d 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,12 @@ src/dependency_injector/providers/*.so # Workspace for samples .workspace/ +/examples/miniapps/movie-lister/wslenv2-win/Scripts +/examples/miniapps/movie-lister/wslenv2-win +/examples/miniapps/movie-lister/wslenv2/bin +/examples/miniapps/movie-lister/wslenv2/share/python-wheels +/examples/miniapps/movie-lister/wslenv2 +/examples/miniapps/movie-lister/setup_venv.bat +/examples/miniapps/movie-lister/setup_venv.sh +/examples/miniapps/movie-lister/run_movie_lister.bat +/examples/miniapps/movie-lister/run_movie_lister.sh diff --git a/examples/miniapps/movie-lister/data/fixtures.py b/examples/miniapps/movie-lister/data/fixtures.py index 2870d04d9..f3b829248 100644 --- a/examples/miniapps/movie-lister/data/fixtures.py +++ b/examples/miniapps/movie-lister/data/fixtures.py @@ -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: writer = csv.writer(opened_file) - for row in movies_data: - writer.writerow(row) + writer.writerows(movies_data) def create_sqlite(movies_data, path): diff --git a/examples/miniapps/movie-lister/movies/__main__.py b/examples/miniapps/movie-lister/movies/__main__.py index 975618f38..561a6ac58 100644 --- a/examples/miniapps/movie-lister/movies/__main__.py +++ b/examples/miniapps/movie-lister/movies/__main__.py @@ -4,8 +4,8 @@ from dependency_injector.wiring import inject, Provide -from .listers import MovieLister -from .containers import Container +from movies.listers import MovieLister +from movies.containers import Container @inject diff --git a/examples/miniapps/movie-lister/movies/containers.py b/examples/miniapps/movie-lister/movies/containers.py index 9d30fbfb8..4425c6a71 100644 --- a/examples/miniapps/movie-lister/movies/containers.py +++ b/examples/miniapps/movie-lister/movies/containers.py @@ -2,7 +2,7 @@ from dependency_injector import containers, providers -from . import finders, listers, entities +from movies import finders, listers, entities class Container(containers.DeclarativeContainer): diff --git a/examples/miniapps/movie-lister/movies/finders.py b/examples/miniapps/movie-lister/movies/finders.py index 3485d8c38..85601b735 100644 --- a/examples/miniapps/movie-lister/movies/finders.py +++ b/examples/miniapps/movie-lister/movies/finders.py @@ -4,7 +4,7 @@ import sqlite3 from typing import Callable, List -from .entities import Movie +from movies.entities import Movie class MovieFinder: diff --git a/examples/miniapps/movie-lister/movies/listers.py b/examples/miniapps/movie-lister/movies/listers.py index 36d254c20..4da5b40b0 100644 --- a/examples/miniapps/movie-lister/movies/listers.py +++ b/examples/miniapps/movie-lister/movies/listers.py @@ -1,6 +1,6 @@ """Movie listers module.""" -from .finders import MovieFinder +from movies.finders import MovieFinder class MovieLister: diff --git a/examples/miniapps/movie-lister/movies/tests.py b/examples/miniapps/movie-lister/movies/tests.py index eea04c81b..af91a8710 100644 --- a/examples/miniapps/movie-lister/movies/tests.py +++ b/examples/miniapps/movie-lister/movies/tests.py @@ -4,7 +4,7 @@ import pytest -from .containers import Container +from movies.containers import Container @pytest.fixture diff --git a/examples/miniapps/movie-lister/setup_and_run_movie_lister.bat b/examples/miniapps/movie-lister/setup_and_run_movie_lister.bat new file mode 100644 index 000000000..8f20daf02 --- /dev/null +++ b/examples/miniapps/movie-lister/setup_and_run_movie_lister.bat @@ -0,0 +1,22 @@ +echo on +REM The assumption is made that the python executable can be found. + +REM Set variabless +set ENV_NAME=wslenv2-win +set VENV_DIR=%ENV_NAME%\Scripts +set PYTHON_VENV=%VENV_DIR%\python.exe + +REM Create virtual environment +python -m venv %ENV_NAME% + +REM Populate dependencies and run the example +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 + diff --git a/examples/miniapps/movie-lister/setup_and_run_movie_lister.sh b/examples/miniapps/movie-lister/setup_and_run_movie_lister.sh new file mode 100644 index 000000000..9b34ac6f0 --- /dev/null +++ b/examples/miniapps/movie-lister/setup_and_run_movie_lister.sh @@ -0,0 +1,14 @@ +#!/bin/bash -ef + +rm -rf wslenv2 + +python3 -m venv wslenv2 +. 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