Getting Django Running Locally with the Help of uv

Tonight I wanted to get a local copy of Django set up and running, with the aim of taking some baby steps towards contributing to Django. I was expecting this to be much harder, but after following the steps outlined in the Django docs, but substituting in some uv commands, I was up and running and fully tested within about 5 minutes.

Here are the steps I followed, on my Mac...

  1. Forked the Django project in GitHub to https://github.com/stuartmaxwell/django.
  2. Created a directory on my Mac to store the project: mkdir ~/Documents/Django/Django_Project && cd ~/Documents/Django/Django_Project
  3. Cloned the forked Django repo: git clone [email protected]:stuartmaxwell/django.git
  4. Changed directory into the cloned repo cd django and had a look at some files: ls -al & cat pyproject.toml & cat .gitignore
  5. Ran uv sync to install Django and the dependencies. To be honest, I wasn't sure if this would work, but it did!
  6. Next I wanted to install the test dependencies: uv pip install -r tests/requirements/py3.txt - and here's where I ran into my first error, I needed to: install a library that provides libmemcached/memcached.h" for [email protected] (that was part of the error message provided).
  7. A quick Google search led me to install libmemcached, and I picked the easy option of just using homebrew: brew install libmemcached
  8. Of course, homebrew is never the easy option! I tried to install the test dependencies again, and got the same error again. I now know from previous experience that homebrew doesn't put things in well-known places, and another quick Google search led me to this environment variable which looked like it would help: export LIBMEMCACHED=/opt/homebrew
  9. Ran uv pip install -r tests/requirements/py3.txt again, and this time it installed everything as quickly as you'd expect from uv.
  10. Now time to run the tests... And again using uv so that I don't need to manually activate virtual environments: uv run tests/runtests.py - and 56.551 seconds later, all 17,475 tests had finished running with 1,271 skipped tests, and 5 expected failures.

Much easier than I expected, and another great experience with uv (and not so great experience with homebrew!)