rozzac90 / pinnacle

Python Wrapper for Pinnacle Sports API
MIT License
52 stars 26 forks source link

Enable installation of pinnacle in environment without 'requests' #23

Open miikama opened 3 years ago

miikama commented 3 years ago

First of all, thanks for the clean wrapper library :)

Previously, the setup.py imported the version of the package directory with from pinnacle import __version__. The issue with this approach is that when setup.py imports from pinnacle package, it ends up trying to also import requests.

When installing in a clean python installation, requests is not available, thus installing the package is not possible without first installing requests manually.

This method of extracting package version (with the drawbacks) is also listed as one of the possible options in https://packaging.python.org/guides/single-sourcing-package-version/#single-sourcing-the-version.

This commit changes the versioning to follow a recent note on the same page, by adding the version in the setup.cfg file instead.

Only more recent versions of setuptools support this (versions after 46.4 which has been released this spring). With older versions of setuptools, the installation of pinnacle package will fail if requests is not installed, as it has been failing up to this point.

Even older versions of setuptools (tested with setuptools 39.0, which is the default on ubuntu 18.04) are able to correctly set the package version in PKG-INFOduring installation even when it is only specified in the pinnacle.__init__.py file and not in the setup.pyat all.

In short, I see no drawbacks, only benefits :).