-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
META: Hatch documentation upgrade #1245
Comments
@lwasser hey! |
looking forward to seeing what you pull together @DahanDv ! |
It would be good to document advice on usage within Docker (this was requested in the past). Is just installing I had seen in the docs a brief note/admonition about standalone/installers not being able to detect/use an existing python install, thus pulling in a standalone version of python? (I had attempted to avoid this with a If 150-400MB is to be expected, it might be worthwhile to raise some awareness there. At least with an endorsed approach for using |
i am not sure if i can help here or not but chiming in. i just played with this quickly locally. when i created a docker container with python / pip in it it automatically increased the container size but about 330mb. my question: if python is not installed on a user's system and you install hatch, will it by default now try to install python now that it supports uv? i wonder if this should be another issue where folks chime in but also i wonder if anyone has worked with a docker container with some version of python already installed to see if there is a difference in the size of the container when running hatch --version (as a way to potentially tease out the need for python to be installed and how is't setup most efficiently in a container vs. hatch's default behavior). please excuse this comment if it's totally off base. it does seem like docs around this would be useful! |
I will respond to a few comments at the same time:
|
@ofek to clarify the example above referred to this issue comment. which had this docker setup: $ docker run -it ubuntu:22.04 bash
$ apt update && apt install -y curl
$ curl -sSfL https://github.com/pypa/hatch/releases/download/hatch-v1.10.0/hatch-1.10.0-x86_64-unknown-linux-gnu.tar.gz | tar -xz
$ mv hatch-1.10.0-x86_64-unknown-linux-gnu/usr/local/bin/hatch
$ du -shx /
144M /
$ hatch --version
Hatch, version 1.10.0
$ du -shx /
558M / in this case a user is
So nothing is run - yet. Then the hatch binaries are moved into a new location so hatch can be called. To me it makes sense based on what you wrote above that in this specific case, when you run The alternative approach would be for someone to create a docker container that first installs python or inherits from another container on dockerhub that contains python. Is that interpretation correct? and if it is, would it make sense to create a small how to (or add doc enhancements elsewhere)? i'm happy to help create a very basic example of this that others could enhance / build off of. |
here is a repro example. i definitely saw it install python and hatch when i ran
|
Yes that is actually expected as I mention in my first bullet point. Hatch binaries are built with PyApp and bootstraps itself on the first run. If you already have Python available and want to cut down on disk space then I would recommend installing manually. |
I might be able to shave some MBs off given a new release of the binaries and docs on enabling the option. |
fantastic. Ofek would a small "how to" or tutorial about creating a docker environment be useful in the docs? i am not a docker expert but i could atleast capture the information here for folks to use. maybe @polarathene (if you are up for it) could review and provide input as well? |
Yes that would be quite helpful! I wouldn't have time to add that new feature until after PyCon though. |
I looked into it a bit, here's my findings, hope it's helpful 👍 FWIW, keeping it simple and focused/familiar for most Docker users (that is those less experienced) is probably best. I wouldn't stress too much on size as you can see in the examples below you won't save too much with the added effort, but it's possible 👍 If you write something up and contribute a PR feel free to ping me and I'll try provide a review if I have the time :) TL;DR:
There's also the route of having a NOTE:
Install approachesPackage Manager (122 MiB)$ docker run --rm -it quay.io/fedora/fedora-minimal:41 bash
$ du -shx /
126M /
$ dnf5 install -y --setopt=install_weak_deps=0 hatch
Transaction Summary:
Installing: 75 packages
Upgrading: 5 packages
Replacing: 5 packages
Total size of inbound packages is 33 MiB. Need to download 33 MiB.
After this operation 122 MiB will be used (install 124 MiB, remove 2 MiB).
# Extra is from package manager cache:
$ du -shx /
297M /
# Clean up package manager cache:
$ dnf5 clean all
Removed 12 files, 7 directories. 0 errors occurred.
# Thus total 122 MiB added weight:
$ du -shx /
248M / Standalone installer (4MiB installs to 400+ MiB)$ docker run --rm -it quay.io/fedora/fedora-minimal:41 bash
# Fedora image already has curl, just needs tar + gzip to extract:
$ dnf5 install -y tar gzip && dnf5 clean all
# As the tar.gz contains only a single file, we can write the output to the preferred location directly:
$ curl -sSfL https://github.com/pypa/hatch/releases/download/hatch-v1.10.0/hatch-1.10.0-x86_64-unknown-linux-gnu.tar.gz \
| tar -xzO > /usr/local/bin/hatch && chmod +x /usr/local/bin/hatch
# Before triggering install:
$ du -shx /
131M /
# 410+ MiB added weight from install:
$ hatch --version && du -shx /
544M / Now as a FROM quay.io/fedora/fedora-minimal:41
RUN dnf5 install -y tar gzip && dnf5 clean all
RUN curl -sSfL https://github.com/pypa/hatch/releases/download/hatch-v1.10.0/hatch-1.10.0-x86_64-unknown-linux-gnu.tar.gz \
| tar -xzO > /usr/local/bin/hatch && chmod +x /usr/local/bin/hatch
RUN hatch --version # In dir with `Dockerfile` above:
docker build --tag local/hatch .
docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock wagoodman/dive local/hatch
Considering that's all in the
|
Thank you for the fantastic writeup! As of https://github.com/pypa/hatch/releases/tag/hatch-v1.11.0, the binaries pull down distributions that already have Hatch installed which is about as small as I can make that. This is what the official GitHub action to install Hatch will use when I have time to do so. There is also a new
|
Actually forget what I said please, I'm about to reduce that substantially. |
amazing!! ofek, with pycon travel coming up i won't be able to start a tutorial / how to until after i'm back! but also @polarathene you've provided an INCREDIBLE amount of information above and i suspect / know :) that you know a lot more about this topic than i do. would you like to start a tutorial and i can perhaps contribute? or would you like for me to start / try my best to reflect what you have found and then you can review/ contribute / add that way? it just seems to me that there is so much information in this thread now, that we should capture it and turn it into a documentation page for others to discover! |
ofek that is a considerable reduction in image size!! so so awesome!! |
Cheers for the improvement @ofek ! 🥳 (EDIT: It seems there are some gotchas to consider vs a The below notes are mostly for my benefit to come back to, but sharing with others if helpful. I'll summarize with a TLDR in a follow-up comment. Collapsed for brevity (click to view)Layer insights:
Actual hatch lives as a python script at
|
Summary of prior messageStill a tad long, see the prior message for more details. GH Releases:
Standalone installer depends on external python despite bundling it's own:
Standalone installer prepends it's bin location to
Docs (Web / CLI help) need love:
|
@lwasser I've got a bit to juggle elsewhere, but I'd be happy to review a PR when I can spare the time. I am not that experienced with Python, but I know Linux and Docker very well! If you've got any questions feel free to reach out 👍 I think most of the info I've covered above doesn't really need to go into the docs. It was more about exploring what options were available and the tradeoffs 😎
|
I just wanted to check back in here, y'all. I've been swamped with other volunteer commitments, and I won't be able to follow through with the docker PR. I hope that someone else can hop in and work on this, as this issue contains a lot of great information. We are having good success with using and teaching Hatch over at pyOpenSci, so I hope to continue to see the use of and documentation for Hatch grow! |
Hi all! I wanted to introduce myself to this topic as Ofek kindly pointed me here when I mentioned I would be interested in helping out with some documentation. I work as a data scientist at a small company in Austin, TX and we adopted hatch as our project manager earlier this year after some research. We had been using conda but I ran into some major headaches when trying to deploy using conda + docker + AWS services. Since these AWS services were going to be a big part of how we deployed our solutions, we decided to switch our project manager. Since I don't want to write an essay here, I will try to keep it short 😁. We decided on hatch and I have been experimenting with it ever since and really enjoy the features though I think documentation could be improved and so I am here to help. I have not read this entire thread yet but I look forward to catching up and helping as I can (I also volunteer for too many projects 😬). |
Following the discussion here, we discussed with @ofek @DahanDv upgrading the hatch docs to include more how-to and tutorial style elements to help users get started with hatch.
This also related to this issue opened by @pfmoore about using the Diátaxis framework.
In this issue we can iterate around what the structure of tutorials vs how-tos should look like and what we wish to create / develop further to help hatch users. I'll attempt to track comments below and update the main outline here as the discussion progresses.
I'll also try to here and there scan issues and discussions to identify pain points and get users involved in the upgraded content reviews :) @DahanDv
Note that we also are working on tutorials at pyOpenSci which we could link to / use as needed here.
Here is a tutorial on publishing to PyPI using hatch.
I'm starting the discussion here but probably can't work out a full outline now. Please add comments about other tutorials / how to's that you'd like to see and i will update this header comment as needed. (or @ofek obviously you can always edit it too!).
Hatch How To's
Hatch Tutorials
The text was updated successfully, but these errors were encountered: