diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000000000000000000000000000000000..98d2d27629c6f62219f1abf4cdf5043b0308e660 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,87 @@ +name: "Build" + +on: ['push', 'pull_request'] + +jobs: + build_wheels: + name: "Build wheels" + runs-on: 'ubuntu-latest' + + steps: + - uses: actions/checkout@v2 + name: "Checkout source repository" + + - uses: actions/setup-python@v2 + name: "Set up Python 3.9" + with: + python-version: '3.9' + + - name: "Install cibuildwheel" + run: | + python3 -m pip install cibuildwheel==1.7.1 + + - name: "Build wheels" + run: | + python3 -m cibuildwheel --output-dir dist + env: + ROCKSDB_VERSION: '6.14.6' + CIBW_MANYLINUX_X86_64_IMAGE: 'manylinux2014' + CIBW_BUILD: 'cp37-manylinux* cp38-manylinux* cp39-manylinux*' + CIBW_SKIP: '*-manylinux_i686' + CIBW_TEST_REQUIRES: '.[test]' + CIBW_TEST_COMMAND: 'rm {project}/rocksdb/tests/__init__.py; pytest {project}/rocksdb/tests' + CIBW_BEFORE_BUILD: | + yum install -y bzip2-devel lz4-devel snappy-devel zlib-devel + pushd /opt + git clone https://github.com/facebook/rocksdb + cd rocksdb + git reset --hard $ROCKSDB_VERSION + CXXFLAGS='-flto -Os -s' PORTABLE=1 make shared_lib -j 4 + make install-shared + popd + + - uses: actions/upload-artifact@v2 + name: "Upload build artifacts" + with: + path: 'dist/*.whl' + + + build_sdist: + name: "Build source distribution" + runs-on: 'ubuntu-latest' + steps: + - uses: actions/checkout@v2 + name: "Checkout source repository" + + - uses: actions/setup-python@v2 + name: "Set up Python 3.9" + with: + python-version: '3.9' + + - name: "Build sdist" + run: | + python3 setup.py sdist + + - uses: actions/upload-artifact@v2 + name: "Upload build artifacts" + with: + path: 'dist/*.tar.gz' + + + upload_pypi: + name: "Upload packages" + needs: ['build_wheels', 'build_sdist'] + runs-on: 'ubuntu-latest' + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') + steps: + - uses: actions/download-artifact@v2 + name: "Download artifacts" + with: + name: 'artifact' + path: 'dist' + + - uses: pypa/gh-action-pypi-publish@master + name: "Publish built packages" + with: + user: '__token__' + password: "${{ secrets.PYPI_API_TOKEN }}" diff --git a/LICENSE.md b/LICENSE similarity index 100% rename from LICENSE.md rename to LICENSE diff --git a/README.rst b/README.rst index 1174f672839751d7bbea99dbab4ab9042eb80c63..b2a51e6a2d98582e260c52ba030741e3d693d49f 100644 --- a/README.rst +++ b/README.rst @@ -1,10 +1,5 @@ -Note -========= -The original pyrocksdb (https://pypi.python.org/pypi/pyrocksdb/0.4) has not been updated for long time. I update pyrocksdb to support the latest rocksdb. Please open issues in github if you have any problem. - -News (2020/09/03 iFA) -========= -Python version which lower than 3.0 is not supported anymore. +python-rocksdb +============== pyrocksdb ========= @@ -13,38 +8,33 @@ Python bindings for RocksDB. See http://python-rocksdb.readthedocs.io/en/latest/ for a more comprehensive install and usage description. -Quick Install +Quick install ------------- -Quick install for debian/ubuntu like linux distributions. - .. code-block:: bash - $ apt-get install build-essential libsnappy-dev zlib1g-dev libbz2-dev libgflags-dev liblz4-dev - $ git clone https://github.com/facebook/rocksdb.git - $ cd rocksdb - $ mkdir build && cd build - $ cmake .. - $ make - $ cd .. - $ export CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}${CPLUS_INCLUDE_PATH:+:}`pwd`/include/ - $ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}${LD_LIBRARY_PATH:+:}`pwd`/build/ - $ export LIBRARY_PATH=${LIBRARY_PATH}${LIBRARY_PATH:+:}`pwd`/build/ - - $ apt-get install python-virtualenv python-dev - $ virtualenv pyrocks_test - $ cd pyrocks_test - $ . bin/active - $ pip install python-rocksdb - - -Quick Usage Guide + $ pip install rocksdb + + +Quick usage guide ----------------- -.. code-block:: pycon +.. code-block:: python >>> import rocksdb - >>> db = rocksdb.DB("test.db", rocksdb.Options(create_if_missing=True)) + >>> db = rocksdb.DB('test.db', rocksdb.Options(create_if_missing=True)) >>> db.put(b'a', b'data') - >>> print db.get(b'a') + >>> print(db.get(b'a')) b'data' + + +Acknowledgements +---------------- + +This project is a fork of `python-rocksdb`_ maintained by `twmht`_, which itself is a fork +of `pyrocksdb`_, that was originally written by `stephan-hof`_. + +.. _python-rocksdb: https://github.com/twmht/python-rocksdb +.. _twmht: https://github.com/twmht +.. _pyrocksdb: https://github.com/stephan-hof/pyrocksdb +.. _stephan-hof: https://github.com/stephan-hof diff --git a/setup.py b/setup.py index 283285cddc5179685c01540d05944a3c955c8ca6..db9e0a7d817b2373ce349712fbad96fb02613d71 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,5 @@ import platform, sys -from setuptools import setup -from setuptools import find_packages -from setuptools import Extension +import setuptools extra_compile_args = [ @@ -14,36 +12,81 @@ extra_compile_args = [ '-fno-rtti', ] + if platform.system() == 'Darwin': extra_compile_args += ['-mmacosx-version-min=10.7', '-stdlib=libc++'] if sys.version_info < (3 , 0): raise Exception("pyRocksDB require Python 3.x") -setup( - name="python-rocksdb", - version='0.7.0', - description="Python bindings for RocksDB", - keywords='rocksdb', - author='Ming Hsuan Tu', - author_email="qrnnis2623891@gmail.com", - url="https://github.com/twmht/python-rocksdb", +def _get_long_description(): + with open('README.rst') as readme_file: + return readme_file.read() + + +setuptools.setup( + name='rocksdb', + version='0.8.0rc2', + description='Python bindings for RocksDB', + long_description=_get_long_description(), + long_description_content_type='text/x-rst', + author='Andrey Martyanov', + author_email='andrey@martyanov.com', + url='https://github.com/martyanov/python-rocksdb', license='BSD License', - setup_requires=['setuptools>=25', 'Cython>=0.20'], - install_requires=['setuptools>=25'], - package_dir={'rocksdb': 'rocksdb'}, - packages=find_packages('.'), - ext_modules=[Extension( - 'rocksdb._rocksdb', - ['rocksdb/_rocksdb.pyx'], - extra_compile_args=extra_compile_args, - language='c++', - libraries=['rocksdb', 'snappy', 'bz2', 'z', 'lz4'], - )], - extras_require={ - "doc": ['sphinx_rtd_theme', 'sphinx'], - "test": ['pytest'], + license_file='LICENSE', + packages=setuptools.find_packages('.'), + package_dir={ + 'rocksdb': 'rocksdb', }, include_package_data=True, + ext_modules=[ + setuptools.Extension( + 'rocksdb._rocksdb', + [ + 'rocksdb/_rocksdb.pyx', + ], + extra_compile_args=extra_compile_args, + language='c++', + libraries=[ + 'rocksdb', + 'snappy', + 'bz2', + 'z', + 'lz4', + ], + ), + ], + setup_requires=[ + 'cython>=0.20', + 'setuptools>=25', + ], + install_requires=[ + 'setuptools>=25', + ], + extras_require={ + 'doc': [ + 'sphinx', + 'sphinx_rtd_theme', + ], + 'test': [ + 'pytest', + ], + }, zip_safe=False, + keywords='rocksdb bindings', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: BSD License', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Topic :: Database', + ], + project_urls={ + 'Bug Reports': 'https://github.com/martyanov/python-rocksdb/issues', + 'Repository': 'https://github.com/martyanov/python-rocksdb', + }, )