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

pipenv support

üst 699a11c5
......@@ -6,8 +6,9 @@ before_script:
python:
- "3.7-dev"
install:
- pip install -r requirements/travis.pip
- pip install pipenv
- pipenv install
env:
- DJANGO_ENV=travis
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!
- Latest `Python 3.7.0` runtime environment.
- `PostgreSQL`
- `pip`, `virtualenv`, `virtualenvwrapper`
- `pipenv`
- If you like to run Rake Tasks, you need `Ruby` too but not required: `2.5.0`
## Installation
......@@ -31,30 +31,20 @@ database:
$ 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
# example
$ mkvirtualenv my_projects_env
# or make it active:
$ workon my_projects_env
$ pipenv shell
```
You need to declare **3 environment** variables. I always put my project
specific environment variables under `virtualenvwrapper`’s `postactivate`
file. Open your `~/.virtualenvs/my_projects_env/bin/postactivate` and add
these lines (*or set it manually*):
You need to declare **3 environment** variables.
```bash
export DJANGO_ENV="development"
export DJANGO_SECRET="YOUR-SECRET-HERE" # will fix it in a second.
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;
```bash
......@@ -69,7 +59,7 @@ $ cp config/settings/development.example.py config/settings/development.py
$ cp config/settings/test.example.py config/settings/test.py
# development.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!
```
......@@ -78,7 +68,7 @@ or, you can use installer script:
```bash
$ bash <(curl -fsSL https://raw.githubusercontent.com/vigo/django2-project-template/master/install.sh)
$ cd YOUR_PROJECT/
$ pip install -r requirements/development.pip
$ pipenv install
$ git init # now you can start your own repo!
```
......@@ -502,10 +492,6 @@ Here is directory/file structure:
├── db
├── locale
│   └── tr
├── requirements
│   ├── base.pip
│   ├── development.pip
│   └── heroku.pip
├── static
│   └── css
├── templates
......@@ -515,7 +501,8 @@ Here is directory/file structure:
├── Procfile
├── Rakefile
├── manage.py
├── requirements.txt
├── Pipfile
├── Pipfile.lock
└── runtime.txt
```
......@@ -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
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
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
[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"
```
### `base.py`
......@@ -658,26 +646,33 @@ mode.
simple passwords such as `1234`. `MEDIA_ROOT` is set to basedir’s `media` 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
-r base.pip
ipython==7.4.0
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
[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"
```
They can be installed by;
```
$ pipenv install --dev
```
### `test.example.py`
......@@ -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
-r base.pip
gunicorn==19.9.0
whitenoise==4.1.2
```
By default, Heroku requires `requirements.txt`. Therefore we have it too :)
```python
-r requirements/heroku.pip
pipenv install gunicorn whitenoise
```
Heroku also requires `Procfile` and `runtime.txt`. Both provided in the basedir.
......@@ -736,10 +724,9 @@ $ heroku run python manage.py createsuperuser
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
it `production`, create your `config/settings/production.py` and
`requirements/production.pip`. You must set you `DJANGO_ENV` to `production`
and don’t forget to set `DJANGO_ENV` and `DJANGO_SECRET` on your production
server!
it `production`, create your `config/settings/production.py`. You must set you
`DJANGO_ENV` to `production` and don’t forget to set `DJANGO_ENV` and `DJANGO_SECRET`
on your production server!
---
......@@ -1182,8 +1169,8 @@ class MyAdmin(admin.ModelAdmin):
}
```
This widget uses `Pillow` (*Python Image Library*) which ships with your `base.pip`
requirements file. Show image preview, width x height if the file is image.
This widget uses `Pillow` (*Python Image Library*) which ships with your `Pipfile`
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 &&
echo
echo
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 -e "\tcd ${PROJECT_NAME}/"
echo -e "\tpip install -r requirements/development.pip"
echo -e "\tpipenv install"
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