Opened 14 months ago

Last modified 6 weeks ago

#28905 assigned Cleanup/optimization

Overhaul extra_requires to include more optional dependencies

Reported by: Jaap Roes Owned by: Nick Pope
Component: Packaging Version: master
Severity: Normal Keywords: setup optional dependencies packages requirements
Cc: Herbert Fortes Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Django has a number of optional features that require the installation of additional Python packages.

Right now it's possible to pip install Django[bcrypt,argon2] to install Django and the optional packages (at the correct minimum version) required for bcrypt/argon2 support.

However this is not possible for other optional features, like database/cache backend, gis, certain image related features etc.

I've created a pull request adding the optional dependencies found in the test requirements (initially only psycopg2 for postgresql, but after a comment from pope1ni I followed their suggestion to include more). It changes the set of extra_requires to:

{
    'admindocs': ['docutils'],
    'argon2': ['argon2_cffi>=16.1.0'],
    'bcrypt': ['bcrypt'],
    'gis': [
        'geoip2',
        'numpy'
    ],
    'geoip': ['geoip2'],
    'jinja2': ['Jinja2>=2.9.2'],
    'memcached': ['python3-memcached'],
    'numpy': ['numpy'],
    'mysql': ['mysqlclient>=1.3.7'],
    'oracle': ['Oracle'],
    'images': ['Pillow'],
    'postgresql': ['psycopg2>=2.5.4'],
    'pylibmc': ['pylibmc; sys.platform != "win32"'],
    'sqlparse': ['sqlparse'],
    'selenium': ['selenium'],
    'test-parallel': ['tblib'],
    'yaml': ['PyYAML'],
}

So end users can do things like:

$ pip install Django[mysql,sqlparse,images,memcached]
$ pip install Django[postgresql,gis]
$ pip install Django[selenium,test-parallel]

Not only would this make it much easier to install a particular combination of Django and optional dependencies correctly, it also makes some of the optional features/dependencies a little bit more discoverable.

This might not the full set of optional dependencies, or the right grouping/naming, so a review is more than welcome.

Besides adding this to setup.py, additional changes to the documentation, test instructions and scripts, code warnings etc. will probably be necessary.

Change History (16)

comment:1 Changed 14 months ago by Jaap Roes

Component: UncategorizedPackaging

comment:2 Changed 14 months ago by Sergey Fedoseev

Has patch: set
Triage Stage: UnreviewedAccepted

comment:3 Changed 14 months ago by Jaap Roes

I have no idea where to go from here. I assume posting this to the developer mailinglist is the best way to gather feedback on this and come to a consensus of which packages and groupings.

edit: https://groups.google.com/forum/#!topic/django-developers/6IQ5VeY6jY8

Last edited 13 months ago by Jaap Roes (previous) (diff)

comment:4 Changed 11 months ago by Carlton Gibson

Related #27682

comment:5 Changed 11 months ago by Carlton Gibson

Needs documentation: set

comment:6 Changed 8 months ago by Jaap Roes

Easy pickings: set

I don't have the time/energy to get this done, but I feel that this would be an excellent, and fairly easy, ticket for someone to work on during the Djangocon sprints

comment:7 Changed 8 months ago by oliver

Owner: changed from nobody to oliver
Status: newassigned

comment:8 Changed 8 months ago by oliver

Owner: oliver deleted
Status: assignednew

comment:9 Changed 8 months ago by Israel Fermín Montilla

Can I claim it?, I have some spare time I could invest on this

comment:10 Changed 8 months ago by Herbert Fortes

Cc: Herbert Fortes added

comment:11 Changed 8 months ago by Jaap Roes

Yes please claim it, it would be really helpful to, for example, identify pieces of documentation that should be updated when this lands.

comment:12 Changed 7 months ago by Niranj Rajasekaran

Owner: set to Niranj Rajasekaran
Status: newassigned

comment:13 Changed 2 months ago by Jaap Roes

I just discovered another optional dependency, on Linux one can install pyinotify for better reloading behaviour (https://docs.djangoproject.com/en/dev/ref/django-admin/#runserver).

So maybe adding {'dev': ['pyinotify ; sys_platform == "linux"']} would be helpful as well.

comment:14 Changed 2 months ago by Nick Pope

Needs documentation: unset
Owner: changed from Niranj Rajasekaran to Nick Pope

New PR.

comment:15 Changed 8 weeks ago by Jaap Roes

Thanks Nick for taking this ticket and trying to move it forwards.

The additional documentation about optional dependencies makes so much sense, it alone would satisfy some of the discoverability issues with optional dependencies. It would be nice if the overview of optional dependencies could link to the relevant sections in the docs. E.g. caching, databases, GIS, password hashers, template engines, serializers etc.

The grouping/inclusion of dependencies seems to be the main stumbling block. Adding extra_requires groups adds a maintenance burden on these groups, as in, they'll need to work for future versions of Django. For this reason I think it's probably not the right choice to name groups directly after the package they are installing (pylibmc, pyinotify, selenium etc.).

Maybe it would be easier to just start out with just adding the database extra's? Those seem non-controversial and the package names and version specs are non-obvious, so having those in Django's setup.py has a clear advantage.

It might also be interesting to figure out how to "deprecate" extra requirement groups, so at some point it would be possible to phase out the bcrypt or argon2 extra requirements.

I was also thinking, extra requirements would also be a nice place to include other "official" Django projects. E.g. pip install django[mysql,localflavor,comments] or pip install django[postgresql,channels].

Anyway, I don't think this ticket will go anywhere until someone with a more authoritative voice makes a decision what's wanted and unwanted.

comment:16 in reply to:  15 Changed 6 weeks ago by Nick Pope

Thanks for the feedback, please see responses below.

... It would be nice if the overview of optional dependencies could link to the relevant sections in the docs. E.g. caching, databases, GIS, password hashers, template engines, serializers etc.

Agreed. Will add in links to useful sections in the documentation.

... For this reason I think it's probably not the right choice to name groups directly after the package they are installing (pylibmc, pyinotify, selenium etc.).

Maybe it would be easier to just start out with just adding the database extra's? ...

I still feel that adding support for some of the packages other than database backends would be very useful. There should at the very least be an easy option to install all non-database backend packages, particularly useful for removing tests/requirements/*.txt.

It might also be interesting to figure out how to "deprecate" extra requirement groups, so at some point it would be possible to phase out the bcrypt or argon2 extra requirements.

I'm not sure it is possible to "deprecate" - in fact it doesn't really make sense - a package must be available during a deprecation period. However, when the package is removed, the group must either remain empty in extra_requires or be removed entirely if documented in the release notes.

I was also thinking, extra requirements would also be a nice place to include other "official" Django projects. E.g. pip install django[mysql,localflavor,comments] or pip install django[postgresql,channels].

I think it best to leave these out of the extra_requires option, but perhaps document them on the optional dependencies page along with a link to other django-related projects.

Note: See TracTickets for help on using tickets.
Back to Top