Skip to content

Commit 2533ba1

Browse files
authored
feat: include postgrest in monorepo, finalize monorepo switch (#1213)
1 parent 12ffb31 commit 2533ba1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+9571
-84
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
python-version: ${{ matrix.python-version }}
4141

4242
- name: Run Tests
43-
run: make ci -j
43+
run: make ci
4444

4545
- name: Upload coverage to Coveralls
4646
uses: coverallsapp/github-action@v2

.release-please-manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"src/realtime": "2.7.0",
44
"src/functions": "0.10.1",
55
"src/storage": "0.12.1",
6+
"src/postgrest": "1.1.1",
67
"src/auth": "2.12.3"
78
}

Makefile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: ci, default, pre-commit, clean, start-infra, stop-infra
22

3-
PACKAGES := functions realtime storage auth supabase
3+
PACKAGES := functions realtime storage auth postgrest supabase
44
FORALL_PKGS = $(foreach pkg, $(PACKAGES), $(pkg).$(1))
55

66
help::
@@ -17,19 +17,23 @@ help::
1717
@echo " pre-commit -- Run pre-commit on all files"
1818

1919
clean: $(call FORALL_PKGS,clean)
20+
rm -rf dist .ruff_cache .pytest_cache
2021
help::
2122
@echo " clean -- Delete cache files and coverage reports from tests"
2223

2324
publish: $(call FORALL_PKGS,build)
2425
uv publish
2526

2627
# not all packages have infra, so just manually instantiate the ones that do for now
27-
start-infra: realtime.start-infra storage.start-infra auth.start-infra
28+
start-infra: realtime.start-infra storage.start-infra auth.start-infra postgrest.start-infra
2829
help::
29-
@echo " start-infra -- Start all containers necessary for tests. NOTE: it is not necessary to this before running CI tests, they start the infra by themselves"
30-
stop-infra: realtime.stop-infra storage.stop-infra auth.stop-infra
30+
@echo " start-infra -- Start all containers necessary for tests."
31+
@echo " NOTE: it is not necessary to this command before running CI tests"
32+
33+
stop-infra: realtime.stop-infra storage.stop-infra auth.stop-infra postgrest.stop-infra
3134
help::
32-
@echo " stop-infra -- Stop all infra used by tests. NOTE: tests do leave their infra running, so run this to ensure all containers are stopped"
35+
@echo " stop-infra -- Stop all infra used by tests."
36+
@echo " NOTE: run this command to ensure all containers are stopped after tests"
3337

3438

3539
realtime.%:
@@ -44,6 +48,9 @@ storage.%:
4448
auth.%:
4549
@$(MAKE) -C src/auth $*
4650

51+
postgrest.%:
52+
@$(MAKE) -C src/postgrest $*
53+
4754
supabase.%:
4855
@$(MAKE) -C src/supabase $*
4956

README.md

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
# `supabase-py`
22

3-
Python monorepo for all [Supabase](https://supabase.com) libraries. This is a work in progress, and currently these are the ones contained in this repository:
3+
[![CI](https://github.com/supabase/supabase-py/actions/workflows/ci.yml/badge.svg)](https://github.com/supabase/supabase-py/actions/workflows/ci.yml)
4+
[![Version](https://img.shields.io/pypi/v/supabase?color=%2334D058)](https://pypi.org/project/supabase)
5+
[![Coverage Status](https://coveralls.io/repos/github/supabase/supabase-py/badge.svg?branch=main)](https://coveralls.io/github/supabase/supabase-py?branch=main)
6+
7+
Python monorepo for all [Supabase](https://supabase.com) libraries.
48

59
- [supabase](src/supabase/README.md)
6-
- [realtime](src/realtime/README.md)
10+
- [realtime-py](src/realtime/README.md)
711
- [supabase_functions](src/functions/README.md)
812
- [storage3](src/storage/README.md)
13+
- [postgrest](src/postgrest/README.md)
914
- [supabase_auth](src/auth/README.md)
1015

1116
Relevant links:
@@ -15,7 +20,7 @@ Relevant links:
1520
- [GitHub OAuth in your Python Flask app](https://supabase.com/blog/oauth2-login-python-flask-apps)
1621
- [Python data loading with Supabase](https://supabase.com/blog/loading-data-supabase-python)
1722

18-
## Set up a Local Development Environment
23+
## Local Development
1924

2025
### Clone the Repository
2126

@@ -24,50 +29,52 @@ git clone https://github.com/supabase/supabase-py.git
2429
cd supabase-py
2530
```
2631

27-
### Create and Activate a Virtual Environment
32+
### Dependencies
33+
34+
This repository relies on the following dependencies for development:
35+
- `uv` for python project management.
36+
- `make` for command running.
37+
- `docker` for both `postgrest` and `auth` test containers.
38+
- `supabase-cli` for both `storage` and `realtime` test containers.
39+
40+
All of these dependencies are included in the nix shell environment, through `flake.nix`. If you've got `nix` installed, you may prefer to use it through `nix develop`.
2841

29-
We recommend activating your virtual environment. For example, we like `uv`, `conda` and `nix`! Click [here](https://docs.python.org/3/library/venv.html) for more about Python virtual environments and working with [conda](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#activating-an-environment) and [uv](https://docs.astral.sh/uv/getting-started/features/). For nix, just install it with flakes enabled.
42+
### Use a Virtual Environment
43+
44+
We recommend using a virtual environment, preferrably through `uv`, given it is currently the only tool that understands the workspace setup (you can read more about it in [the uv docs](https://docs.astral.sh/uv/concepts/projects/workspaces/)).
3045

31-
Using uv:
3246
```
3347
uv venv supabase-py
3448
source supabase-py/bin/activate
3549
uv sync
3650
```
3751

38-
Using venv (Python 3 built-in):
52+
If you're using nix, the generated `python` executable should have the correct dependencies installed for the whole workspace, given it is derived from the root's `pyproject.toml` using [uv2nix](https://github.com/pyproject-nix/uv2nix).
3953

40-
```bash
41-
python3 -m venv env
42-
source env/bin/activate # On Windows, use .\env\Scripts\activate
43-
```
54+
### Running tests and other commands
4455

45-
Using conda:
56+
We use `make` to store and run the relevant commands. The structure is setup such that each sub package can individually set its command in its own `Makefile`, and the job of the main `Makefile` is just coordinate calling each of them.
4657

58+
For instance, in order to run all tests of all packages, you should use the following root command
4759
```bash
48-
conda create --name supabase-py
49-
conda activate supabase-py
60+
make ci
5061
```
62+
Which internally dispatches `make -C src/{package} tests` calls to each package in the monorepo.
5163

52-
Using nix:
64+
You should also consider using
5365
```bash
54-
nix develop
66+
make ci -jN # where N is the number of max concurrent jobs, or just -j for infinite jobs
5567
```
68+
To run each of the packages' tests in parallel. This should be generally faster than running in 1 job, but has the downside of messing up the CLI output, so parsing error messages might not be easy.
5669

57-
### Local installation
58-
59-
You can also install locally after cloning this repo. Install Development mode with `pip install -e`, which makes it editable, so when you edit the source code the changes will be reflected in your python module.
60-
61-
## Badges
62-
63-
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?label=license)](https://opensource.org/licenses/MIT)
64-
[![CI](https://github.com/supabase/supabase-py/actions/workflows/ci.yml/badge.svg)](https://github.com/supabase/supabase-py/actions/workflows/ci.yml)
65-
[![Python](https://img.shields.io/pypi/pyversions/supabase)](https://pypi.org/project/supabase)
66-
[![Version](https://img.shields.io/pypi/v/supabase?color=%2334D058)](https://pypi.org/project/supabase)
67-
[![Codecov](https://codecov.io/gh/supabase/supabase-py/branch/develop/graph/badge.svg)](https://codecov.io/gh/supabase/supabase-py)
68-
[![Last commit](https://img.shields.io/github/last-commit/supabase/supabase-py.svg?style=flat)](https://github.com/supabase/supabase-py/commits)
69-
[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/supabase/supabase-py)](https://github.com/supabase/supabase-py/commits)
70-
[![Github Stars](https://img.shields.io/github/stars/supabase/supabase-py?style=flat&logo=github)](https://github.com/supabase/supabase-py/stargazers)
71-
[![Github Forks](https://img.shields.io/github/forks/supabase/supabase-py?style=flat&logo=github)](https://github.com/supabase/supabase-py/network/members)
72-
[![Github Watchers](https://img.shields.io/github/watchers/supabase/supabase-py?style=flat&logo=github)](https://github.com/supabase/supabase-py)
73-
[![GitHub contributors](https://img.shields.io/github/contributors/supabase/supabase-py)](https://github.com/supabase/supabase-py/graphs/contributors)
70+
Other relevant commands include
71+
```bash
72+
make pre-commit # run lints and formmating before commiting
73+
make stop-infra # stops all running containers from all packages
74+
make clean # delete all intermediary files created by testing
75+
```
76+
All the sub packages command are available from the main root by prefixing the command with `{package_name}.`. Examples:
77+
```bash
78+
make realtime.tests # run only realtime tests
79+
make storage.clean # delete temporary files only in the storage package
80+
```

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,30 @@
3333
pkgs.supabase-cli
3434
pkgs.uv
3535
pkgs.gnumake
36+
pkgs.docker
3637
];
3738
workspace = uv2nix.lib.workspace.loadWorkspace { workspaceRoot = ./.; };
3839

3940
workspace-overlay = workspace.mkPyprojectOverlay {
4041
sourcePreference = "wheel"; # or sourcePreference = "sdist";
4142
};
4243

44+
pyproject-overlay = final: prev: {
45+
ruamel-yaml-clib = prev.ruamel-yaml-clib.overrideAttrs (old: {
46+
nativeBuildInputs = old.nativeBuildInputs ++ [
47+
(final.resolveBuildSystem {
48+
setuptools = [];
49+
})
50+
];
51+
});
52+
53+
};
54+
4355
python-for = pkgs: let
4456
extensions = pkgs.lib.composeManyExtensions [
4557
pyproject-build-systems.overlays.default
4658
workspace-overlay
59+
pyproject-overlay
4760
];
4861
base-python = pkgs.callPackage pyproject-nix.build.packages {
4962
python = pkgs.python311;
@@ -55,6 +68,21 @@
5568
python-env = python.mkVirtualEnv "supabase-py" workspace.deps.all;
5669
in {
5770
default = pkgs.mkShell {
71+
env = {
72+
# Don't create venv using uv
73+
UV_NO_SYNC = "1";
74+
75+
# Force uv to use nixpkgs Python interpreter
76+
UV_PROJECT_ENVIRONMENT = python-env;
77+
UV_PYTHON = pkgs.python311.interpreter;
78+
79+
# Prevent uv from downloading managed Python's
80+
UV_PYTHON_DOWNLOADS = "never";
81+
};
82+
shellHook = ''
83+
# Undo dependency propagation by nixpkgs.
84+
unset PYTHONPATH
85+
'';
5886
packages = [ python-env ] ++ (dev-tools pkgs);
5987
};
6088
});

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ members = [
44
"src/functions",
55
"src/supabase",
66
"src/storage",
7+
"src/postgrest",
78
"src/auth"
89
]
910

@@ -12,6 +13,7 @@ realtime = { workspace = true }
1213
supabase_functions = { workspace = true }
1314
supabase_auth = { workspace = true }
1415
storage3 = { workspace = true }
16+
postgrest = { workspace = true }
1517
supabase = { workspace = true }
1618

1719
[tool.pytest.ini_options]

release-please-config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
"changelog-path": "src/storage/CHANGELOG.md",
1818
"release-type": "python"
1919
},
20+
"src/postgrest": {
21+
"changelog-path": "src/postgrest/CHANGELOG.md",
22+
"release-type": "python"
23+
},
2024
"src/supabase": {
2125
"changelog-path": "src/supabase/CHANGELOG.md",
2226
"release-type": "python"

src/auth/README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,30 @@
33
[![CI](https://github.com/supabase-community/gotrue-py/actions/workflows/ci.yml/badge.svg)](https://github.com/supabase-community/gotrue-py/actions/workflows/ci.yml)
44
[![Python](https://img.shields.io/pypi/pyversions/gotrue)](https://pypi.org/project/gotrue)
55
[![Version](https://img.shields.io/pypi/v/gotrue?color=%2334D058)](https://pypi.org/project/gotrue)
6-
[![Coverage Status](https://coveralls.io/repos/github/supabase/auth-py/badge.svg?branch=main)](https://coveralls.io/github/supabase/auth-py?branch=main)
76

87
This is a Python port of the [supabase js gotrue client](https://github.com/supabase/gotrue-js). The current state is that there is a features parity but with small differences that are mentioned in the section **Differences to the JS client**. As of December 14th, we renamed to repo from `gotrue-py` to `auth-py` to mirror the changes in the JavaScript library.
98

109
## Installation
1110

12-
The package can be installed using pip or poetry:
11+
The package can be installed using pip, uv or poetry:
1312

14-
### Poetry
13+
### Pip
1514

1615
```bash
17-
poetry add supabase_auth
16+
pip install supabase_auth
1817
```
1918

20-
### Pip
19+
20+
### Uv
2121

2222
```bash
23-
pip install supabase_auth
23+
uv add supabase_auth
24+
```
25+
26+
### Poetry
27+
28+
```bash
29+
poetry add supabase_auth
2430
```
2531

2632
## Features

src/auth/infra/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# docker-compose.yml
2-
version: '3'
2+
name: auth-tests
33
services:
44
gotrue: # Signup enabled, autoconfirm off
55
image: supabase/auth:v2.178.0

0 commit comments

Comments
 (0)