Skip to content

Commit b8b0502

Browse files
authored
chore: switch to monorepo, move realtime inside (#1190)
1 parent ec775ca commit b8b0502

Some content is hidden

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

68 files changed

+5442
-939
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ jobs:
2828
- name: Clone Repository
2929
uses: actions/checkout@v5
3030

31+
- name: Install supabase cli latest
32+
uses: supabase/setup-cli@v1
33+
3134
- name: Install uv
3235
uses: astral-sh/setup-uv@v6
3336
with:
3437
version: "0.8.2"
3538
python-version: ${{ matrix.python-version }}
3639

3740
- name: Run Tests
38-
run: uv run tests
41+
run: make ci
3942

4043
- name: Upload coverage to Coveralls
4144
uses: coverallsapp/github-action@v2
@@ -95,8 +98,5 @@ jobs:
9598
version: "0.8.2"
9699
python-version: "3.11"
97100

98-
- name: Build package dist directory
99-
run: uv build
100-
101-
- name: Publish package distributions to PyPI
102-
uses: pypa/gh-action-pypi-publish@release/v1
101+
- name: Build all packages and publish
102+
run: make publish

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ venv/
269269
ENV/
270270
env.bak/
271271
venv.bak/
272+
.direnv
273+
.envrc
272274

273275
# Spyder project settings
274276
.spyderproject

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.PHONY: ci, default, pre-commit
2+
3+
default:
4+
@echo "Available targets are: ci, pre-commit"
5+
6+
ci: pre-commit
7+
make -C src/realtime tests
8+
make -C src/supabase tests
9+
10+
publish:
11+
uv build --project realtime
12+
uv build --project supabase
13+
uv publish
14+
15+
pre-commit:
16+
uv run pre-commit run --all-files

README.md

Lines changed: 10 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# `supabase-py`
22

3-
Python client for [Supabase](https://supabase.com)
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:
4+
5+
- [supabase](src/supabase/README.md)
6+
- [realtime](src/realtime/README.md)
7+
8+
Relevant links:
49

510
- Documentation: [supabase.com/docs](https://supabase.com/docs/reference/python/introduction)
611
- Usage:
@@ -18,12 +23,13 @@ cd supabase-py
1823

1924
### Create and Activate a Virtual Environment
2025

21-
We recommend activating your virtual environment. For example, we like `uv` and `conda`! 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/).
26+
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.
2227

2328
Using uv:
2429
```
2530
uv venv supabase-py
2631
source supabase-py/bin/activate
32+
uv sync
2733
```
2834

2935
Using venv (Python 3 built-in):
@@ -40,154 +46,15 @@ conda create --name supabase-py
4046
conda activate supabase-py
4147
```
4248

43-
### PyPI installation
44-
45-
Install the package (for Python >= 3.9):
46-
49+
Using nix:
4750
```bash
48-
# with pip
49-
pip install supabase
50-
51-
# with conda
52-
conda install -c conda-forge supabase
51+
nix develop
5352
```
5453

5554
### Local installation
5655

5756
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.
5857

59-
## Usage
60-
61-
Set your Supabase environment variables in a dotenv file, or using the shell:
62-
63-
```bash
64-
export SUPABASE_URL="my-url-to-my-awesome-supabase-instance"
65-
export SUPABASE_KEY="my-supa-dupa-secret-supabase-api-key"
66-
```
67-
68-
Init client:
69-
70-
```python
71-
import os
72-
from supabase import create_client, Client
73-
74-
url: str = os.environ.get("SUPABASE_URL")
75-
key: str = os.environ.get("SUPABASE_KEY")
76-
supabase: Client = create_client(url, key)
77-
```
78-
79-
Use the supabase client to interface with your database.
80-
81-
### Sign-up
82-
83-
```python
84-
user = supabase.auth.sign_up({ "email": users_email, "password": users_password })
85-
```
86-
87-
### Sign-in
88-
89-
```python
90-
user = supabase.auth.sign_in_with_password({ "email": users_email, "password": users_password })
91-
```
92-
93-
### Insert Data
94-
95-
```python
96-
data = supabase.table("countries").insert({"name":"Germany"}).execute()
97-
98-
# Assert we pulled real data.
99-
assert len(data.data) > 0
100-
```
101-
102-
### Select Data
103-
104-
```python
105-
data = supabase.table("countries").select("*").eq("country", "IL").execute()
106-
107-
# Assert we pulled real data.
108-
assert len(data.data) > 0
109-
```
110-
111-
### Update Data
112-
113-
```python
114-
data = supabase.table("countries").update({"country": "Indonesia", "capital_city": "Jakarta"}).eq("id", 1).execute()
115-
```
116-
117-
### Update data with duplicate keys
118-
119-
```python
120-
country = {
121-
"country": "United Kingdom",
122-
"capital_city": "London" # This was missing when it was added
123-
}
124-
125-
data = supabase.table("countries").upsert(country).execute()
126-
assert len(data.data) > 0
127-
```
128-
129-
### Delete Data
130-
131-
```python
132-
data = supabase.table("countries").delete().eq("id", 1).execute()
133-
```
134-
135-
### Call Edge Functions
136-
137-
```python
138-
def test_func():
139-
try:
140-
resp = supabase.functions.invoke("hello-world", invoke_options={'body':{}})
141-
return resp
142-
except (FunctionsRelayError, FunctionsHttpError) as exception:
143-
err = exception.to_dict()
144-
print(err.get("message"))
145-
```
146-
147-
### Download a file from Storage
148-
149-
```python
150-
bucket_name: str = "photos"
151-
152-
data = supabase.storage.from_(bucket_name).download("photo1.png")
153-
```
154-
155-
### Upload a file
156-
157-
```python
158-
bucket_name: str = "photos"
159-
new_file = getUserFile()
160-
161-
data = supabase.storage.from_(bucket_name).upload("/user1/profile.png", new_file)
162-
```
163-
164-
### Remove a file
165-
166-
```python
167-
bucket_name: str = "photos"
168-
169-
data = supabase.storage.from_(bucket_name).remove(["old_photo.png", "image5.jpg"])
170-
```
171-
172-
### List all files
173-
174-
```python
175-
bucket_name: str = "charts"
176-
177-
data = supabase.storage.from_(bucket_name).list()
178-
```
179-
180-
### Move and rename files
181-
182-
```python
183-
bucket_name: str = "charts"
184-
old_file_path: str = "generic/graph1.png"
185-
new_file_path: str = "important/revenue.png"
186-
187-
data = supabase.storage.from_(bucket_name).move(old_file_path, new_file_path)
188-
```
189-
190-
19158
## Roadmap
19259

19360
- [x] Wrap [Postgrest-py](https://github.com/supabase/postgrest-py/)
@@ -265,14 +132,6 @@ data = supabase.storage.from_(bucket_name).move(old_file_path, new_file_path)
265132

266133
Contributing to the Python libraries are a great way to get involved with the Supabase community. Reach out to us on [Discord](https://discord.supabase.com) or on our [Github Discussions](https://github.com/orgs/supabase/discussions) page if you want to get involved.
267134

268-
## Important: Proper Client Shutdown
269-
270-
To ensure the Supabase client terminates correctly and to prevent resource leaks, you **must** explicitly call:
271-
272-
```python
273-
client.auth.sign_out()
274-
```
275-
276135
### Running Tests
277136

278137
Currently, the test suites are in a state of flux. We are expanding our clients' tests to ensure things are working, and for now can connect to this test instance, which is populated with the following table:

cli_scripts.py

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)