Skip to content

Commit 3187bc9

Browse files
refactoring setup.py config for pip install (#145)
1 parent d72ffcc commit 3187bc9

File tree

11 files changed

+128
-12
lines changed

11 files changed

+128
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,4 @@ clog/
8787
manifest/
8888
.mypy_cache/
8989
.ruff_cache/
90+
tests/db_snapshots/

docker-compose.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@ services:
88
- SURREAL_PASS=root
99
- SURREAL_LOG=trace
1010
ports:
11-
- 8000:8000
11+
- 8300:8000
12+
13+
surrealdb_big_data:
14+
image: surrealdb-big-data
15+
# environment:
16+
# - SURREAL_USER=root
17+
# - SURREAL_PASS=root
18+
# - SURREAL_LOG=trace
19+
ports:
20+
- 9000:8000
1221

1322
surrealdb_200:
1423
image: surrealdb/surrealdb:v2.0.0

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ classifiers = [
2020
]
2121

2222
[build-system]
23-
requires = ["setuptools", "wheel", "setuptools-rust"]
23+
requires = ["setuptools", "wheel"]
2424

2525
[tool.poetry.dependencies]
2626
python = "^3.10"

scripts/download_snapshots.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
# navigate to directory
4+
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
5+
cd $SCRIPTPATH
6+
7+
cd ..
8+
cd tests
9+
10+
if [ -d "./db_snapshots" ]; then
11+
echo "DB snapshots are already present"
12+
rm -rf ./db_snapshots
13+
fi
14+
15+
dockpack pull -i maxwellflitton/surrealdb-data -d ./db_snapshots

setup.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import pathlib
33

44
from setuptools import setup
5-
from setuptools_rust import Binding, RustExtension
65

76

87
with open("README.md", "r") as fh:
@@ -21,15 +20,29 @@
2120
long_description=long_description,
2221
long_description_content_type="text/markdown",
2322
version=version,
24-
rust_extensions=[RustExtension("surrealdb.rust_surrealdb", binding=Binding.PyO3)],
2523
packages=[
2624
"surrealdb",
27-
"surrealdb.execution_mixins",
28-
"surrealdb.async_execution_mixins"
25+
"surrealdb.data",
26+
"surrealdb.data.types"
2927
],
3028
package_data={
3129
"surrealdb": ["binaries/*"],
3230
},
31+
install_requires=[
32+
"cbor2==5.6.5",
33+
"certifi==2024.12.14",
34+
"charset-normalizer==3.4.0",
35+
"idna==3.10",
36+
"pytz==2024.2",
37+
"requests==2.32.3",
38+
"semantic-version==2.10.0",
39+
"tomli==2.2.1",
40+
"types-pytz==2024.2.0.20241003",
41+
"types-requests==2.32.0.20241016",
42+
"typing_extensions==4.12.2",
43+
"urllib3==2.2.3",
44+
"websockets==14.1",
45+
],
3346
# rust extensions are not zip safe, just like C-extensions.
3447
zip_safe=False,
3548
include_package_data=True

surrealdb/data/types/datetime.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import pytz # type: ignore
2-
31
from dataclasses import dataclass
42
from datetime import datetime
5-
from math import floor
63
from typing import Tuple
74

5+
import pytz # type: ignore
6+
from math import floor
7+
88

99
@dataclass
1010
class DateTimeCompact:
1111
timestamp: int = 0 # nanoseconds
1212

1313
@staticmethod
14-
def parse(seconds: int, nanoseconds: int):
14+
def parse(seconds: int, nanoseconds: int) -> "DateTimeCompact":
1515
return DateTimeCompact(nanoseconds + (seconds * pow(10, 9)))
1616

1717
def get_seconds_and_nano(self) -> Tuple[int, int]:

surrealdb/data/types/duration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from dataclasses import dataclass
2-
from math import floor
32
from typing import Tuple
43

4+
from math import floor
5+
56

67
@dataclass
78
class Duration:

tests/builds/big_data_dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM debian:bullseye-slim
2+
3+
RUN apt-get update && apt-get install -y libpq-dev
4+
RUN apt-get install -y curl
5+
RUN apt-get install libssl-dev -y
6+
RUN apt-get install tree -y
7+
RUN apt-get install -y --no-install-recommends unzip bash
8+
RUN curl -sSL https://raw.githubusercontent.com/maxwellflitton/surrealdb-backup-cli/main/scripts/install.sh | bash
9+
10+
COPY ./db_snapshots/big_data_snapshot/package/ ./big_data_snapshot/
11+
RUN ./surrealdb_backup unpack -d ./unpacked_data/ -t ./big_data_snapshot/
12+
RUN rm ./unpacked_data/LOCK
13+
RUN curl -sSf https://install.surrealdb.com | sh
14+
15+
EXPOSE 8000
16+
17+
CMD ["surreal", "start", "--bind", "0.0.0.0:8000", "--allow-all", "--user", "root", "--pass", "root", "rocksdb:./unpacked_data"]

tests/integration/async/test_batch.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from typing import List
2+
from unittest import TestCase, main
3+
4+
from surrealdb import SurrealDB, RecordID
5+
from tests.integration.connection_params import TestConnectionParams
6+
import asyncio
7+
import websockets
8+
9+
10+
class TestBatch(TestCase):
11+
12+
def setUp(self) -> None:
13+
self.params = TestConnectionParams()
14+
self.db = SurrealDB(self.params.url)
15+
self.queries: List[str] = []
16+
17+
self.db.connect()
18+
self.db.use(self.params.namespace, self.params.database)
19+
self.db.sign_in("root", "root")
20+
21+
# self.query = """
22+
# CREATE |product:1000000| CONTENT {
23+
# name: rand::enum('Cruiser Hoodie', 'Surreal T-Shirt'),
24+
# colours: [rand::string(10), rand::string(10),],
25+
# price: rand::int(20, 60),
26+
# time: {
27+
# created_at: rand::time(1611847404, 1706455404),
28+
# updated_at: rand::time(1651155804, 1716906204)
29+
# }
30+
# };
31+
# """
32+
# self.db.query(query=self.query)
33+
34+
def tearDown(self) -> None:
35+
pass
36+
37+
def test_batch(self):
38+
print("test_batch")
39+
40+
if __name__ == '__main__':
41+
main()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
# navigate to directory
4+
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
5+
cd $SCRIPTPATH
6+
7+
cd ..
8+
9+
if [ -d "./db_snapshots/big_data_snapshot" ]; then
10+
echo "removing the big data snapshot"
11+
rm -rf ./db_snapshots/big_data_snapshot
12+
fi
13+
14+
dockpack pull -i maxwellflitton/surrealdb-data -d ./db_snapshots/big_data_snapshot
15+
rm ./db_snapshots/big_data_snapshot/package/LOCK
16+
17+
docker build -f ./builds/big_data_dockerfile -t surrealdb-big-data .

0 commit comments

Comments
 (0)