| 1 |
Contributing to django-allauth |
| 2 |
============================== |
| 3 |
|
| 4 |
.. begin-contributing |
| 5 |
|
| 6 |
Thank you for considering contributing to django-allauth! This document outlines the process for contributing to the project and sets up your development environment. |
| 7 |
|
| 8 |
Code of Conduct |
| 9 |
--------------- |
| 10 |
|
| 11 |
In the interest of fostering an open and welcoming community, we as contributors and maintainers pledge to make participation in our project a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. |
| 12 |
|
| 13 |
Getting Started |
| 14 |
--------------- |
| 15 |
|
| 16 |
Setting Up Your Development Environment |
| 17 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 18 |
|
| 19 |
There are two primary ways to set up your development environment: |
| 20 |
|
| 21 |
Option 1: Standard Python Virtual Environment (Recommended for Beginners) |
| 22 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 23 |
|
| 24 |
1. **Install system dependencies** |
| 25 |
|
| 26 |
Before creating a virtual environment, you'll need to install some system dependencies: |
| 27 |
|
| 28 |
**On macOS:** |
| 29 |
|
| 30 |
.. code-block:: bash |
| 31 |
|
| 32 |
# Using Homebrew |
| 33 |
brew install libxml2 libxmlsec1 pkg-config openssl |
| 34 |
|
| 35 |
**On Ubuntu/Debian:** |
| 36 |
|
| 37 |
.. code-block:: bash |
| 38 |
|
| 39 |
sudo apt-get install libxml2-dev libxmlsec1-dev libxmlsec1-openssl pkg-config |
| 40 |
|
| 41 |
**On RHEL/CentOS/Fedora:** |
| 42 |
|
| 43 |
.. code-block:: bash |
| 44 |
|
| 45 |
sudo dnf install libxml2-devel xmlsec1-devel xmlsec1-openssl-devel libtool-ltdl-devel |
| 46 |
|
| 47 |
2. **Create and activate a virtual environment** |
| 48 |
|
| 49 |
.. code-block:: bash |
| 50 |
|
| 51 |
# Create a virtual environment |
| 52 |
python -m venv virtualenv |
| 53 |
|
| 54 |
# Activate it |
| 55 |
# On Windows: |
| 56 |
virtualenv\Scripts\activate |
| 57 |
# On macOS/Linux: |
| 58 |
source virtualenv/bin/activate |
| 59 |
|
| 60 |
3. **Install django-allauth in development mode** |
| 61 |
|
| 62 |
.. code-block:: bash |
| 63 |
|
| 64 |
# Install development dependencies |
| 65 |
pip install -r requirements-dev.txt |
| 66 |
|
| 67 |
Option 2: Using devenv/Nix (Recommended for Advanced Users) |
| 68 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 69 |
|
| 70 |
If you prefer a more isolated and reproducible development environment, you can use Nix-based `devenv <https://devenv.sh>`_: |
| 71 |
|
| 72 |
1. **Install devenv** (If you don't have it already) |
| 73 |
|
| 74 |
Follow the `official installation instructions <https://devenv.sh/getting-started/>`_. |
| 75 |
|
| 76 |
2. **Activate the developer environment** |
| 77 |
|
| 78 |
.. code-block:: bash |
| 79 |
|
| 80 |
# This will create an isolated environment with all required dependencies |
| 81 |
devenv shell |
| 82 |
|
| 83 |
Note: The first time you run this command, it may take a significant amount of time as it builds all dependencies. Subsequent launches will be much faster. |
| 84 |
|
| 85 |
|
| 86 |
Running Tests |
| 87 |
------------- |
| 88 |
|
| 89 |
django-allauth uses a comprehensive test suite. You can run tests in several ways: |
| 90 |
|
| 91 |
Using pytest directly |
| 92 |
~~~~~~~~~~~~~~~~~~~~~ |
| 93 |
|
| 94 |
.. code-block:: bash |
| 95 |
|
| 96 |
# Run all tests for the default setup |
| 97 |
pytest allauth/ |
| 98 |
|
| 99 |
# Run tests with a specific Django settings module |
| 100 |
pytest --ds=tests.projects.regular.settings tests/ |
| 101 |
|
| 102 |
# Run a specific test file |
| 103 |
pytest tests/apps/account/test_login.py |
| 104 |
|
| 105 |
Note, if you are using MacOS, using pip and get this error when run tests: |
| 106 |
|
| 107 |
.. code-block:: bash |
| 108 |
|
| 109 |
import xmlsec |
| 110 |
ImportError: dlopen( ... symbol not found in flat namespace '_xmlSecOpenSSLTransformHmacRipemd160GetKlass') |
| 111 |
|
| 112 |
You can try: |
| 113 |
|
| 114 |
.. code-block:: bash |
| 115 |
|
| 116 |
pip uninstall xmlsec lxml |
| 117 |
pip install --no-binary :all: xmlsec |
| 118 |
# Ref: https://github.com/xmlsec/python-xmlsec/issues/320 |
| 119 |
|
| 120 |
Using nox (recommended) |
| 121 |
~~~~~~~~~~~~~~~~~~~~~~~ |
| 122 |
|
| 123 |
Nox automates testing across different Python and Django versions: |
| 124 |
|
| 125 |
.. code-block:: bash |
| 126 |
|
| 127 |
# List all available sessions |
| 128 |
nox --list |
| 129 |
|
| 130 |
# Run tests for a specific Python version |
| 131 |
nox -x --session "test-3.11" |
| 132 |
|
| 133 |
# Run tests for specific environment |
| 134 |
nox -x --session "test-3.11" --python 3.11 -- --ds=tests.projects.regular.settings tests/apps/account/test_login.py |
| 135 |
|
| 136 |
Run Code Quality Checks |
| 137 |
~~~~~~~~~~~~~~~~~~~~~~~ |
| 138 |
|
| 139 |
.. code-block:: bash |
| 140 |
|
| 141 |
# Run all linting checks |
| 142 |
nox -t lint |
| 143 |
|
| 144 |
# Run specific check |
| 145 |
nox --session black |
| 146 |
nox --session isort |
| 147 |
nox --session flake8 |
| 148 |
nox --session bandit |
| 149 |
nox --session djlint |
| 150 |
|
| 151 |
Building Documentation |
| 152 |
---------------------- |
| 153 |
|
| 154 |
Documentation is built using Sphinx: |
| 155 |
|
| 156 |
.. code-block:: bash |
| 157 |
|
| 158 |
# Build the documentation |
| 159 |
nox --session docs |
| 160 |
|
| 161 |
The built documentation will be available in the ``docs/_build/html`` directory. |
| 162 |
|
| 163 |
Development Workflow |
| 164 |
-------------------- |
| 165 |
|
| 166 |
1. **Create a new branch for your feature or bugfix** |
| 167 |
|
| 168 |
.. code-block:: bash |
| 169 |
|
| 170 |
git checkout -b feature/your-feature-name |
| 171 |
|
| 172 |
2. **Make your changes and add tests** |
| 173 |
|
| 174 |
All new features should include proper tests. |
| 175 |
|
| 176 |
3. **Run tests locally to ensure everything passes** |
| 177 |
|
| 178 |
.. code-block:: bash |
| 179 |
|
| 180 |
nox -x --session "test-3.11" |
| 181 |
|
| 182 |
4. **Run code quality checks** |
| 183 |
|
| 184 |
.. code-block:: bash |
| 185 |
|
| 186 |
nox -t lint |
| 187 |
|
| 188 |
5. **Commit your changes with meaningful commit messages** |
| 189 |
|
| 190 |
6. **Submit a pull request to the main repository** |
| 191 |
|
| 192 |
Pull Request Guidelines |
| 193 |
----------------------- |
| 194 |
|
| 195 |
- Update documentation for significant changes |
| 196 |
- Add tests for new functionality |
| 197 |
- Ensure all tests pass |
| 198 |
- Follow the project's code style |
| 199 |
- Keep pull requests focused on a single topic |
| 200 |
- Write clear, descriptive commit messages |
| 201 |
|
| 202 |
Additional Resources |
| 203 |
-------------------- |
| 204 |
|
| 205 |
- `Official Documentation <https://docs.allauth.org/en/latest/>`_ |
| 206 |
- `Issue Tracker <https://codeberg.org/allauth/django-allauth/issues>`_ |
| 207 |
- `Project Source <https://codeberg.org/allauth/django-allauth>`_ |
| 208 |
|
| 209 |
Thank you for your contributions! |
| 210 |
|
| 211 |
.. end-contributing |