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

Check if requests is installed? #123

Closed
Anselmoo opened this issue Nov 20, 2022 · 3 comments · Fixed by #128
Closed

Check if requests is installed? #123

Anselmoo opened this issue Nov 20, 2022 · 3 comments · Fixed by #128

Comments

@Anselmoo
Copy link
Contributor

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

import requests

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
Copy link
Owner

mwouts commented Nov 21, 2022

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
Copy link
Contributor Author

Anselmoo commented Nov 21, 2022

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
Copy link
Contributor Author

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

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