Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make aiohttp and requests optional dependencies #177

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

akx
Copy link

@akx akx commented Aug 27, 2024

This PR makes aiohttp and requests, only required for geoip2.webservice, optional dependencies.

They can be installed separately (many projects will likely have requests anyway), or using the extras provided, i.e.

pip install GeoIP2[aiohttp,requests]

to use the version range specified by requirements.

The Tox configuration is adjusted so tests are run both with and without the libraries installed.

This fixes #101 (makes it possible to install without the webservice bits).
This closes #104 (supersedes it to work with the current packaging and testing infrastructure).

@oschwald
Copy link
Member

As discussed in the issue and other PR, this is a breaking change for web service users. I'd prefer either a solution that allows you to opt-out of the dependencies rather than opt-in or one that breaks the package into several packages where you could depend on the parts that you need with geoip2 remaining a meta packages that includes all of the parts.

@akx
Copy link
Author

akx commented Aug 28, 2024

As discussed in the issue and other PR, this is a breaking change for web service users.

Yes, in semver terms this would be a major version bump. (In fact, the reason why I looked into this was that we have a downstream application that has pinned GeoIP to a much older version because the new version would pull in aiohttp and other things we don't want.)

However, practically, chances are that web service users will already have requests or aiohttp installed via other dependencies, or their application's direct dependencies.

I'd prefer either a solution that allows you to opt-out of the dependencies rather than opt-in

Unfortunately that's not possible with Python package extras.

one that breaks the package into several packages where you could depend on the parts that you need with geoip2 remaining a meta packages that includes all of the parts.

In my view, it would be significantly more packaging and infra work for little profit. However, this practically does that already: the core package is geoip2, the "package" that automagically supports sync web services is geoip2[requests], the "package" that automagically supports async web services is geoip2[aiohttp].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Installation of only one component of the package
2 participants