From 569296896c667f1b4054454dd25cdeae43b48804 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl>
Date: Wed, 16 Dec 2020 18:43:16 +0100
Subject: [PATCH] 0.5.1

---
 .dockerignore           |  2 ++
 .gitattributes          |  1 +
 README.md               |  3 +++
 requirements.txt        |  1 -
 setup.py                | 30 +++++++++++++++++++++++-------
 tempsdb/chunks/gzip.pyx |  5 ++---
 tempsdb/database.pyx    |  1 +
 7 files changed, 32 insertions(+), 11 deletions(-)
 create mode 100644 .gitattributes

diff --git a/.dockerignore b/.dockerignore
index 677f967..e7a3e2b 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -4,3 +4,5 @@ docs
 build
 dist
 *.egg-info
+*.c
+*.h
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..dfdb8b7
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+*.sh text eol=lf
diff --git a/README.md b/README.md
index b8bc6fe..8e7db1a 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,9 @@ Then copy your resulting wheel and install it via pip on the target system.
 ## v0.5.1
 
 * added `VarlenSeries.close_chunks`
+* `Database.sync` will now return 0
+* indexed-gzip proved to be a poor choice, dropped
+* `setup.py` fixed
 
 ## v0.5
 
diff --git a/requirements.txt b/requirements.txt
index 0f106c9..08bdec7 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,6 +2,5 @@ satella
 ujson
 snakehouse>=1.2.3
 six
-indexed_gzip
 nose2
 coverage
diff --git a/setup.py b/setup.py
index bb898a3..23daadd 100644
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,11 @@
 import os
 import typing as tp
 
+from Cython.Build import cythonize
 from satella.files import find_files
 from distutils.core import setup
 
+from setuptools import find_packages, Extension
 from snakehouse import Multibuild, build, monkey_patch_parallel_compilation
 
 
@@ -20,15 +22,29 @@ if 'CI' in os.environ:
     ext_kwargs['define_macros'] = [("CYTHON_TRACE_NOGIL", "1")]
     directives.update(profile=True, linetrace=True, embedsignature=True)
     cythonize_kwargs['gdb_debug'] = True
-
+    # extensions = [
+    #     Extension('tempsdb.database', ['tempsdb/database.pyx']),
+    #     Extension('tempsdb.database', ['tempsdb/database.pyx']),
+    #     Extension('tempsdb.exceptions', ['tempsdb/exceptions.pyx']),
+    #     Extension('tempsdb.iterators', ['tempsdb/iterators.pyx']),
+    #     Extension('tempsdb.series', ['tempsdb/series.pyx']),
+    #     Extension('tempsdb.varlen', ['tempsdb/varlen.pyx']),
+    #     Extension('tempsdb.chunks.gzip', ['tempsdb/chunks/gzip.pyx']),
+    #     Extension('tempsdb.chunks.direct', ['tempsdb/chunks/direct.pyx']),
+    #     Extension('tempsdb.chunks.normal', ['tempsdb/chunks/normal.pyx']),
+    #     Extension('tempsdb.chunks.maker', ['tempsdb/chunks/maker.pyx']),
+    #     Extension('tempsdb.chunks.base', ['tempsdb/chunks/base.pyx']),
+    # ]
+    # ext_modules = cythonize(extensions, compiler_directives=directives)
+ext_modules = build([Multibuild('tempsdb', find_pyx('tempsdb'), **ext_kwargs), ],
+                     compiler_directives=directives,
+                     **cythonize_kwargs)
 
 setup(name='tempsdb',
-      version='0.5.1a2',
-      packages=['tempsdb'],
-      install_requires=['satella>=2.14.24', 'ujson', 'indexed_gzip'],
-      ext_modules=build([Multibuild('tempsdb', find_pyx('tempsdb'), **ext_kwargs), ],
-                        compiler_directives=directives,
-                        **cythonize_kwargs),
+      version='0.5.1',
+      packages=find_packages(include=['tempsdb', 'tempsdb.*']),
+      install_requires=['satella>=2.14.24', 'ujson'],
+      ext_modules=ext_modules,
       python_requires='!=2.7.*,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*',
       test_suite="tests",
       zip_safe=False
diff --git a/tempsdb/chunks/gzip.pyx b/tempsdb/chunks/gzip.pyx
index 0cca5b7..5531909 100644
--- a/tempsdb/chunks/gzip.pyx
+++ b/tempsdb/chunks/gzip.pyx
@@ -1,5 +1,4 @@
 import gzip
-import indexed_gzip
 import threading
 
 
@@ -7,8 +6,8 @@ cdef class ReadWriteGzipFile:
     def __init__(self, path: str, compresslevel: int = gzip._COMPRESS_LEVEL_FAST):
         self.path = path
         self.compress_level = compresslevel
-        self.ro_file = indexed_gzip.IndexedGzipFile(path)
         self.rw_file = gzip.GzipFile(path, 'ab', compresslevel=self.compress_level)
+        self.ro_file = gzip.GzipFile(path, 'rb')
         self.pointer = 0
         self.lock = threading.RLock()
         self.needs_flush_before_read = False
@@ -19,8 +18,8 @@ cdef class ReadWriteGzipFile:
         self.size = self.pointer
 
     cpdef int flush(self) except -1:
-        self.rw_file.flush()
         self.ro_file.close()
+        self.rw_file.flush()
         self.ro_file = gzip.GzipFile(self.path, 'rb')
         self.pointer = 0
         self.needs_flush_before_read = False
diff --git a/tempsdb/database.pyx b/tempsdb/database.pyx
index c3969f9..62c340c 100644
--- a/tempsdb/database.pyx
+++ b/tempsdb/database.pyx
@@ -194,6 +194,7 @@ cdef class Database:
         for series in self.open_series.values():
             if not series.closed:
                 series.sync()
+        return 0
 
     cpdef list get_all_normal_series(self):
         """
-- 
GitLab