Repository: django-import-export/django-import-export (language: python)

Issue:
Allow lighter dependency on tablib without all format modules
**Describe the bug**
I use django-import-export and configure some admins with lightweight format (most of the time only CSV).
But I can’t avoid installing many modules that I don’t need, making all environments (tox test environments + server deployments) a little bit slower and bigger to install.

**To Reproduce**
- install django-import-export
- notice dependency on xlwt, xlrd, pyyaml, openpyxl, odfpy (and their dependencies)
- see in the code that this is not flexible: https://github.com/django-import-export/django-import-export/blob/main/setup.py#L27

**Versions (please complete the following information):**
 - Django Import Export: current

**Expected behavior**
It would be nice if we could choose to install django-import-export with or without `extra` specifiers.  For example, `django-import-export` would depend on `tablib` and provide CSV, `django-import-export[ods]` depend on `tablib[ods]`, etc.

**Screenshots**

**Additional context**
I just found #1069, which I hadn’t seen before writing this ticket.  That PR delegates checks format availability with tablib, which is great, but it keps the dependency on all tablib extras, which means projects that depend on django-import-export don’t have a way to not install all extra dependencies.

It could need a major version bump and a big note in the release notes, but changing the definition of extras here would complete that feature and give the missing control to people.

Thanks for considering this!


Discussion / hints:

Fix patch:
diff --git a/docs/changelog.rst b/docs/changelog.rst
index 83d6fecc5..bc164921e 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -9,6 +9,7 @@ Please refer to :doc:`release notes<release_notes>`.
 - removed unused variable ``Result.new_record`` (#1640)
 - Refactor ``resources.py`` to standardise method args (#1641)
 - added specific check for missing ``import_id_fields`` (#1645)
+- Enable optional tablib dependencies (#1647)
 
 4.0.0-alpha.5 (2023-09-22)
 --------------------------
diff --git a/docs/installation.rst b/docs/installation.rst
index 7c56a6ae4..859668bc9 100644
--- a/docs/installation.rst
+++ b/docs/installation.rst
@@ -2,24 +2,26 @@
 Installation and configuration
 ==============================
 
-django-import-export is available on the Python Package Index (PyPI), so it
+import_export is available on the Python Package Index (PyPI), so it
 can be installed with standard Python tools like ``pip`` or ``easy_install``::
 
-    $ pip install django-import-export
+  pip install django-import-export
 
-This will automatically install many formats supported by tablib. If you need
-additional formats like ``cli`` or ``Pandas DataFrame``, you should install the
-appropriate tablib dependencies (e.g. ``pip install tablib[pandas]``). Read
-more on the `tablib format documentation page`_.
+This will automatically install the default formats supported by tablib.
+If you need additional formats you should install the extra dependencies as required
+appropriate tablib dependencies (e.g. ``pip install django-import-export[xlsx]``).
 
-.. _tablib format documentation page: https://tablib.readthedocs.io/en/stable/formats.html
+To install all available formats, use ``pip install django-import-export[all]``.
+
+For all formats, see the
+`tablib documentation <https://tablib.readthedocs.io/en/stable/formats.html>`_.
 
 Alternatively, you can install the git repository directly to obtain the
 development version::
 
-    $ pip install -e git+https://github.com/django-import-export/django-import-export.git#egg=django-import-export
+  pip install -e git+https://github.com/django-import-export/django-import-export.git#egg=django-import-export
 
-Now, you're good to go, unless you want to use django-import-export from the
+Now, you're good to go, unless you want to use import_export from the
 admin as well. In this case, you need to add it to your ``INSTALLED_APPS`` and
 let Django collect its static files.
 
@@ -36,7 +38,7 @@ let Django collect its static files.
     $ python manage.py collectstatic
 
 All prerequisites are set up! See :doc:`getting_started` to learn how to use
-django-import-export in your project.
+import_export in your project.
 
 
 
@@ -199,7 +201,7 @@ The values must be those provided in ``import_export.formats.base_formats`` e.g
 Example app
 ===========
 
-There's an example application that showcases what django-import-export can do.
+There's an example application that showcases what import_export can do.
 It's assumed that you have set up a Python ``venv`` with all required dependencies
 (from ``test.txt`` requirements file) and are able to run Django locally.
 
diff --git a/docs/release_notes.rst b/docs/release_notes.rst
index fa1e63b7b..b4b91e930 100644
--- a/docs/release_notes.rst
+++ b/docs/release_notes.rst
@@ -5,26 +5,42 @@ Release Notes
 v4
 ==
 
-v4 of import-export (released Q4 2023) contains a number of minor changes to the API.
+v4 introduces breaking changes in order to address some long-standing issues.
+In all cases, please test thoroughly before deploying v4 to production.
+
+This guide describes the major changes and how to upgrade.
+
+Installation
+============
+
+We have modified installation methods to allow for optional dependencies.
+This means that you have to explicitly declare dependencies when installing import_export.
+
+If you are not sure, or want to preserve the pre-v4 behaviour, then ensure that 
+import_export is installed as follows (either in your requirements file (or during 
+installation)::
+
+  django-import-export[all]
+
+API changes
+===========
+
+v4 of import_export (released Q4 2023) contains a number of minor changes to the API.
 
 If you have customized import-export by overriding methods, then you will have to
 modify your installation before working with v4.  If you have not overridden any
 methods then you should not be affected by these changes and no changes to your code
 should be necessary.
 
+The API changes include changes to method arguments, although some method names have
+changed.
+
 Test thoroughly before deploying v4 to production.
 
 Refer to
 `this PR <https://github.com/django-import-export/django-import-export/pull/1641/>`_
 for more information.
 
-This guide describes the major changes and how to upgrade.
-
-API changes
-===========
-
-The API changes mostly change method arguments, although some method names have changed.
-
 Methods which process row data have been updated so that method args are standardized.
 This has been done to resolve inconsistency issues where the parameters differed between
 method calls, and to allow easier extensibility.
diff --git a/pyproject.toml b/pyproject.toml
index a150d132d..54a7f4a91 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -37,9 +37,20 @@ classifiers = [
 dependencies = [
     "diff-match-patch",
     "Django>=3.2",
-    "tablib[html,ods,xls,xlsx,yaml]@git+https://github.com/jazzband/tablib.git@master#egg=tablib"
+    "tablib@git+https://github.com/jazzband/tablib.git@master#egg=tablib"
 ]
 
+[project.optional-dependencies]
+all = [
+    "tablib[all]@git+https://github.com/jazzband/tablib.git@master#egg=tablib"
+]
+cli = ["tablib[cli]"]
+ods = ["tablib[ods]"]
+pandas = ["tablib[pandas]"]
+xls = ["tablib[xls]@git+https://github.com/jazzband/tablib.git@master#egg=tablib"]
+xlsx = ["tablib[xlsx]@git+https://github.com/jazzband/tablib.git@master#egg=tablib"]
+yaml = ["tablib[yaml]@git+https://github.com/jazzband/tablib.git@master#egg=tablib"]
+
 [project.urls]
 Documentation = "https://django-import-export.readthedocs.io/en/stable/"
 Repository = "https://github.com/django-import-export/django-import-export"
diff --git a/requirements/base.txt b/requirements/base.txt
index 335c34afa..01a088cca 100644
--- a/requirements/base.txt
+++ b/requirements/base.txt
@@ -1,4 +1,4 @@
 Django>=3.2
 # # tablib temporarily using master before v4
-tablib[html,ods,xls,xlsx,yaml]@git+https://github.com/jazzband/tablib.git@master#egg=tablib
+tablib@git+https://github.com/jazzband/tablib.git@master#egg=tablib
 diff-match-patch
diff --git a/requirements/docs.txt b/requirements/docs.txt
index b3b56217f..14a4af863 100644
--- a/requirements/docs.txt
+++ b/requirements/docs.txt
@@ -1,3 +1,3 @@
 -r base.txt
-sphinx
-sphinx-rtd-theme
+sphinx==7.2.6
+sphinx-rtd-theme==1.3.0


Test patch:
diff --git a/requirements/test.txt b/requirements/test.txt
index 03b2a6ddf..b75ff142a 100644
--- a/requirements/test.txt
+++ b/requirements/test.txt
@@ -1,7 +1,9 @@
-psycopg2-binary
-mysqlclient
-chardet
-pytz
-memory-profiler
-django-extensions
-coverage
+psycopg2-binary==2.9.8
+mysqlclient==2.2.0
+chardet==5.2.0
+pytz==2023.3
+memory-profiler==0.61.0
+django-extensions==3.2.3
+coverage==7.3.1
+# tablib temporarily using master before v4
+tablib[all]@git+https://github.com/jazzband/tablib.git@master#egg=tablib