adafruit / Adafruit_CircuitPython_Requests

Requests-like interface for web interfacing
MIT License
51 stars 36 forks source link

Fix importing `adafruit_requests` in CPython #94

Closed kevincon closed 2 years ago

kevincon commented 2 years ago

This PR fixes importing adafruit_requests in CPython by replacing the imports of various classes from adafruit_esp32spi, adafruit_wiznet5k, etc. (which weren't specified as requirements of adafruit_requests and thus caused importing adafruit_requests to fail due to not being available) with protocols that describe the common structure of those types.

To help prevent the use of adafruit_requests in CPython from breaking in the future, this PR also adds a step to the Build CI job which uses tox to build the package and run its tests in a virtual environment.

I also tested the changes to adafruit_requests.py in CircuitPython by copying the file to the lib/ folder of my MagTag device running the COVID tracking project and verifying that the display showed the COVID stats as expected (although note that project's data source has stopped reporting new data since March 7, 2021).

Fixes #93.

FoamyGuy commented 2 years ago

I successfully tested the version from this branch on PyPortal and CPython with the simpletest scripts in the repo.

The changes you've made and reasoning for them make sense to me. Thanks again for working on this.

tekktrik commented 2 years ago

This is great! The only question I have is how often this library gets used on CPython w/ Blinka if the CPython requests module exists? Just trying to understand use cases.

tekktrik commented 2 years ago

Never mind, I caught up on the relevant Issue. Sounds like a cool project!