granian icon indicating copy to clipboard operation
granian copied to clipboard

Make the watchfiles dependency optional

Open bluetech opened this issue 1 year ago • 1 comments
trafficstars

Granian depends on the watchfiles Python package for the --reload (reload on file changes) feature. This feature is helpful for local development, but is not needed on production (at least that I know of!).

The watchfiles package brings in the following extra packages to the granian dependency closure:

  • watchfiles
    • anyio
      • idna
      • sniffio

To reduce the dependencies in production, I propose making watchfiles optional:

  • Move the watchfiles import to be done lazily in _serve_with_reloader.
  • Remove the watchfiles from the default dependencies and move it to a granian[watch] extra instead.
  • Update the docs to mention that the [watch] extra is needed for --reload to work.

I can implement this if it sounds good.

bluetech avatar Feb 05 '24 09:02 bluetech

Sounds reasonable to me, I'll be happy to accept a PR for this. The only thing I would change in your plan is to name the extra reload instead of watch just to be more consistent.

gi0baro avatar Feb 05 '24 15:02 gi0baro