Skip to content

Commit

Permalink
Actually drops Python 3.7... by: Filip, Piotr
Browse files Browse the repository at this point in the history
  • Loading branch information
caseneuve committed Jul 28, 2023
1 parent 04d71fb commit da6c5ed
Show file tree
Hide file tree
Showing 20 changed files with 37 additions and 38 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ In a PythonAnywhere Bash console, run:

pip3.10 install --user pythonanywhere

If there is no `python3.9` on your PythonAnywhere account,
If there is no `python3.10` on your PythonAnywhere account,
you should upgrade your account to the newest system image.
See [here](https://help.pythonanywhere.com/pages/ChangingSystemImage) how to do that.
`pa` works with python 3.7, 3.8 and 3.9, but we recommend using the latest system image.
`pa` works with python 3.8, 3.9, and 3.10 but we recommend using the latest system image.

### On your own machine
Install the `pythonanywhere` package from [PyPI](https://pypi.org/project/pythonanywhere/).
Expand Down
2 changes: 1 addition & 1 deletion cli/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def autoconfigure(
help="Domain name, eg www.mydomain.com",
),
python_version: str = typer.Option(
"3.7",
"3.8",
"-p",
"--python-version",
help="Python version, eg '3.9'",
Expand Down
2 changes: 1 addition & 1 deletion cli/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def create(
help="Domain name, eg www.mydomain.com",
),
python_version: str = typer.Option(
"3.7",
"3.8",
"-p",
"--python-version",
help="Python version, eg '3.9'",
Expand Down
1 change: 0 additions & 1 deletion pythonanywhere/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import requests

PYTHON_VERSIONS = {
"3.7": "python37",
"3.8": "python38",
"3.9": "python39",
"3.10": "python310",
Expand Down
2 changes: 1 addition & 1 deletion pythonanywhere/snakesay.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3.7
#!/usr/bin/env python3.8
import sys
import textwrap

Expand Down
4 changes: 2 additions & 2 deletions scripts/pa_autoconfigure_django.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3.7
#!/usr/bin/python3.8
"""Autoconfigure a Django project from on a github URL.
- downloads the repo
Expand All @@ -13,7 +13,7 @@
Options:
--branch=<branch> Branch name in case of multiple branches [default: None]
--domain=<domain> Domain name, eg www.mydomain.com [default: your-username.pythonanywhere.com]
--python=<python-version> Python version, eg "3.8" [default: 3.7]
--python=<python-version> Python version, eg "3.9" [default: 3.8]
--nuke *Irrevocably* delete any existing web app config on this domain. Irrevocably.
"""

Expand Down
2 changes: 1 addition & 1 deletion scripts/pa_create_scheduled_task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3.7
#!/usr/bin/python3.8
"""Create a scheduled task.
Two categories of tasks are available: daily and hourly.
Expand Down
4 changes: 2 additions & 2 deletions scripts/pa_create_webapp_with_virtualenv.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3.7
#!/usr/bin/python3.8
"""Create a web app with a virtualenv
- creates a simple hello world web app
Expand All @@ -11,7 +11,7 @@
Options:
--domain=<domain> Domain name, eg www.mydomain.com [default: your-username.pythonanywhere.com]
--python=<python-version> Python version, eg "3.8" [default: 3.7]
--python=<python-version> Python version, eg "3.9" [default: 3.8]
--nuke *Irrevocably* delete any existing web app config on this domain. Irrevocably.
"""

Expand Down
2 changes: 1 addition & 1 deletion scripts/pa_delete_scheduled_task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3.7
#!/usr/bin/python3.8
"""Delete scheduled task(s) by id or nuke'em all.
Usage:
Expand Down
2 changes: 1 addition & 1 deletion scripts/pa_delete_webapp_logs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3.7
#!/usr/bin/python3.8
"""Deletes webapp logs.
- gets list of logs via api
Expand Down
2 changes: 1 addition & 1 deletion scripts/pa_get_scheduled_task_specs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3.7
#!/usr/bin/python3.8
"""Get current scheduled task's specs file by task id.
Available specs are: command, enabled, interval, hour, minute, printable-time,
Expand Down
2 changes: 1 addition & 1 deletion scripts/pa_get_scheduled_tasks_list.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3.7
#!/usr/bin/python3.8
"""Get list of user's scheduled tasks as a table with columns:
id, interval, at (hour:minute/minute past), status (enabled/disabled), command.
Expand Down
2 changes: 1 addition & 1 deletion scripts/pa_install_webapp_letsencrypt_ssl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3.7
#!/usr/bin/python3.8
"""Set the HTTPS certificate and private key for a website, assuming that these have been generated by the dehydrated
script that gets them from Let's Encrypt, and that they're in the standard place. This script should normally only
be run on PythonAnywhere.
Expand Down
2 changes: 1 addition & 1 deletion scripts/pa_install_webapp_ssl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3.7
#!/usr/bin/python3.8
"""Set the HTTPS certificate and private key for a website to the contents of two files, and reload the site.
Usage:
Expand Down
2 changes: 1 addition & 1 deletion scripts/pa_reload_webapp.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3.7
#!/usr/bin/python3.8
"""Reloads the given site
Usage:
Expand Down
6 changes: 3 additions & 3 deletions scripts/pa_start_django_webapp_with_virtualenv.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/python3.7
#!/usr/bin/python3.8
"""Create a new Django webapp with a virtualenv. Defaults to
your free domain, the latest version of Django and Python 3.6
your free domain, the latest version of Django and Python 3.8
Usage:
pa_start_django_webapp_with_virtualenv.py [--domain=<domain> --django=<django-version> --python=<python-version>] [--nuke]
Options:
--domain=<domain> Domain name, eg www.mydomain.com [default: your-username.pythonanywhere.com]
--django=<django-version> Django version, eg "1.8.4" [default: latest]
--python=<python-version> Python version, eg "2.7" [default: 3.7]
--python=<python-version> Python version, eg "2.7" [default: 3.8]
--nuke *Irrevocably* delete any existing web app config on this domain. Irrevocably.
"""

Expand Down
2 changes: 1 addition & 1 deletion scripts/pa_update_scheduled_task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3.7
#!/usr/bin/python3.8
"""Update a scheduled task using id and proper specs.
Note that logfile name will change after updating the task but it won't be
Expand Down
16 changes: 8 additions & 8 deletions tests/test_api_webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ def test_does_post_to_create_webapp(self, api_responses, api_token):
api_responses.add(responses.PATCH, expected_patch_url, status=200)

Webapp("mydomain.com").create(
"3.7", "/virtualenv/path", "/project/path", nuke=False
"3.8", "/virtualenv/path", "/project/path", nuke=False
)

post = api_responses.calls[0]
assert post.request.url == expected_post_url
assert post.request.body == urlencode(
{"domain_name": "mydomain.com", "python_version": PYTHON_VERSIONS["3.7"]}
{"domain_name": "mydomain.com", "python_version": PYTHON_VERSIONS["3.8"]}
)
assert post.request.headers["Authorization"] == f"Token {api_token}"

Expand All @@ -119,7 +119,7 @@ def test_does_patch_to_update_virtualenv_path_and_source_directory(
api_responses.add(responses.PATCH, expected_patch_url, status=200)

Webapp("mydomain.com").create(
"3.7", "/virtualenv/path", "/project/path", nuke=False
"3.8", "/virtualenv/path", "/project/path", nuke=False
)

patch = api_responses.calls[1]
Expand All @@ -139,7 +139,7 @@ def test_raises_if_post_does_not_20x(self, api_responses, api_token):

with pytest.raises(Exception) as e:
Webapp("mydomain.com").create(
"3.7", "/virtualenv/path", "/project/path", nuke=False
"3.8", "/virtualenv/path", "/project/path", nuke=False
)

assert "POST to create webapp via API failed" in str(e.value)
Expand All @@ -166,7 +166,7 @@ def test_raises_if_post_returns_a_200_with_status_error(

with pytest.raises(Exception) as e:
Webapp("mydomain.com").create(
"3.7", "/virtualenv/path", "/project/path", nuke=False
"3.8", "/virtualenv/path", "/project/path", nuke=False
)

assert "POST to create webapp via API failed" in str(e.value)
Expand Down Expand Up @@ -195,7 +195,7 @@ def test_raises_if_patch_does_not_20x(self, api_responses, api_token):

with pytest.raises(Exception) as e:
Webapp("mydomain.com").create(
"3.7", "/virtualenv/path", "/project/path", nuke=False
"3.8", "/virtualenv/path", "/project/path", nuke=False
)

assert (
Expand All @@ -219,7 +219,7 @@ def test_does_delete_first_for_nuke_call(self, api_responses, api_token):
api_responses.add(responses.PATCH, webapp_url, status=200)

Webapp("mydomain.com").create(
"3.7", "/virtualenv/path", "/project/path", nuke=True
"3.8", "/virtualenv/path", "/project/path", nuke=True
)

delete = api_responses.calls[0]
Expand All @@ -242,7 +242,7 @@ def test_ignores_404_from_delete_call_when_nuking(self, api_responses, api_token
api_responses.add(responses.PATCH, webapp_url, status=200)

Webapp("mydomain.com").create(
"3.7", "/virtualenv/path", "/project/path", nuke=True
"3.8", "/virtualenv/path", "/project/path", nuke=True
)


Expand Down
4 changes: 2 additions & 2 deletions tests/test_django_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def test_actually_produces_wsgi_file_that_can_import_project_non_nested(
running_python_version = ".".join(python_version().split(".")[:2])
project = DjangoProject("mydomain.com", running_python_version)
shutil.copytree(str(non_nested_submodule), str(project.project_path))
if running_python_version in ["3.7", "3.8", "3.9", "3.10"]:
if running_python_version in ["3.8", "3.9", "3.10", "3.11"]:
project.create_virtualenv(django_version="latest")
else:
project.create_virtualenv()
Expand All @@ -534,7 +534,7 @@ def test_actually_produces_wsgi_file_that_can_import_nested_project(
running_python_version = ".".join(python_version().split(".")[:2])
project = DjangoProject("mydomain.com", running_python_version)
shutil.copytree(str(more_nested_submodule), str(project.project_path))
if running_python_version in ["3.7", "3.8", "3.9", "3.10"]:
if running_python_version in ["3.8", "3.9", "3.10", "3.11"]:
project.create_virtualenv(django_version="latest")
else:
project.create_virtualenv()
Expand Down
12 changes: 6 additions & 6 deletions tests/test_virtualenvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ def test_path(self, virtualenvs_folder):
assert v.path == Path(virtualenvs_folder) / "domain.com"

def test_create_uses_bash_and_sources_virtualenvwrapper(self, mock_subprocess, virtualenvs_folder):
v = Virtualenv("domain.com", "3.7")
v = Virtualenv("domain.com", "3.8")
v.create(nuke=False)
args, kwargs = mock_subprocess.check_call.call_args
command_list = args[0]
assert command_list[:2] == ["bash", "-c"]
assert command_list[2].startswith("source virtualenvwrapper.sh && mkvirtualenv")

def test_create_calls_mkvirtualenv_with_python_version_and_domain(self, mock_subprocess, virtualenvs_folder):
v = Virtualenv("domain.com", "3.7")
v = Virtualenv("domain.com", "3.8")
v.create(nuke=False)
args, kwargs = mock_subprocess.check_call.call_args
command_list = args[0]
bash_command = command_list[2]
assert "mkvirtualenv --python=python3.7 domain.com" in bash_command
assert "mkvirtualenv --python=python3.8 domain.com" in bash_command

def test_nuke_option_deletes_virtualenv(self, mock_subprocess, virtualenvs_folder):
v = Virtualenv("domain.com", "3.7")
v = Virtualenv("domain.com", "3.8")
v.create(nuke=True)
args, kwargs = mock_subprocess.check_call.call_args
command_list = args[0]
assert command_list[:2] == ["bash", "-c"]
assert command_list[2].startswith("source virtualenvwrapper.sh && rmvirtualenv domain.com")

def test_install_pip_installs_each_package(self, mock_subprocess, virtualenvs_folder):
v = Virtualenv("domain.com", "3.7")
v = Virtualenv("domain.com", "3.8")
v.create(nuke=False)
v.pip_install("package1 package2==1.1.2")
args, kwargs = mock_subprocess.check_call.call_args_list[-1]
Expand All @@ -60,4 +60,4 @@ def test_gets_version(self, fake_home, virtualenvs_folder):
v.create(nuke=False)
v.pip_install("aafigure==0.6")

assert v.get_version("aafigure") == "0.6"
assert v.get_version("aafigure") == "0.6"

0 comments on commit da6c5ed

Please sign in to comment.