From 2be7767b594936a5330b8d7fd1b0462ebfe425f7 Mon Sep 17 00:00:00 2001 From: Birkin James Diana Date: Sat, 23 Nov 2024 10:22:42 -0500 Subject: [PATCH 1/5] removes unneeded package. --- config/requirements/requirements_base.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/requirements/requirements_base.in b/config/requirements/requirements_base.in index 6cd4293..59ff0ff 100644 --- a/config/requirements/requirements_base.in +++ b/config/requirements/requirements_base.in @@ -1,6 +1,5 @@ Django~=4.2.0 -pip-tools~=7.4.0 python-dotenv~=1.0.0 -requests~=2.27.0 # for down-stream compatibility +requests~=2.32.3 trio~=0.26.0 urllib3~=1.26.0 # for down-stream compatibility From e938acb91ba021de3887d5555d5f0693d48f068e Mon Sep 17 00:00:00 2001 From: Birkin James Diana Date: Sat, 23 Nov 2024 10:22:53 -0500 Subject: [PATCH 2/5] adds base.txt. --- README.md | 6 +++ config/requirements/requirements_base.txt | 48 +++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 config/requirements/requirements_base.txt diff --git a/README.md b/README.md index 3e2972c..90dba0b 100644 --- a/README.md +++ b/README.md @@ -86,3 +86,9 @@ Next -- well, the sky's the limit! - This webapp doesn't access the db much, but if it did, and you wanted to inspect the sql generated by the ORM, uncomment out the `django.db.backends` logger in `settings.py`. --- + + +# regular `uv` install + +- The `local-install` instructions above are just to get you up-and-running super quickly and easily. Here are some more typical _local_ uv-install instructions (assumes you've already followed the `local-install` instructions): + - \ No newline at end of file diff --git a/config/requirements/requirements_base.txt b/config/requirements/requirements_base.txt new file mode 100644 index 0000000..8c111cf --- /dev/null +++ b/config/requirements/requirements_base.txt @@ -0,0 +1,48 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile ./config/requirements/requirements_base.in --output-file ./config/requirements/requirements_base.txt --universal --python 3.8 +asgiref==3.8.1 + # via django +attrs==24.2.0 + # via + # outcome + # trio +backports-zoneinfo==0.2.1 ; python_full_version < '3.9' + # via django +certifi==2024.8.30 + # via requests +cffi==1.17.1 ; implementation_name != 'pypy' and os_name == 'nt' + # via trio +charset-normalizer==3.4.0 + # via requests +django==4.2.16 + # via -r ./config/requirements/requirements_base.in +exceptiongroup==1.2.2 ; python_full_version < '3.11' + # via trio +idna==3.10 + # via + # requests + # trio +outcome==1.3.0.post0 + # via trio +pycparser==2.22 ; implementation_name != 'pypy' and os_name == 'nt' + # via cffi +python-dotenv==1.0.1 + # via -r ./config/requirements/requirements_base.in +requests==2.32.3 + # via -r ./config/requirements/requirements_base.in +sniffio==1.3.1 + # via trio +sortedcontainers==2.4.0 + # via trio +sqlparse==0.5.2 + # via django +trio==0.26.2 + # via -r ./config/requirements/requirements_base.in +typing-extensions==4.12.2 ; python_full_version < '3.11' + # via asgiref +tzdata==2024.2 ; sys_platform == 'win32' + # via django +urllib3==1.26.20 + # via + # -r ./config/requirements/requirements_base.in + # requests From 24c7ed7ac4fd1f9f74bb7be748ae6186c72b6c68 Mon Sep 17 00:00:00 2001 From: Birkin James Diana Date: Sat, 23 Nov 2024 10:57:34 -0500 Subject: [PATCH 3/5] adds venv instructions. --- README.md | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 90dba0b..2d0e439 100644 --- a/README.md +++ b/README.md @@ -2,19 +2,28 @@ This is a template for new django projects -- to standardize on some nice features/practices, and to get up and running, locally, easily and quickly. It provides instructions for getting the code from GitHub, installing it, setting up a virtual environment, and lists a few things to try after getting the webapp running. Finally, it lists the nice features/practices. +on this page... +- [local quick-start](#local-quick-start) +- [stuff to try](#stuff-to-try) +- [nice features/practices](#nice-featurespractices) +- [regular setup](#regular-setup) + --- -# local-install +# local quick-start -Notes about the install instructions... +Notes about the quick-start instructions... -- The install-instructions below assume: +- The instructions below assume: - a unix-like environment (ie Mac, Linux, or Windows Subsystem for Linux (WSL)). - you've installed `uv` ([link][uv_link]) - For now, here's a link to an [older version][old] of the repo that uses `pip`-based setup instructions. When improvements are made to this repo, this link will be removed. -- The install-instructions below reference `x_project_stuff`, `x_project`, and `x_app`. In all cases replace with the name of your project, like: `isbn_api_project_stuff`, `isbn_api_project`, and `isbn_api_app`. + +- The instructions below reference `x_project_stuff`, `x_project`, and `x_app`. In all cases replace with the name of your project, like: `isbn_api_project_stuff`, `isbn_api_project`, and `isbn_api_app`. + - The `update_project_and_app_references.py` script ([link](https://github.com/Brown-University-Library/django_template_42_project/blob/main/update_project_and_app_references.py)) deletes the cloned `.git` directory (in addition to its main purpose to rename the project). Why? So you don't accidentally start building away and commit to the template repo. After this installation, creating a new git repo is one of the first things you should do. + - When you start the webapp via `runserver`, you'll get a message that there are migrations that need to be run, with instructions. You can go ahead and do that, or do it later. ```bash @@ -45,6 +54,7 @@ That's it! --- + # stuff to try - Open a browser to . That'll redirect to . @@ -58,7 +68,7 @@ That's it! You won't initially see anything, but if you reload the error-check url, and then check this terminal window again, you'll see the email-data that would have been sent. -- Try . Once you `git init`, `git add --all`, and `git commit -am "initial commit"`, it'll show the branch and commit -- super-handy for dev and prod confirmations. +- Try . Once you `git init`, `git add --all`, and `git commit -am "initial commit"`, it'll show the branch and commit -- _very_ handy for dev and prod confirmations. - Try `$ uv run ./manage.py test`. There are two simple tests that should pass. @@ -88,7 +98,26 @@ Next -- well, the sky's the limit! --- -# regular `uv` install +# regular setup + +The `local quick-start` instructions above are to get you up-and-running super quickly and easily. Below are instructions for a more typical local virtual-environment architecture (they assume you've already followed the `local quick-start` instructions). + +Make the venv... + +```bash +$ cd ./x_project_stuff/ +$ uv venv ./your_venv --python 3.8.10 +$ cd ./x_project +$ source ../your_venv/bin/activate +(your_venv) $ uv pip sync ./config/requirements/requirements_base.txt +``` + +That's a one-time setup. For regular use... -- The `local-install` instructions above are just to get you up-and-running super quickly and easily. Here are some more typical _local_ uv-install instructions (assumes you've already followed the `local-install` instructions): - - \ No newline at end of file +```bash +$ cd ./x_project_stuff/x_project +$ source ../your_venv/bin/activate +(your_venv) $ python ./manage.py runserver +``` + +--- From 020cf50c14c02599e478d6c0d28ae1bb404014b0 Mon Sep 17 00:00:00 2001 From: Birkin James Diana Date: Sat, 23 Nov 2024 11:17:51 -0500 Subject: [PATCH 4/5] tweaks readme. --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2d0e439..14edf1d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # purpose -This is a template for new django projects -- to standardize on some nice features/practices, and to get up and running, locally, easily and quickly. It provides instructions for getting the code from GitHub, installing it, setting up a virtual environment, and lists a few things to try after getting the webapp running. Finally, it lists the nice features/practices. +This is a template for new django projects -- to standardize on some nice features/practices, and to get up and running, locally, easily and quickly. It provides instructions for getting the template from GitHub, customizing it, starting the webapp, and lists a few things to try with the webapp running. Finally, it lists the nice features/practices, and also shows typical usage. on this page... - [local quick-start](#local-quick-start) @@ -18,7 +18,7 @@ Notes about the quick-start instructions... - The instructions below assume: - a unix-like environment (ie Mac, Linux, or Windows Subsystem for Linux (WSL)). - you've installed `uv` ([link][uv_link]) - - For now, here's a link to an [older version][old] of the repo that uses `pip`-based setup instructions. When improvements are made to this repo, this link will be removed. + - _For now, here's a link to an [older version][old] of the repo that uses `pip`-based setup instructions. When improvements are made to this repo, this link will be removed._ - The instructions below reference `x_project_stuff`, `x_project`, and `x_app`. In all cases replace with the name of your project, like: `isbn_api_project_stuff`, `isbn_api_project`, and `isbn_api_app`. @@ -89,11 +89,12 @@ Next -- well, the sky's the limit! - Includes a couple of client-get tests that respond differentially to dev and prod settings. - Includes a dev-only error-check url (enables confirmation that email-admins-on-error is set up correctly). - Uses python-dotenv. -- Uses tilde-comparators in the `.in` requirements files for stable upgrades. -- Uses layered `base.in` and `server.in` requirements files which will produce `.txt` files -- for clarity re what's really in the venv. - Specifies compatible package versions for reliable staging and prod deployment. + - Uses tilde-comparators in the `.in` requirements files for stable upgrades. + - Uses layered `base.in` and `server.in` requirements files which will produce `.txt` files -- for clarity re what's really in the venv. - Shows one possible pattern to make async calls (`app/lib/version_helper.manage_git_calls()`) and gather together the results. - This webapp doesn't access the db much, but if it did, and you wanted to inspect the sql generated by the ORM, uncomment out the `django.db.backends` logger in `settings.py`. +- Includes a default config-file for `ruff`, a fast, extensible python linter that can integrate with many popular code editors such as VS Code, PyCharm, and others. --- From 3b69b87a99671445e205d66ac47a29cfb5d96645 Mon Sep 17 00:00:00 2001 From: Birkin James Diana Date: Sat, 23 Nov 2024 11:20:25 -0500 Subject: [PATCH 5/5] updates ruff.toml --- ruff.toml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ruff.toml b/ruff.toml index 0d9e27a..c479d9d 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,5 +1,5 @@ ## settings ## -line-length = 100 +line-length = 125 indent-width = 4 target-version = "py38" @@ -16,4 +16,7 @@ avoid-escape = true case-sensitive = true [lint.pycodestyle] -max-line-length = 100 +max-line-length = 125 + +[lint.pydocstyle] +convention = "google"