Kaydet (Commit) 1afae0fa authored tarafından Batuhan Taşkaya's avatar Batuhan Taşkaya

pipenv support

üst 699a11c5
...@@ -6,8 +6,9 @@ before_script: ...@@ -6,8 +6,9 @@ before_script:
python: python:
- "3.7-dev" - "3.7-dev"
install: install:
- pip install -r requirements/travis.pip - pip install pipenv
- pipenv install
env: env:
- DJANGO_ENV=travis - DJANGO_ENV=travis
script: script:
- python manage.py test applications -v 2 - pipenv run python manage.py test applications -v 2
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
ipython = "==7.4.0"
bpython = "==0.18"
django-debug-toolbar = "==1.11"
coverage = "==4.5.3"
isort = "==4.3.16"
black = "==19.3b0"
flake8 = "==3.7.7"
flake8-bandit = "==2.1.0"
flake8-blind-except = "==0.1.1"
flake8-bugbear = "==18.8.0"
flake8-builtins = "==1.4.1"
flake8-polyfill = "==1.0.2"
flake8-print = "==3.1.0"
flake8-quotes = "==1.0.0"
flake8-string-format = "==0.2.3"
pylint = "==2.3.1"
Werkzeug = "==0.15.2"
[packages]
django-extensions = "==2.1.6"
python-slugify = "==3.0.2"
psycopg2-binary = "==2.8"
dj-database-url = "==0.5.0"
Django = "==2.2"
Pillow = "==6.0.0"
[requires]
python_version = "3.7"
This diff is collapsed.
...@@ -13,7 +13,7 @@ Django releases as much as I can! ...@@ -13,7 +13,7 @@ Django releases as much as I can!
- Latest `Python 3.7.0` runtime environment. - Latest `Python 3.7.0` runtime environment.
- `PostgreSQL` - `PostgreSQL`
- `pip`, `virtualenv`, `virtualenvwrapper` - `pipenv`
- If you like to run Rake Tasks, you need `Ruby` too but not required: `2.5.0` - If you like to run Rake Tasks, you need `Ruby` too but not required: `2.5.0`
## Installation ## Installation
...@@ -31,30 +31,20 @@ database: ...@@ -31,30 +31,20 @@ database:
$ createdb my_project_dev $ createdb my_project_dev
``` ```
Please use `virtualenvwrapper` and create your environment and activate it.
With Python 3.3+, you don’t need to install `virtualenv`. You can create your
environment via; `python -m venv /path/to/your/environment`
Use pipenv to activate your virtual environment if that exists else create one and activate.
```bash ```bash
# example $ pipenv shell
$ mkvirtualenv my_projects_env
# or make it active:
$ workon my_projects_env
``` ```
You need to declare **3 environment** variables. I always put my project You need to declare **3 environment** variables.
specific environment variables under `virtualenvwrapper`’s `postactivate`
file. Open your `~/.virtualenvs/my_projects_env/bin/postactivate` and add
these lines (*or set it manually*):
```bash ```bash
export DJANGO_ENV="development" export DJANGO_ENV="development"
export DJANGO_SECRET="YOUR-SECRET-HERE" # will fix it in a second. export DJANGO_SECRET="YOUR-SECRET-HERE" # will fix it in a second.
export DATABASE_URL="postgres://localhost:5432/my_project_dev" export DATABASE_URL="postgres://localhost:5432/my_project_dev"
``` ```
then trigger `workon my_projects_env`, this reloads environment variables. If you put them into an `.env` file pipenv will automatically load them.
then; then;
```bash ```bash
...@@ -69,7 +59,7 @@ $ cp config/settings/development.example.py config/settings/development.py ...@@ -69,7 +59,7 @@ $ cp config/settings/development.example.py config/settings/development.py
$ cp config/settings/test.example.py config/settings/test.py $ cp config/settings/test.example.py config/settings/test.py
# development.py is not under revison control # development.py is not under revison control
# test.py is not under revison control # test.py is not under revison control
$ pip install -r requirements/development.pip $ pipenv install
$ git init # now you can start your own repo! $ git init # now you can start your own repo!
``` ```
...@@ -78,7 +68,7 @@ or, you can use installer script: ...@@ -78,7 +68,7 @@ or, you can use installer script:
```bash ```bash
$ bash <(curl -fsSL https://raw.githubusercontent.com/vigo/django2-project-template/master/install.sh) $ bash <(curl -fsSL https://raw.githubusercontent.com/vigo/django2-project-template/master/install.sh)
$ cd YOUR_PROJECT/ $ cd YOUR_PROJECT/
$ pip install -r requirements/development.pip $ pipenv install
$ git init # now you can start your own repo! $ git init # now you can start your own repo!
``` ```
...@@ -502,10 +492,6 @@ Here is directory/file structure: ...@@ -502,10 +492,6 @@ Here is directory/file structure:
├── db ├── db
├── locale ├── locale
│   └── tr │   └── tr
├── requirements
│   ├── base.pip
│   ├── development.pip
│   └── heroku.pip
├── static ├── static
│   └── css │   └── css
├── templates ├── templates
...@@ -515,7 +501,8 @@ Here is directory/file structure: ...@@ -515,7 +501,8 @@ Here is directory/file structure:
├── Procfile ├── Procfile
├── Rakefile ├── Rakefile
├── manage.py ├── manage.py
├── requirements.txt ├── Pipfile
├── Pipfile.lock
└── runtime.txt └── runtime.txt
``` ```
...@@ -538,15 +525,16 @@ All the other settings files (*according to environment*) imports ...@@ -538,15 +525,16 @@ All the other settings files (*according to environment*) imports
un-tracked/git-ignored file. Original file is `development.example.py`. You un-tracked/git-ignored file. Original file is `development.example.py`. You
need to create a copy of it! (*if you follow along from the beginning, you’ve already did this*) need to create a copy of it! (*if you follow along from the beginning, you’ve already did this*)
All the base/common required Python packages/modules are defined under `requirements/base.pip`: All the base/common required Python packages/modules are defined under `Pipfile`'s `packages` scope.:
```bash ```bash
Django==2.2 [packages]
Pillow==6.0.0 django-extensions = "==2.1.6"
django-extensions==2.1.6 python-slugify = "==3.0.2"
python-slugify==3.0.2 psycopg2-binary = "==2.8"
psycopg2-binary==2.8 dj-database-url = "==0.5.0"
dj-database-url==0.5.0 Django = "==2.2"
Pillow = "==6.0.0"
``` ```
### `base.py` ### `base.py`
...@@ -658,26 +646,33 @@ mode. ...@@ -658,26 +646,33 @@ mode.
simple passwords such as `1234`. `MEDIA_ROOT` is set to basedir’s `media` folder, simple passwords such as `1234`. `MEDIA_ROOT` is set to basedir’s `media` folder,
`STATICFILES_DIRS` includes basedir’s `static` folder. `STATICFILES_DIRS` includes basedir’s `static` folder.
All the required modules are defined under `requirements/development.pip`: All the required modules are defined under `Pipfile`'s `dev-packages` scope.:
```bash ```bash
-r base.pip [dev-packages]
ipython==7.4.0 ipython = "==7.4.0"
Werkzeug==0.15.2 bpython = "==0.18"
django-debug-toolbar==1.11 django-debug-toolbar = "==1.11"
coverage==4.5.3 coverage = "==4.5.3"
isort==4.3.16 isort = "==4.3.16"
black==19.3b0 black = "==19.3b0"
flake8==3.7.7 flake8 = "==3.7.7"
flake8-bandit==2.1.0 flake8-bandit = "==2.1.0"
flake8-blind-except==0.1.1 flake8-blind-except = "==0.1.1"
flake8-bugbear==18.8.0 flake8-bugbear = "==18.8.0"
flake8-builtins==1.4.1 flake8-builtins = "==1.4.1"
flake8-polyfill==1.0.2 flake8-polyfill = "==1.0.2"
flake8-print==3.1.0 flake8-print = "==3.1.0"
flake8-quotes==1.0.0 flake8-quotes = "==1.0.0"
flake8-string-format==0.2.3 flake8-string-format = "==0.2.3"
pylint==2.3.1 pylint = "==2.3.1"
Werkzeug = "==0.15.2"
```
They can be installed by;
```
$ pipenv install --dev
``` ```
### `test.example.py` ### `test.example.py`
...@@ -703,18 +698,11 @@ ALLOWED_HOSTS = [ ...@@ -703,18 +698,11 @@ ALLOWED_HOSTS = [
] ]
``` ```
All the required modules are defined under `requirements/heroku.pip`: Heroku supports Pipenv as native but you need to install few dependicies for heroku
separately.
```bash ```bash
-r base.pip pipenv install gunicorn whitenoise
gunicorn==19.9.0
whitenoise==4.1.2
```
By default, Heroku requires `requirements.txt`. Therefore we have it too :)
```python
-r requirements/heroku.pip
``` ```
Heroku also requires `Procfile` and `runtime.txt`. Both provided in the basedir. Heroku also requires `Procfile` and `runtime.txt`. Both provided in the basedir.
...@@ -736,10 +724,9 @@ $ heroku run python manage.py createsuperuser ...@@ -736,10 +724,9 @@ $ heroku run python manage.py createsuperuser
If you are using different platform or OS, such as Ubuntu or your custom If you are using different platform or OS, such as Ubuntu or your custom
servers, you can follow the settings and requirements conventions. If you name servers, you can follow the settings and requirements conventions. If you name
it `production`, create your `config/settings/production.py` and it `production`, create your `config/settings/production.py`. You must set you
`requirements/production.pip`. You must set you `DJANGO_ENV` to `production` `DJANGO_ENV` to `production` and don’t forget to set `DJANGO_ENV` and `DJANGO_SECRET`
and don’t forget to set `DJANGO_ENV` and `DJANGO_SECRET` on your production on your production server!
server!
--- ---
...@@ -1182,8 +1169,8 @@ class MyAdmin(admin.ModelAdmin): ...@@ -1182,8 +1169,8 @@ class MyAdmin(admin.ModelAdmin):
} }
``` ```
This widget uses `Pillow` (*Python Image Library*) which ships with your `base.pip` This widget uses `Pillow` (*Python Image Library*) which ships with your `Pipfile`
requirements file. Show image preview, width x height if the file is image. Show image preview, width x height if the file is image.
--- ---
......
...@@ -71,9 +71,9 @@ cp config/settings/test.example.py config/settings/test.py && ...@@ -71,9 +71,9 @@ cp config/settings/test.example.py config/settings/test.py &&
echo echo
echo echo
printf "${color_2}Installation completed...${color_r}\n\n" printf "${color_2}Installation completed...${color_r}\n\n"
echo -e "\tNow, create your virtual environment and run:" echo -e "\tNow, set-up your dependicies by running:"
echo echo
echo -e "\tcd ${PROJECT_NAME}/" echo -e "\tcd ${PROJECT_NAME}/"
echo -e "\tpip install -r requirements/development.pip" echo -e "\tpipenv install"
echo echo
echo echo
-r requirements/heroku.pip
\ No newline at end of file
Django==2.2
Pillow==6.0.0
django-extensions==2.1.6
python-slugify==3.0.2
psycopg2-binary==2.8
dj-database-url==0.5.0
-r base.pip
ipython==7.4.0
bpython==0.18
Werkzeug==0.15.2
django-debug-toolbar==1.11
coverage==4.5.3
isort==4.3.16
black==19.3b0
flake8==3.7.7
flake8-bandit==2.1.0
flake8-blind-except==0.1.1
flake8-bugbear==18.8.0
flake8-builtins==1.4.1
flake8-polyfill==1.0.2
flake8-print==3.1.0
flake8-quotes==1.0.0
flake8-string-format==0.2.3
pylint==2.3.1
-r base.pip
gunicorn==19.9.0
whitenoise==4.1.2
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment