chore: switch to monorepo, move realtime inside #1190
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
This PR contains the first change in the monorepo switch, by moving
realtime
into this repository, and deprecating https://github.com/supabase/realtime-py (which I intend to do later). This requires restructuring this repository's files in order to leverageuv
workspaces, as explained in #1186.The changes can be summarized by the following tree diagram:
Reasoning
File structuring
uv
broadly expects python "packages" to be either libraries or applications; and for workspaces, it expects them to be structured as N libraries, whose directory need to be specified inuv.workspace.members
, and 1 application, located in./src/{appname}
. This means that projects in the root of the repository are generally interpreted as describing the application, but given that this repository shouldn't have no application, I decided to move most of the rootspyproject.toml
intosrc/supabase
, and use it as a workspace library entry by listing it inmembers
.uv
generally calls these "virtual workspaces" but I couldn't find much documentation around them anywhere.Package specific dependencies and commands
uv
already handles package specific dependencies by leveraginguv --exact --package {package} {cmd} ...
, so no additional care is required besides calling the command correctly. In order to make running these more streamlined, and to share/compose them into bigger ones (for instance, to run the same commands locally and in CI), I think it makes sense to rely on a command runner. I outlined the following broad requirements in order to decide which tool to use:uv
, including test/dev time dependencies (by usingdependency-groups
). This is to ensure that we are not specifying tests differently to run locally vs in CI.realtime
requires certain docker instances to be up before runningpytest
, whilesupabase
does not. On the flip side,supabase
relies onunasync-cli
to generate the_sync
, with adhocsed
commands, whilerealtime
does not use any of it - I don't think we want to keep this behavior in the future, but I do not intend to change it now.I decided to give just a try. It can be summarized as a
make
successor, that aims to be a command runner instead of a build system. By being a command runner, it does not suffer from issues thatMakefile
s suffer, like that targets may be interpreted as files, and thus need to be marked as PHONY sometimes, and has niceties such as aliases, readable errors, recipe arguments, invoking from anywhere (not only from the workspace root).just
also allows for structuring the files as namespaced modules, which helps to avoid hackier solutions to name collisions, like prepending every command with the package name. With this, each package can declare its commands for testing, linting and publishing insidesrc/{packge}/mod.just
, that is then imported as a module inside thejustfile
in the root of the workspace. This allows us to define targets likejust test
by composing each of the packages'test
, without any additional coordination.Alternatives
I believe that trying to use
Makefile
s to the same effect would result in a big spaghetti mess of commands, which is why I sought for a different tool.just
was the best tool I found that was also minimalistic and not an entire build system, but I'd love some more suggestions for monorepo related tooling, specially those that generally fit those guidelines. For the record, I considered the following tools:uv
to run it in the first place.uv
.