mwouts / itables

Pandas DataFrames as Interactive DataTables
https://mwouts.github.io/itables/
MIT License
730 stars 54 forks source link

Check if `requests` is installed? #123

Closed Anselmoo closed 1 year ago

Anselmoo commented 1 year ago

If requests is not pre-installed, the native installation (pip install .) can cause some trouble.

https://github.com/mwouts/itables/blob/d12e364690afb788947890080fa380af92eb3c4d/setup.py#L6

It might be a good idea to catch that via try-except?

Solution 1:

try:
    import requests
except ImportError:
    print("Please install requests")
    exit(1)

Solution 2:

try:
    import requests
except ImportError:
    import subprocess
    subprocess.check_call(['python', '-m', 'pip', 'install', 'requests'])
    import requests
mwouts commented 1 year ago

Hey @Anselmoo , maybe we could use a build requirement like documented here: https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#build-system-requirement ? As requests is only used when the package is built... What do you think?

Anselmoo commented 1 year ago

That's an excellent idea!

However, pyproject.toml should also be considered used as a replacement for setup.py in the long term.

See also: https://github.com/pandas-dev/pandas/blob/main/pyproject.toml

Anselmoo commented 1 year ago

@mwouts looks like it works, however I have to also fix the flake8 issue #124