Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Add Django 3.X, Py3.{7, 8, 9} and PyPy3 & Drop Dj1.11, Py2 and PyPy2 #971

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ dist: xenial
language: python

python:
- "2.7"
- "3.5"
- "3.6"
- "3.7"
- "pypy"
- "3.8"
- "3.9"
- "pypy3"

install:
- pip list & pip install -U setuptools && pip install -U tox-travis
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check
3. The pull request should work for Python 3.6, 3.7, 3.8 and 3.9, and for PyPy3. Check
https://travis-ci.org/pydanny/cookiecutter-djangopackage/pull_requests
and make sure that the tests pass for all supported Python versions.

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ It prompts you for information that it uses to create the app, with defaults in
app_name [blogging_for_humans]:
project_short_description [Your project description goes here]: A sample Django package
models [Comma-separated list of models]: Scoop, Flavor
django_versions [1.11,2.1]:
django_versions [2.2,3.0,3.1]:
version [0.1.0]:
create_example_project [N]:
Select open_source_license:
Expand Down
1 change: 1 addition & 0 deletions contributors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ Contributors
* Bruno Alla / @browniebroke
* Steve Steiner / @ssteinerX
* Luiz Marques @luizanao
* Serhat Teker / @SerhatTeker
2 changes: 1 addition & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"app_config_name": "{{ cookiecutter.app_name.replace('_', ' ')|title()|replace(' ', '') }}Config",
"project_short_description": "Your project description goes here",
"models": "Comma-separated list of models",
"django_versions": "1.11,2.1",
"django_versions": "2.2,3.0,3.1",
"version": "0.1.0",
"create_example_project": "N",
"open_source_license": ["MIT", "BSD", "ISCL", "Apache Software License 2.0", "Not open source"]
Expand Down
2 changes: 1 addition & 1 deletion hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
logger.error('Invalid value for app_name "{}"'.format(app_name))
sys.exit(1)

ALLOWED_VERSIONS = ["1.11", "2.1", "master"]
ALLOWED_VERSIONS = ["2.2", "3.0", "3.1", "master"]

for django_version in '{{cookiecutter.django_versions}}'.split(","):
if str(django_version).strip() not in ALLOWED_VERSIONS:
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[pytest]
testpaths = tests/
testpaths = tests/
7 changes: 3 additions & 4 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
pip==9.0.1
cookiecutter==1.6.0
pytest-cookies==0.2.0
pytest==3.2.2
tox==2.9.1
tox==3.20.0
pytest-cov==2.5.1
watchdog==0.8.3
sh==1.12.14
flake8==3.4.1
sh==1.14.2
flake8==3.7.9
50 changes: 28 additions & 22 deletions tests/test_bake_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,54 +181,60 @@ def test_django_versions_default(cookies):

tox_file = result.project.join('tox.ini')
tox_text = tox_file.read()
assert "{py27,py35,py36}-django-111" in tox_text
assert "{py35,py36,py37}-django-21" in tox_text
assert "{py36,py37,py38,py39}-django-22" in tox_text
assert "{py36,py37,py38,py39}-django-30" in tox_text
assert "{py36,py37,py38,py39}-django-31" in tox_text
travis_file = result.project.join('.travis.yml')
travis_text = travis_file.read()
assert 'py35-django-111' in travis_text
assert 'py36-django-111' in travis_text
assert 'py35-django-21' in travis_text
assert 'py36-django-21' in travis_text
assert 'py37-django-21' in travis_text
assert 'py36-django-22' in travis_text
assert 'py37-django-22' in travis_text
assert 'py38-django-22' in travis_text
assert 'py39-django-22' in travis_text
setup_file = result.project.join('setup.py')
setup_text = setup_file.read()
assert "'Framework :: Django :: 1.11'," in setup_text
assert "'Framework :: Django :: 2.1'," in setup_text
assert "'Programming Language :: Python :: 2'," in setup_text
assert "'Programming Language :: Python :: 2.7'," in setup_text
assert "'Framework :: Django :: 2.2'," in setup_text
assert "'Framework :: Django :: 3.0'," in setup_text
assert "'Framework :: Django :: 3.1'," in setup_text
assert "'Programming Language :: Python :: 3'," in setup_text
assert "'Programming Language :: Python :: 3.5'," in setup_text
assert "'Programming Language :: Python :: 3.6'," in setup_text
assert "'Programming Language :: Python :: 3.7'," in setup_text
assert "'Programming Language :: Python :: 3.8'," in setup_text
assert "'Programming Language :: Python :: 3.9'," in setup_text


def test_new_django_versions(cookies):
"""
Test case to assert that the tox.ini & setup.py files are generated with correct versions with a new Django version
"""

extra_context = {'django_versions': '1.11,2.1'}
extra_context = {'django_versions': '2.2,3.0,3.1'}
with bake_in_temp_dir(cookies, extra_context=extra_context) as result:

tox_file = result.project.join('tox.ini')
tox_text = tox_file.read()
assert "{py27,py35,py36}-django-111" in tox_text
assert "{py27,py35,py36}-django-111" not in tox_text
assert 'django19' not in tox_text
travis_file = result.project.join('.travis.yml')
travis_text = travis_file.read()
assert 'py27-django-111' in travis_text
assert 'py35-django-111' in travis_text
assert 'py36-django-30' in travis_text
assert 'py36-django-31' in travis_text
assert 'django19' not in travis_text
setup_file = result.project.join('setup.py')
setup_text = setup_file.read()
assert "'Framework :: Django :: 2.1'," in setup_text
assert "'Framework :: Django :: 1.11'," in setup_text
assert "'Framework :: Django :: 1.9'," not in setup_text
assert "'Programming Language :: Python :: 2'," in setup_text
assert "'Programming Language :: Python :: 2.7'," in setup_text
assert "'Framework :: Django :: 1.11'," not in setup_text
assert "'Framework :: Django :: 2.1'," not in setup_text
assert "'Framework :: Django :: 2.2'," in setup_text
assert "'Framework :: Django :: 3.0'," in setup_text
assert "'Framework :: Django :: 3.1'," in setup_text
assert "'Programming Language :: Python :: 3'," in setup_text
assert "'Programming Language :: Python :: 3.5'," in setup_text
assert "'Programming Language :: Python :: 3.5'," not in setup_text
assert "'Programming Language :: Python :: 3.6'," in setup_text
assert "'Programming Language :: Python :: 3.7'," in setup_text
assert "'Programming Language :: Python :: 3.8'," in setup_text
assert "'Programming Language :: Python :: 3.9'," in setup_text
assert "'Programming Language :: Python :: 2.7'," not in setup_text
assert "'Programming Language :: Python :: 3.3'," not in setup_text
assert "'Programming Language :: Python :: 3.4'," not in setup_text


def test_flake8_compliance(cookies):
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[tox]
envlist = py27, py34, py35, py36, pypy
envlist = py36, py37, py38, py39, pypy3
skipsdist = true

[testenv]
whitelist_externals = bash
deps =
Django>=1.11,<=2.2
Django>=2.2,<=3.1
-rrequirements_dev.txt

commands =
Expand Down
32 changes: 20 additions & 12 deletions {{cookiecutter.repo_name}}/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@ language: python
python:
- "3.6"

env: {% if '1.11' in cookiecutter.django_versions %}
- TOX_ENV=py36-django-111
- TOX_ENV=py35-django-111
- TOX_ENV=py27-django-111{% endif %}{% if '2.0' in cookiecutter.django_versions %}
- TOX_ENV=py36-django-20
- TOX_ENV=py35-django-20{% endif %}{% if '2.1' in cookiecutter.django_versions %}
- TOX_ENV=py37-django-21
- TOX_ENV=py36-django-21
- TOX_ENV=py35-django-21{% endif %}{% if 'master' in cookiecutter.django_versions %}
- TOX_ENV=py35-django-master
- TOX_ENV=py36-django-master{% endif %}
env: {% if '2.2' in cookiecutter.django_versions %}
- TOX_ENV=py39-django-22
- TOX_ENV=py38-django-22
- TOX_ENV=py37-django-22
- TOX_ENV=py36-django-22{% endif %}{% if '3.0' in cookiecutter.django_versions %}
- TOX_ENV=py36-django-30
- TOX_ENV=py37-django-30
- TOX_ENV=py38-django-30
- TOX_ENV=py39-django-30{% endif %}{% if '3.1' in cookiecutter.django_versions %}
- TOX_ENV=py39-django-31
- TOX_ENV=py38-django-31
- TOX_ENV=py37-django-31
- TOX_ENV=py36-django-31{% endif %}{% if 'master' in cookiecutter.django_versions %}
- TOX_ENV=py36-django-master
- TOX_ENV=py37-django-master
- TOX_ENV=py38-django-master
- TOX_ENV=py39-django-master{% endif %}

matrix:
fast_finish: true{% if 'master' in cookiecutter.django_versions %}
allow_failures:
- env: TOX_ENV=py35-django-master
- env: TOX_ENV=py39-django-master
- env: TOX_ENV=py38-django-master
- env: TOX_ENV=py37-django-master
- env: TOX_ENV=py36-django-master{% endif %}

# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
Expand Down
13 changes: 7 additions & 6 deletions {{cookiecutter.repo_name}}/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,17 @@ def get_version(*file_paths):
zip_safe=False,
keywords='{{ cookiecutter.repo_name }}',
classifiers=[
'Development Status :: 3 - Alpha',{% if '1.11' in cookiecutter.django_versions %}
'Framework :: Django :: 1.11',{% endif %}{% if '2.1' in cookiecutter.django_versions %}
'Framework :: Django :: 2.1',{% endif %}
'Development Status :: 3 - Alpha',{% if '2.2' in cookiecutter.django_versions %}
'Framework :: Django :: 2.2',{% endif %}{% if '3.0' in cookiecutter.django_versions %}
'Framework :: Django :: 3.0',{% endif %}{% if '3.1' in cookiecutter.django_versions %}
'Framework :: Django :: 3.1',{% endif %}
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
],
)
2 changes: 1 addition & 1 deletion {{cookiecutter.repo_name}}/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def open_browser(path):
try:
from urllib import pathname2url
except:
except Exception:
from urllib.request import pathname2url
webbrowser.open("file://" + pathname2url(os.path.abspath(path)))

Expand Down
20 changes: 11 additions & 9 deletions {{cookiecutter.repo_name}}/tox.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
[tox]
envlist ={% if '2.1' in cookiecutter.django_versions %}
{py35,py36,py37}-django-21{% endif %}{% if '1.11' in cookiecutter.django_versions %}
{py27,py35,py36}-django-111{% endif %}{% if 'master' in cookiecutter.django_versions %}
{py35,py36}-django-master{% endif %}
envlist ={% if '2.2' in cookiecutter.django_versions %}
{py36,py37,py38,py39}-django-22{% endif %}{% if '3.0' in cookiecutter.django_versions %}
{py36,py37,py38,py39}-django-30{% endif %}{% if '3.1' in cookiecutter.django_versions %}
{py36,py37,py38,py39}-django-31{% endif %}{% if 'master' in cookiecutter.django_versions %}
{py36,py37,py38,py39}-django-master{% endif %}

[testenv]
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/{{ cookiecutter.app_name }}
commands = coverage run --source {{ cookiecutter.app_name }} runtests.py
deps ={% if '1.11' in cookiecutter.django_versions %}
django-111: Django>=1.11,<1.12{% endif %}{% if '2.1' in cookiecutter.django_versions %}
django-21: Django>=2.1,<2.2{% endif %}{% if 'master' in cookiecutter.django_versions %}
deps ={% if '2.2' in cookiecutter.django_versions %}
django-22: Django>=2.2,<2.3{% endif %}{% if '3.0' in cookiecutter.django_versions %}
django-30: Django>=3.0,<3.1{% endif %}{% if '3.1' in cookiecutter.django_versions %}
django-31: Django>=3.1,<3.2{% endif %}{% if 'master' in cookiecutter.django_versions %}
django-master: https://github.com/django/django/archive/master.tar.gz{% endif %}
-r{toxinidir}/requirements_test.txt
basepython =
py39: python3.9
py38: python3.8
py37: python3.7
py36: python3.6
py35: python3.5
py27: python2.7