diff --git a/CHANGELOG.md b/CHANGELOG.md index fd27149..693afb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# UNRELEASED + +- Make `geoip2` an optional dependency. It can be installed using the `geoip2` extra. + # 2.0.0 (Feb 23, 2025) - Add support for Python 3.13 and drop support for Python 3.8. diff --git a/README.md b/README.md index aa0291a..8d6b0fa 100644 --- a/README.md +++ b/README.md @@ -115,22 +115,25 @@ migration script. python manage.py migrate qsessions ``` -To enable location detection using GeoIP2 (optional): +### Use GeoIP2 (optional) -5. Install `geoip2` package: +To enable location detection using GeoIP2, you'll need to follow a few extra steps: + +1. Install `django-qsessions` with the `geoip2` extra: ```sh - pip install geoip2 + pip install "django-qsessions[geoip2]" ``` -6. Set `GEOIP_PATH` to a directory for storing GeoIP2 database. +2. Set `GEOIP_PATH` to a directory in Django settings for storing GeoIP2 + database. -7. Run the following command to download latest GeoIP2 database. You - can add this command to a cron job to update GeoIP2 DB +3. Run the following command to download the latest GeoIP2 database. You + can add this command to a cron job to update the GeoIP2 DB automatically. Due to [Maxmind license - changes](https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-geolite2-databases/) + changes](https://blog.maxmind.com/2019/12/18/significant-changes-to-accessing-and-using-geolite2-databases/), you will need to acquire and use a license key for downloading the - databases. You can pass the key on the command line, or in the + databases. You can pass the key on the command line or in the `MAXMIND_LICENSE_KEY` environment variable. ```sh diff --git a/setup.py b/setup.py index e75a0b6..3d48fb5 100644 --- a/setup.py +++ b/setup.py @@ -10,12 +10,13 @@ dev_requirements = [ "pre-commit", - "geoip2", # for testing GeoIP2 "pytest>=7", "pytest-cov", "pytest-django", ] +geoip_requirements = ["geoip2>=4.1.0"] + setup( name="django-qsessions", version="2.0.0", @@ -29,7 +30,10 @@ packages=find_packages(".", include=("qsessions", "qsessions.*")), include_package_data=True, install_requires=["Django >= 4.2", "ua-parser[regex] >= 1.0.1"], - extras_require={"dev": dev_requirements}, + extras_require={ + "dev": dev_requirements + geoip_requirements, + "geoip2": geoip_requirements, + }, tests_require=dev_requirements, classifiers=[ "Development Status :: 5 - Production/Stable", diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29