pypa / hatch

Modern, extensible Python project management
https://hatch.pypa.io/latest/
MIT License
5.69k stars 277 forks source link

Offline usage of Hatch with custom pypi repo #1596

Open wj3171868 opened 1 week ago

wj3171868 commented 1 week ago

I dev in an environment without direct internet access.

I'm looking for documentation on how to get some of the features for Hatch working in an offline environment. For example the "hatch fmt" command tries to download ruff from pypi.org even though I've tried to set my local pypi mirror.

hatch python install also has a dependency on a network connection. I believe mirroring the required assets should work well enough but I'm looking for a config option to set a custom location to install python from.

Are there any other Hatch features that have network dependencies that need to be overwritten?

wj3171868 commented 6 days ago

I sorted out my issue with "hatch fmt". I just haven't used 'uv' and didn't have a config set for it. Changed to using pip with a config change in hatch [tool.hatch.envs.hatch-static-analysis] installer = "pip"

I can also just setup uv to work in my environment, now that I know uv is involved. Would it be reasonable to fall back to pip if uv fails? (as a feature request) I suspect having uv configured for proxies and such may be less common unless you're familiar with hatch.

The 'hatch python' command seems to have github url's hard coded for all the different versions and I don't see a reasonable way to override that. In theory I would only need to set a different domain and path and the feature would work in my environment. Is there a reasonable way to override the github URL's without modifying hatch or writing a plugin?

Are there any other places in hatch that assume I'm connected to the internet or may not behave well with restricted network?

wj3171868 commented 5 days ago

search replace of 'https://github.com/indygreg/python-build-standalone/releases/download/' to my mirror of the same files worked well enough I assume writing a plugin with the different domain is the actual fix.. future TODO.

I haven't found anything else with meaningful hard set url's.

Hatch has been a real workflow improvement for me, I really appreciate that this exists.

ofek commented 5 days ago

Have you tried this? https://hatch.pypa.io/latest/how-to/python/custom/

wj3171868 commented 5 days ago

I have not. Perhaps I should give it a try. The environment variables can be mapped into a config perhaps?

I was more looking to just change the path and domain, not change the mapping or release numbers.