Skip to content

Commit c21dd64

Browse files
committed
RDBC-790 Embed ravendb server data
1 parent 607dea0 commit c21dd64

File tree

3 files changed

+53
-4
lines changed

3 files changed

+53
-4
lines changed

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
recursive-include ravendb_embedded/RavenDBServer *
1+
graft ravendb-server
22
include README.rst

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
setuptools~=68.2.0
22
ravendb>=5.2.4
3-
cryptography~=42.0.0
3+
cryptography~=42.0.0
4+
tqdm~=4.66.1

setup.py

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,57 @@
11
from setuptools import setup, find_packages
2+
from setuptools.command.install import install
3+
from setuptools.command.develop import develop
4+
import os
5+
import urllib.request
6+
from tqdm import tqdm
27

8+
# Modify the RavenDB version and download URL accordingly
9+
RAVENDB_VERSION = "6.0.0"
10+
RAVENDB_DOWNLOAD_URL = f"https://www.nuget.org/api/v2/package/RavenDB.Embedded/{RAVENDB_VERSION}"
11+
RAVENDB_DOWNLOAD_FOLDER = "downloaded_ravendb"
12+
RAVENDB_FULL_DOWNLOAD_PATH = os.path.join(RAVENDB_DOWNLOAD_FOLDER, "ravendb-server")
13+
14+
15+
# Function to download RavenDB with progress bar
16+
def download_ravendb_with_progress():
17+
os.makedirs(RAVENDB_DOWNLOAD_FOLDER, exist_ok=True)
18+
19+
response = urllib.request.urlopen(RAVENDB_DOWNLOAD_URL)
20+
total_size = int(response.headers.get("content-length", 0))
21+
block_size = 1024 # Adjust the block size as needed
22+
progress_bar = tqdm(total=total_size, unit="B", unit_scale=True)
23+
24+
with open(RAVENDB_FULL_DOWNLOAD_PATH, "wb") as file, progress_bar:
25+
while True:
26+
buffer = response.read(block_size)
27+
if not buffer:
28+
break
29+
30+
file.write(buffer)
31+
progress_bar.update(len(buffer))
32+
33+
34+
# Custom installation command to download RavenDB before installation
35+
class CustomInstall(install):
36+
def run(self):
37+
download_ravendb_with_progress()
38+
super().run()
39+
40+
41+
# Custom develop command to download RavenDB before development
42+
class CustomDevelop(develop):
43+
def run(self):
44+
download_ravendb_with_progress()
45+
super().run()
46+
47+
48+
# Setup configuration
349
setup(
450
name="ravendb-embedded",
551
packages=find_packages(),
652
long_description=open("README.rst").read(),
7-
version="6.0.0",
8-
description="RavenDB Embedded library to run ravendb in embedded way",
53+
version=RAVENDB_VERSION,
54+
description="RavenDB Embedded library to run RavenDB in an embedded way",
955
author="RavenDB",
1056
author_email="[email protected]",
1157
url="https://github.com/ravendb/ravendb-python-embedded",
@@ -14,4 +60,6 @@
1460
install_requires=[],
1561
include_package_data=True,
1662
zip_safe=False,
63+
package_data={"": ["ravendb-server/*"]},
64+
cmdclass={"install": CustomInstall, "develop": CustomDevelop},
1765
)

0 commit comments

Comments
 (0)