Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package caskdb for PyPI #19

Merged
merged 14 commits into from
Jul 5, 2024
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: tests
run: |
pip install .
make test
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test:
lint:
black --check --diff $(FILES_TO_LINT)
flake8 $(FILES_TO_LINT)
mypy --strict $(FILES_TO_LINT)
mypy .
pytype $(FILES_TO_LINT)

coverage:
Expand Down
19 changes: 0 additions & 19 deletions memory_store.py

This file was deleted.

3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[mypy]
exclude = venv|setup.py
strict = True
8 changes: 1 addition & 7 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
black>=22.1.0
coverage>=6.3.2
flake8>=4.0.1
ipdb>=0.13.9
mypy>=0.950
pytype>=2022.4.26
pytest>=7.1.2
-e .[dev]
47 changes: 47 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[metadata]
name = caskdb
version = 0.1.0
description = Disk based Log Structured Hash Table Store
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/avinassh/py-caskdb
author = Avinash Sajjanshetty
author_email = [email protected]
license = MIT
license_file = LICENSE
classifiers =
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: Implementation :: CPython
Typing :: Typed

[options]
packages = find:
python_requires = >=3.8
package_dir = =src

[options.packages.find]
where = ./src

[options.extras_require]
dev =
black>=22.1.0
build>=1.2.1
coverage>=6.3.2
flake8>=4.0.1
ipdb>=0.13.9
mypy>=1.10.1
pytest>=7.1.2
pytype>=2024.4.11
twine>=5.1.1

[options.package_data]
caskdb =
py.typed
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from setuptools import setup

setup()
4 changes: 4 additions & 0 deletions src/caskdb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from caskdb.disk_store import DiskStorage
from caskdb.memory_store import MemoryStorage

__all__ = ["DiskStorage", "MemoryStorage"]
3 changes: 2 additions & 1 deletion disk_store.py → src/caskdb/disk_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
# it also supports dictionary style API too:
disk["hamlet"] = "shakespeare"
"""

import os.path
import time
import typing

from format import KeyEntry, encode_kv, decode_kv, HEADER_SIZE, decode_header
from caskdb.format import KeyEntry, encode_kv, decode_kv, HEADER_SIZE, decode_header

# We use `file.seek` method to move our cursor to certain byte offset for read
# or write operations. The method takes two parameters file.seek(offset, whence).
Expand Down
4 changes: 2 additions & 2 deletions example.py → src/caskdb/example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from memory_store import MemoryStorage
from disk_store import DiskStorage
from caskdb.memory_store import MemoryStorage
from caskdb.disk_store import DiskStorage


def memory_db() -> None:
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions src/caskdb/memory_store.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class MemoryStorage:
def __init__(self) -> None:
self.data: dict[str, str] = {}

def set(self, key: str, value: str) -> None:
self.data[key] = value

def get(self, key: str) -> str:
return self.data.get(key, "")

def close(self) -> None:
return
1 change: 1 addition & 0 deletions src/caskdb/py.typed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Marker file for PEP 561. This package uses inline types.
2 changes: 1 addition & 1 deletion tests/test_disk_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import typing
import unittest

from disk_store import DiskStorage
from caskdb import DiskStorage


class TempStorageFile:
Expand Down
10 changes: 8 additions & 2 deletions tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
import unittest
import uuid

from format import encode_header, decode_header, encode_kv, decode_kv, HEADER_SIZE
from format import KeyEntry
from caskdb.format import (
encode_header,
decode_header,
encode_kv,
decode_kv,
HEADER_SIZE,
)
from caskdb.format import KeyEntry


def get_random_header() -> tuple[int, int, int]:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_memory_store.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from memory_store import MemoryStorage
from caskdb import MemoryStorage


class TestInMemoryCaskDB(unittest.TestCase):
Expand All @@ -15,4 +15,4 @@ def test_invalid_key(self) -> None:

def test_close(self) -> None:
store = MemoryStorage()
self.assertTrue(store.close())
store.close()
Loading