News for hackers. Stuff that matters.
Re:DIY Git in Python by jamesdutc on Saturday May 13, 2023 @05:31PM (#35932950)
Similar (but a far more limited implementation):

“Write a Git Client from Scratch in 25 Minutes”

https://youtu.be/xvzo_nV9PjU

Re:DIY Git in Python by aardvarkr on Saturday May 13, 2023 @06:00PM (#35933211)
This has been posted before but it’s incredibly well written and easy to follow. I had a blast with it last time it made the front page. Great post to reshare!
Re:DIY Git in Python by asicsp on Saturday May 13, 2023 @11:37PM (#35935123)
Links:

https://news.ycombinator.com/item?id=28735425 (194 points | Oct 3, 2021 | 23 comments)

https://news.ycombinator.com/item?id=24517925 (309 points | Sept 18, 2020 | 30 comments)

Re:DIY Git in Python by tech234a on Saturday May 13, 2023 @06:01PM (#35933215)
Loosely related: Dulwich, a pure-Python Git implementation

https://github.com/jelmer/dulwich

Re:DIY Git in Python by microtherion on Saturday May 13, 2023 @06:17PM (#35933328)
This seems to be a similar idea to James Coglan's excellent book _Building Git_, which reimplemented Git in Ruby: https://shop.jcoglan.com/building-git/
Re:DIY Git in Python by ibitto on Saturday May 13, 2023 @06:20PM (#35933342)
Two more Python implementations are mentioned in build-your-own-x [0].

- https://wyag.thb.lt

- https://benhoyt.com/writings/pygit/

[0]: https://github.com/codecrafters-io/build-your-own-x#build-yo...

Re:DIY Git in Python by forgotpwd16 on Sunday May 14, 2023 @02:30AM (#35935802)
Also codecrafters itself has build your own git course.
Re:DIY Git in Python by okasaki on Saturday May 13, 2023 @06:38PM (#35933470)
Probably fun to read and educational, but why in the world does the page use grey text on a grey background?
Re:DIY Git in Python by anamexis on Saturday May 13, 2023 @07:02PM (#35933653)
It passes WCAG contrast guidelines just fine. It has a contrast ratio of 7.84, and the WCAG AAA standard requires 7.0.

I find it very readable.

Re:DIY Git in Python by zserge on Saturday May 13, 2023 @07:07PM (#35933683)
A similar toy git in Go (but probably smaller and more limited): https://zserge.com/posts/git/
Re:DIY Git in Python by fiddlerwoaroof on Saturday May 13, 2023 @07:24PM (#35933793)
I implemented a read-only implementation of git here: https://github.com/fiddlerwoaroof/cl-git

It’s nearly complete, I just have to finish a couple annoying edge cases around delta compression.

Re:DIY Git in Python by teleforce on Saturday May 13, 2023 @07:35PM (#35933861)
Nice tutorial on building Git with Python from scratch.

This book teach building Git from scratch with Ruby:

https://shop.jcoglan.com/building-git/

Re:DIY Git in Python by TuringNYC on Saturday May 13, 2023 @08:31PM (#35934211)
Putting aside git, i love the format and step-by-step teaching! You've done a better job at this than 99% of CS professors i've ever had. Thank you for doing this!
Re:DIY Git in Python by evgpbfhnr on Sunday May 14, 2023 @06:41AM (#35936986)
This interface is downright awesome; I'd love something that takes a git repository and displays the commit message along with the diffs like this (might be how this works under the hood) If there's something usable like this I didn't know about, please say!

EDIT: from comment in the first page the author said it's custom typescript which isn't open-source yet, there's still hope :)

Re:DIY Git in Python by macintux on Saturday May 13, 2023 @08:57PM (#35934344)
I really love the idea, but it's sent me down the Python packaging rabbit hole because the very first page's recommendation to use `python3 setup.py develop --user` doesn't work without some customization that I have yet to figure out.

First, it seems to (maybe?) work better with a venv running, which I didn't have. Ok, I can create one.

Next, `SetuptoolsDeprecationWarning: setup.py install is deprecated`, although I can live with that for now.

Next, I'm provided with a long list of ideas for how to enable `.pth` files, but https://setuptools.pypa.io/en/latest/deprecated/easy_install... strongly implies that `export PYTHONUSERBASE=`pwd`` prior to running setup should work. It doesn't.

Python, why does your ecosystem have to be so broken?

Re:DIY Git in Python by xcdzvyn on Saturday May 13, 2023 @09:38PM (#35934537)
It's almost surprising how far Python has come with the state pip is in; it's so rare to have any remotely sizeable software's dependencies install properly without some hacking.
Re:DIY Git in Python by LeonenTheDK on Saturday May 13, 2023 @10:27PM (#35934813)
I can echo the same. My Python use has largely been automating some tasks at work, nothing incredibly large, but new installation of the deps is always problematic. And the same goes for more than a few OSS projects I try to get working locally.
Re:DIY Git in Python by rtpg on Sunday May 14, 2023 @01:16AM (#35935510)
What I've seen way more of is that pip by itself works "fine" (on *nixes, module the Mac package manager problem), except you have to do some virtualenv setup. Lots of projects write their own wrappers or tools to make this more straightforward (perfectly reasonable!)

End result: you need to hack around these tools because they are assuming X or Y about an environment. Or you have to set up pyenv & co because whoever made this project decided that is "the way" to do things.

So now we have this "portable" language ecosystem where everyone wants to run things in docker because that's easier than getting developers to be able to debug their own environments (will repeat this is completely reasonable!)

Re:DIY Git in Python by toyg on Sunday May 14, 2023 @11:47AM (#35938836)
I guess it depends very much on the niche. Datascience? Yeah, hacking probably necessary for all those C/rust stuff. Web? Things will work just fine.
Re:DIY Git in Python by alex_lav on Saturday May 13, 2023 @11:49PM (#35935173)
Python packaging sucks. It's a big part of my job right now. To get various things to work, I've had to downgrade setuptools and manually install Cython.
Re:DIY Git in Python by PufPufPuf on Sunday May 14, 2023 @05:12AM (#35936556)
Python packaging is dead simple. You just define your package in requirements.txt, setup.py, setup.cfg, MANIFEST.in, pyproject.toml (although this one has two different ways to declare dependencies), and/or Pipfile. You then use pip, pipenv, virtualenv, venv, virtualenvwrapper, pyenv, pyenv-virtualenv, pyenv-virtualenvwrapper, poetry, and/or conda to install and manage the package.
Re:DIY Git in Python by Too on Sunday May 14, 2023 @11:48PM (#35943702)
That instruction is not the recommended way.

To make it work, use a virtualenv, seriously always use a virtualenv. Then inside: pip install --editable ./

This has been the standard way to install packages since forever. Don’t know why author complicates it with lower level setuptools. This is the same message that deprecationwarning is giving btw.

Re:DIY Git in Python by macintux on Monday May 15, 2023 @08:01AM (#35946835)
Thanks, that did the trick.

I'm going to argue, however, that "standard" is far too strong a word. I've been using Python on a near-daily basis for the last 4 years. I've never run into that, and I don't see it at the Hitchhiker's Guide.

Well, that and Python doesn't seem to do standard.

Re:DIY Git in Python by wild_pointer on Sunday May 14, 2023 @03:06AM (#35935984)
I took this tutorial and it vastly improved my git understanding, nicely done in both content and the way it's presented!