Skip to content
Huy Nguyen's Blog
Go back

copit: Copy Source Code Into Your Project, shadcn/ui Style

Sometimes you find useful code on GitHub — a single module, a well-written parser, a utility — and your options are bad: copy-paste it manually and lose track of where it came from, or install the entire library as a dependency just for one piece of it. Other times you want a library but can’t have it: version conflicts, or it’s unmaintained but the code is still perfectly good.

copit solves this the way shadcn/ui did for React components: instead of an opaque package, you get the actual source files. You own them, you can read and modify them, no dependency lock-in — but unlike manual vendoring, everything stays tracked and updatable.

Table of contents

Open Table of contents

How it works

pip install copit

copit init                          # creates copit.toml
copit add github:owner/repo@v1.0/path/to/component
copit update vendor/component       # re-fetch latest
copit sync                          # re-fetch all tracked sources
copit remove vendor/component       # clean up

Everything is tracked in copit.toml. You can mark files you’ve modified so they won’t get clobbered on update, and a --backup flag saves .orig copies when your files differ from upstream.

Versus the alternatives

The bigger idea

The pattern I’m most excited about: distributing framework components as copyable source. Think of how a LangChain-style project could work — the core orchestration ships as a pip package, but integrations (provider adapters, custom chains) are source files users copy in and own. They read exactly what the code does, modify what doesn’t fit, and never wait on an upstream PR.

A note on Rust

copit is a Rust binary distributed via maturin, so pip install copit gives you a native binary with no toolchain needed (it’s also on crates.io). I’m primarily a Python developer — this was my first Rust project, chosen for the single-binary distribution story, and a great learning exercise in ownership, anyhow error handling, and structuring a real project with tests.

Feedback, issues, and contributions are welcome.


Share this post:


Previous Post
nplus1: A Modern N+1 Query Detector for Django, SQLAlchemy, and Peewee
Next Post
django-i18n-fields: Multilingual Model Fields for Django