From ad6afabe8edf25560a63ad8a8aee46156b5e3c69 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Mon, 31 Oct 2022 16:48:02 +0300 Subject: [PATCH 01/18] make: remove obsolete build commands Part of #198 --- Makefile | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Makefile b/Makefile index 5d9f6382..ec00e7fa 100644 --- a/Makefile +++ b/Makefile @@ -11,11 +11,5 @@ cov-html: python -m coverage html -i cov-report: python -m coverage report -dist: - python setup.py sdist --format=gztar,bztar,zip -dist-upload: - python setup.py sdist --format=gztar,bztar,zip upload -dist-upload-2: - python setup.py sdist --format=ztar upload docs: python setup.py build_sphinx From 8604fbb7b5341f8e8930342f609a2175d2cb2616 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Mon, 7 Nov 2022 15:56:54 +0300 Subject: [PATCH 02/18] python: use explicit binaries version Specify explicit Python 3 python3 and pip3 binaries everywhere to make commands more portable. Part of #198 --- .github/workflows/reusable_testing.yml | 4 ++-- .github/workflows/testing.yml | 26 +++++++++++++------------- Makefile | 12 ++++++------ README.rst | 8 ++++---- docs/source/index.rst | 2 +- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/reusable_testing.yml b/.github/workflows/reusable_testing.yml index c9528f8b..cc64e383 100644 --- a/.github/workflows/reusable_testing.yml +++ b/.github/workflows/reusable_testing.yml @@ -34,9 +34,9 @@ jobs: python-version: 3.7 - name: Install connector requirements - run: pip install -r requirements.txt + run: pip3 install -r requirements.txt - name: Install test requirements - run: pip install -r requirements-test.txt + run: pip3 install -r requirements-test.txt - run: make test diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 271a8c51..ff93e4b5 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -76,14 +76,14 @@ jobs: # install of the newer msgpack package by overwriting it with sed. if: matrix.msgpack-deps != '' run: | - pip install ${{ matrix.msgpack-deps }} + pip3 install ${{ matrix.msgpack-deps }} sed -i -e "s/^msgpack.*$/${{ matrix.msgpack-deps }}/" requirements.txt - name: Install package requirements - run: pip install -r requirements.txt + run: pip3 install -r requirements.txt - name: Install test requirements - run: pip install -r requirements-test.txt + run: pip3 install -r requirements-test.txt - name: Run tests run: make test @@ -136,10 +136,10 @@ jobs: python-version: ${{ matrix.python }} - name: Install package requirements - run: pip install -r requirements.txt + run: pip3 install -r requirements.txt - name: Install test requirements - run: pip install -r requirements-test.txt + run: pip3 install -r requirements-test.txt - name: Run tests run: | @@ -191,13 +191,13 @@ jobs: python-version: ${{ matrix.python }} - name: Install the package with pip - run: pip install git+$GITHUB_SERVER_URL/$GITHUB_REPOSITORY@$GITHUB_REF_NAME + run: pip3 install git+$GITHUB_SERVER_URL/$GITHUB_REPOSITORY@$GITHUB_REF_NAME - name: Install test requirements - run: pip install -r requirements-test.txt + run: pip3 install -r requirements-test.txt - name: Run tests - run: python -m unittest discover -v + run: python3 -m unittest discover -v env: TEST_PURE_INSTALL: true @@ -235,10 +235,10 @@ jobs: python-version: ${{ matrix.python }} - name: Install connector requirements - run: pip install -r requirements.txt + run: pip3 install -r requirements.txt - name: Install test requirements - run: pip install -r requirements-test.txt + run: pip3 install -r requirements-test.txt - name: Setup WSL for tarantool uses: Vampire/setup-wsl@v1 @@ -322,10 +322,10 @@ jobs: python-version: ${{ matrix.python }} - name: Install the package with pip - run: pip install git+$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY@$env:GITHUB_REF_NAME + run: pip3 install git+$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY@$env:GITHUB_REF_NAME - name: Install test requirements - run: pip install -r requirements-test.txt + run: pip3 install -r requirements-test.txt - name: Setup WSL for tarantool uses: Vampire/setup-wsl@v1 @@ -351,7 +351,7 @@ jobs: REMOTE_TARANTOOL_HOST: localhost REMOTE_TARANTOOL_CONSOLE_PORT: 3302 TEST_PURE_INSTALL: true - run: python -m unittest discover -v + run: python3 -m unittest discover -v - name: Stop test tarantool instance if: ${{ always() }} diff --git a/Makefile b/Makefile index ec00e7fa..c63b2cee 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,15 @@ .PHONY: install test docs install: - pip install --editable . + pip3 install --editable . test: - python setup.py test + python3 setup.py test testdata: cd ./test/data/; ./generate.sh coverage: - python -m coverage run -p --source=. setup.py test + python3 -m coverage run -p --source=. setup.py test cov-html: - python -m coverage html -i + python3 -m coverage html -i cov-report: - python -m coverage report + python3 -m coverage report docs: - python setup.py build_sphinx + python3 setup.py build_sphinx diff --git a/README.rst b/README.rst index 44e14b0c..fa08ffa4 100644 --- a/README.rst +++ b/README.rst @@ -24,7 +24,7 @@ The recommended way to install the ``tarantool`` package is using ``pip``. .. code-block:: bash - $ pip install tarantool + $ pip3 install tarantool ZIP archive ^^^^^^^^^^^ @@ -42,7 +42,7 @@ You can also install the development version of the package using ``pip``. .. code-block:: bash - $ pip install git+https://github.com/tarantool/tarantool-python.git@master + $ pip3 install git+https://github.com/tarantool/tarantool-python.git@master -------------------------------------------------------------------------------- @@ -112,7 +112,7 @@ To build documentation, first you must install its build requirements: .. code-block:: bash - $ pip install -r docs/requirements.txt + $ pip3 install -r docs/requirements.txt Then run @@ -124,7 +124,7 @@ You may host local documentation server with .. code-block:: bash - $ python -m http.server --directory build/sphinx/html + $ python3 -m http.server --directory build/sphinx/html Open ``localhost:8000`` in your browser to read the docs. diff --git a/docs/source/index.rst b/docs/source/index.rst index 5e5a04ca..7f094b7e 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -12,7 +12,7 @@ Install Tarantool Python connector with ``pip`` (`PyPI`_ page): .. code-block:: bash - $ pip install tarantool + $ pip3 install tarantool Source code is available on `GitHub`_. From 2424c8298db7af1047134f69bfaa8740bde1b3e0 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Mon, 7 Nov 2022 16:54:17 +0300 Subject: [PATCH 03/18] make: separate phony for each target Part of #198 --- Makefile | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c63b2cee..22559da1 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,29 @@ -.PHONY: install test docs +.PHONY: install install: pip3 install --editable . + + +.PHONY: test test: python3 setup.py test + +.PHONY: testdata testdata: cd ./test/data/; ./generate.sh + +.PHONY: coverage coverage: python3 -m coverage run -p --source=. setup.py test + +.PHONY: cov-html cov-html: python3 -m coverage html -i + +.PHONY: cov-report cov-report: python3 -m coverage report + + +.PHONY: docs docs: python3 setup.py build_sphinx From 561521160d2135401405342f5b80295719976660 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Wed, 19 Oct 2022 17:13:04 +0300 Subject: [PATCH 04/18] ci: remove source code with script Remove connector source code for pure install tests with Python script. Python was chosen since it would work both on Windows and Linux. Part of #198 --- .github/scripts/remove_source_code.py | 14 ++++++++++++++ .github/workflows/testing.yml | 21 ++++++--------------- 2 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 .github/scripts/remove_source_code.py diff --git a/.github/scripts/remove_source_code.py b/.github/scripts/remove_source_code.py new file mode 100644 index 00000000..d0dfdef7 --- /dev/null +++ b/.github/scripts/remove_source_code.py @@ -0,0 +1,14 @@ +import os, shutil + +required_paths = ['.git', '.github', 'test', 'requirements-test.txt', 'Makefile'] + +for path in os.listdir(): + if path in required_paths: + continue + + if os.path.isfile(path) or os.path.islink(path): + os.remove(path) + elif os.path.isdir(path): + shutil.rmtree(path) + else: + raise ValueError(f"{path} is not a file, link or dir") diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index ff93e4b5..b23890c7 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -175,11 +175,6 @@ jobs: - name: Clone the connector repo uses: actions/checkout@v2 - - name: Remove connector source code - run: | - rm -rf tarantool - rm setup.py - - name: Install tarantool ${{ matrix.tarantool }} uses: tarantool/setup-tarantool@v1 with: @@ -190,6 +185,9 @@ jobs: with: python-version: ${{ matrix.python }} + - name: Remove connector source code + run: python3 .github/scripts/remove_source_code.py + - name: Install the package with pip run: pip3 install git+$GITHUB_SERVER_URL/$GITHUB_REPOSITORY@$GITHUB_REF_NAME @@ -306,21 +304,14 @@ jobs: - name: Clone the connector repo uses: actions/checkout@v2 - - name: Remove connector source code (main folder) - uses: JesseTG/rm@v1.0.3 - with: - path: tarantool - - - name: Remove connector source code (setup.py) - uses: JesseTG/rm@v1.0.3 - with: - path: setup.py - - name: Setup Python for tests uses: actions/setup-python@v2 with: python-version: ${{ matrix.python }} + - name: Remove connector source code + run: python3 .github/scripts/remove_source_code.py + - name: Install the package with pip run: pip3 install git+$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY@$env:GITHUB_REF_NAME From aae66822cf3114aa6aea4a3b3ecea4835a08801c Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Mon, 7 Nov 2022 16:56:21 +0300 Subject: [PATCH 05/18] make: target for test pure install Part of #198 --- .github/workflows/testing.yml | 7 ++----- Makefile | 4 ++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index b23890c7..697aed46 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -195,9 +195,7 @@ jobs: run: pip3 install -r requirements-test.txt - name: Run tests - run: python3 -m unittest discover -v - env: - TEST_PURE_INSTALL: true + run: make test-pure-install run_tests_ce_windows: # We want to run on external PRs, but not on our own internal @@ -341,8 +339,7 @@ jobs: env: REMOTE_TARANTOOL_HOST: localhost REMOTE_TARANTOOL_CONSOLE_PORT: 3302 - TEST_PURE_INSTALL: true - run: python3 -m unittest discover -v + run: make test-pure-install - name: Stop test tarantool instance if: ${{ always() }} diff --git a/Makefile b/Makefile index 22559da1..374aed80 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,10 @@ install: test: python3 setup.py test +.PHONY: test-pure-install +test-pure-install: + TEST_PURE_INSTALL=true python3 -m unittest discover -v + .PHONY: testdata testdata: cd ./test/data/; ./generate.sh From 790823bc6f922763f9112752ea8342610d2765b3 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Tue, 8 Nov 2022 09:53:13 +0300 Subject: [PATCH 06/18] setup: update description Part of #198 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 0d1d7e20..1c565e79 100755 --- a/setup.py +++ b/setup.py @@ -88,14 +88,14 @@ def find_version(*file_paths): author_email="admin@tarantool.org", url="https://github.com/tarantool/tarantool-python", license="BSD", - description="Python client library for Tarantool 1.6 Database", + description="Python client library for Tarantool", long_description=read('README.rst'), long_description_content_type='text/x-rst', classifiers=[ "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", - "Programming Language :: Python", + "Programming Language :: Python :: 3 :: Only", "Topic :: Database :: Front-Ends" ], cmdclass=cmdclass, From 7569ce0a15117eedc763aced4e60ed0897bb492c Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Fri, 28 Oct 2022 17:46:49 +0300 Subject: [PATCH 07/18] setup: remove msgpack version dependency The only reason of this dependency is various vulnerability fixes. We decided not to enforce the user on this. Follows #223, part of #198 --- CHANGELOG.md | 1 + requirements.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e95ec9b..e752bf59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -198,6 +198,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 functions (PR #252). - Extract tarantool.Interval encode and decode to external functions (PR #252). +- Do not enforce msgpack version (#198). ### Fixed - Package build (#238). diff --git a/requirements.txt b/requirements.txt index 5885f0e8..aa4406ce 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -msgpack>=1.0.4 +msgpack pandas pytz dataclasses; python_version <= '3.6' From 8aecca6ebb7d994914ed189d4db2646bb0016150 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Thu, 20 Oct 2022 10:06:17 +0300 Subject: [PATCH 08/18] cd: pack pip package Pack source code and wheel file with Github Actions. Result is stored as artifact. Part of #198 --- .github/workflows/packing.yml | 55 +++++++++++++++++++++++++++++++++++ .gitignore | 1 + CHANGELOG.md | 1 + Makefile | 16 ++++++++++ 4 files changed, 73 insertions(+) create mode 100644 .github/workflows/packing.yml diff --git a/.github/workflows/packing.yml b/.github/workflows/packing.yml new file mode 100644 index 00000000..9a7b1edc --- /dev/null +++ b/.github/workflows/packing.yml @@ -0,0 +1,55 @@ +name: packing + +on: + push: + branches: + - master + tags: + - '*' + pull_request: + pull_request_target: + types: [labeled] + +jobs: + pack_pip: + # We want to run on external PRs, but not on our own internal + # PRs as they'll be run by the push to the branch. + # + # The main trick is described here: + # https://github.com/Dart-Code/Dart-Code/pull/2375 + if: (github.event_name == 'push') || + (github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name != github.repository) + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + steps: + - name: Clone the connector repo + uses: actions/checkout@v3 + # Checkout all tags for correct version computation. + with: + fetch-depth: 0 + + - name: Setup Python and basic packing tools + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install tools for packing and verification + run: pip3 install wheel twine + + - name: Pack source and binary files + run: make pip-dist + + - name: Verify the package + run: make pip-dist-check + + - name: Archive pip artifacts + uses: actions/upload-artifact@v3 + with: + name: pip_dist + path: pip_dist + retention-days: 1 + if-no-files-found: error diff --git a/.gitignore b/.gitignore index a27a5f42..51b36f6d 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ sophia venv/* tarantool/version.py +pip_dist diff --git a/CHANGELOG.md b/CHANGELOG.md index e752bf59..2f17c03b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -185,6 +185,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 always be equal to initialization `timestamp`. - Support iproto feature push (#201). +- Pack pip package with GitHub Actions (#198). ### Changed - Bump msgpack requirement to 1.0.4 (PR #223). diff --git a/Makefile b/Makefile index 374aed80..94bb8d8a 100644 --- a/Makefile +++ b/Makefile @@ -31,3 +31,19 @@ cov-report: .PHONY: docs docs: python3 setup.py build_sphinx + + +.PHONY: pip-sdist +pip-sdist: + python3 setup.py sdist --dist-dir=pip_dist + +.PHONY: pip-bdist +pip-bdist: + python3 setup.py bdist_wheel --dist-dir=pip_dist + +.PHONY: pip-dist +pip-dist: pip-sdist pip-bdist + +.PHONY: pip-dist-check +pip-dist-check: + twine check pip_dist/* From 8cb948db162355d5bee05d627958b25dbdbd4983 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Thu, 20 Oct 2022 10:45:29 +0300 Subject: [PATCH 09/18] ci: run tests with pip package Part of #198 --- .github/workflows/packing.yml | 121 ++++++++++++++++++++++++++++++++++ .github/workflows/testing.yml | 4 +- 2 files changed, 123 insertions(+), 2 deletions(-) diff --git a/.github/workflows/packing.yml b/.github/workflows/packing.yml index 9a7b1edc..e04eaf2e 100644 --- a/.github/workflows/packing.yml +++ b/.github/workflows/packing.yml @@ -53,3 +53,124 @@ jobs: path: pip_dist retention-days: 1 if-no-files-found: error + + run_tests_pip_package_linux: + needs: pack_pip + + # We want to run on external PRs, but not on our own internal + # PRs as they'll be run by the push to the branch. + # + # The main trick is described here: + # https://github.com/Dart-Code/Dart-Code/pull/2375 + if: (github.event_name == 'push') || + (github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name != github.repository) + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + steps: + - name: Clone the connector repo + uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Remove connector source code + run: python3 .github/scripts/remove_source_code.py + + - name: Install tarantool + uses: tarantool/setup-tarantool@v1 + with: + tarantool-version: '2.10' + + - name: Download pip package artifacts + uses: actions/download-artifact@v3 + with: + name: pip_dist + path: pip_dist + + - name: Install the package from pip artifacts + run: pip3 install pip_dist/*.whl + + - name: Install test requirements + run: pip3 install -r requirements-test.txt + + - name: Run tests + run: make test-pure-install + + run_tests_pip_package_windows: + needs: pack_pip + + # We want to run on external PRs, but not on our own internal + # PRs as they'll be run by the push to the branch. + # + # The main trick is described here: + # https://github.com/Dart-Code/Dart-Code/pull/2375 + if: (github.event_name == 'push') || + (github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name != github.repository) + + runs-on: windows-latest + + strategy: + fail-fast: false + + steps: + - name: Clone the connector repo + uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Remove connector source code + run: python3 .github/scripts/remove_source_code.py + + - name: Download pip package artifacts + uses: actions/download-artifact@v3 + with: + name: pip_dist + path: pip_dist + + - name: Install the package from pip artifacts + run: pip3 install (gci ./pip_dist *.whl).fullname + + - name: Install test requirements + run: pip3 install -r requirements-test.txt + + - name: Setup WSL for tarantool + uses: Vampire/setup-wsl@v1 + with: + distribution: Ubuntu-20.04 + + - name: Install tarantool + shell: wsl-bash_Ubuntu-20.04 {0} + run: | + curl -L https://tarantool.io/release/2/installer.sh | bash -s + sudo apt install -y tarantool tarantool-dev + + - name: Setup test tarantool instance + shell: wsl-bash_Ubuntu-20.04 {0} + run: | + rm -f ./tarantool.pid ./tarantool.log + TNT_PID=$(tarantool ./test/suites/lib/tarantool_python_ci.lua > tarantool.log 2>&1 & echo $!) + touch tarantool.pid + echo $TNT_PID > ./tarantool.pid + + - name: Run tests + env: + REMOTE_TARANTOOL_HOST: localhost + REMOTE_TARANTOOL_CONSOLE_PORT: 3302 + run: make test-pure-install + + - name: Stop test tarantool instance + if: ${{ always() }} + shell: wsl-bash_Ubuntu-20.04 {0} + run: | + cat tarantool.log || true + kill $(cat tarantool.pid) || true diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 697aed46..72b90c88 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -148,7 +148,7 @@ jobs: env: TEST_TNT_SSL: ${{ matrix.tarantool == '2.10.0-1-gfa775b383-r486-linux-x86_64' }} - run_tests_with_install_linux: + run_tests_pip_branch_install_linux: # We want to run on external PRs, but not on our own internal # PRs as they'll be run by the push to the branch. # @@ -276,7 +276,7 @@ jobs: cat tarantool.log || true kill $(cat tarantool.pid) || true - run_tests_with_install_windows: + run_tests_pip_branch_install_windows: # We want to run on external PRs, but not on our own internal # PRs as they'll be run by the push to the branch. # From 5d604bece58595829c4adb37765be397398a421e Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Mon, 7 Nov 2022 17:38:42 +0300 Subject: [PATCH 10/18] cd: publish pip package Publish pip package on tag. To test, comment "run only on tags" condition, change PYPI_REPO to testpypi and use ${{ secrets.TEST_PYPI_TOKEN }} as PYPI_TOKEN. You also need to remove 5dfdae5208256acf247ee27dbff52d23ca14185a commit changes about scm version and set some constant version: using local version identifiers [1] is not allowed by test.pypi.org. 1. https://peps.python.org/pep-0440/ Part of #198 --- .github/workflows/packing.yml | 36 +++++++++++++++++++++++++++++++++++ CHANGELOG.md | 1 + 2 files changed, 37 insertions(+) diff --git a/.github/workflows/packing.yml b/.github/workflows/packing.yml index e04eaf2e..63ead420 100644 --- a/.github/workflows/packing.yml +++ b/.github/workflows/packing.yml @@ -174,3 +174,39 @@ jobs: run: | cat tarantool.log || true kill $(cat tarantool.pid) || true + + publish_pip: + if: startsWith(github.ref, 'refs/tags') + + needs: + - run_tests_pip_package_linux + - run_tests_pip_package_windows + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + steps: + - name: Clone the connector repo + uses: actions/checkout@v3 + + - name: Setup Python and basic packing tools + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install tools for package publishing + run: pip3 install twine + + - name: Download pip package artifacts + uses: actions/download-artifact@v3 + with: + name: pip_dist + path: pip_dist + + - name: Publish artifacts + run: twine upload -r $PYPI_REPO -u __token__ -p $PYPI_TOKEN pip_dist/* + env: + PYPI_REPO: pypi + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f17c03b..4fd6e94a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -186,6 +186,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support iproto feature push (#201). - Pack pip package with GitHub Actions (#198). +- Publish pip package with GitHub Actions (#198). ### Changed - Bump msgpack requirement to 1.0.4 (PR #223). From 9a328660959f20a276f009da0082ef6439254810 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Tue, 8 Nov 2022 11:47:18 +0300 Subject: [PATCH 11/18] cd: pack RPM package New RPM spec is based on RHEL RPM guide for Python packages [1] merged with results of `python3 setup.py bdist_rpm --spec-only`. Beware that RPM name is changed based on recommendations for all mainstream distributives (for example, see [2]). Binary RPM is named python3-tarantool and source RPM is named python-tarantool. Before the patch they both were called tarantool-python (even though there wasn't new RPM releases since 0.6.5). RPM is suitable for distributives with Python 3.7 or newer. See [3] about pre-Python 3.7 systems support. 1. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/installing_and_using_dynamic_programming_languages/assembly_packaging-python-3-rpms_installing-and-using-dynamic-programming-languages 2. https://fedoraproject.org/wiki/Packaging:Naming?rd=Packaging:NamingGuidelines#Python_source_package_naming 3. https://github.com/tarantool/tarantool-python/issues/257 Part of #164, #198 --- .github/workflows/packing.yml | 65 ++++++++++++++++++ .gitignore | 10 +++ CHANGELOG.md | 1 + Makefile | 13 ++++ rpm/SPECS/python-tarantool.spec | 61 +++++++++++++++++ rpm/tarantool-python.spec | 117 -------------------------------- 6 files changed, 150 insertions(+), 117 deletions(-) create mode 100644 rpm/SPECS/python-tarantool.spec delete mode 100644 rpm/tarantool-python.spec diff --git a/.github/workflows/packing.yml b/.github/workflows/packing.yml index 63ead420..082d90d7 100644 --- a/.github/workflows/packing.yml +++ b/.github/workflows/packing.yml @@ -210,3 +210,68 @@ jobs: env: PYPI_REPO: pypi PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + + pack_rpm: + # We want to run on external PRs, but not on our own internal + # PRs as they'll be run by the push to the branch. + # + # The main trick is described here: + # https://github.com/Dart-Code/Dart-Code/pull/2375 + if: (github.event_name == 'push') || + (github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name != github.repository) + runs-on: ubuntu-latest + + container: + image: ${{ matrix.target.os }}:${{ matrix.target.dist }} + + strategy: + fail-fast: false + + matrix: + target: + - os: fedora + dist: '34' + - os: fedora + dist: '35' + - os: fedora + dist: '36' + + steps: + - name: Bump git version + # Fails to compute package version inside docker otherwise: + # https://github.com/actions/runner/issues/2033 + run: dnf install -y git + + - name: Clone the connector repo + uses: actions/checkout@v3 + # Checkout all tags for correct version computation. + with: + fetch-depth: 0 + + - name: Set ownership + # Fails to compute package version inside docker otherwise: + # https://github.com/actions/runner/issues/2033 + run: chown -R $(id -u):$(id -g) $PWD + + - name: Setup Python and various packing tools + run: dnf install -y python3 python3-libs python3-pip python3-setuptools python3-wheel + + - name: Install RPM packing tools + run: | + dnf install -y gcc make coreutils diffutils patch + dnf install -y rpm-build rpm-devel rpmlint rpmdevtools + + - name: Pack source and binary RPM + run: make rpm-dist + + - name: Verify the package + run: make rpm-dist-check + + - name: Archive RPM artifacts + uses: actions/upload-artifact@v3 + with: + name: rpm_dist_${{ matrix.target.os }}_${{ matrix.target.dist }} + path: rpm_dist + retention-days: 1 + if-no-files-found: error diff --git a/.gitignore b/.gitignore index 51b36f6d..3392efa8 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,13 @@ venv/* tarantool/version.py pip_dist + +# Cannot ignore a directory and negate a single file +# https://www.atlassian.com/git/tutorials/saving-changes/gitignore +rpm/SOURCES +rpm/SRPMS +rpm/BUILDROOT +rpm/BUILD +rpm/RPMS + +rpm_dist diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fd6e94a..bc960947 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -187,6 +187,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support iproto feature push (#201). - Pack pip package with GitHub Actions (#198). - Publish pip package with GitHub Actions (#198). +- Pack RPM package with GitHub Actions (#164, #198). ### Changed - Bump msgpack requirement to 1.0.4 (PR #223). diff --git a/Makefile b/Makefile index 94bb8d8a..58752456 100644 --- a/Makefile +++ b/Makefile @@ -47,3 +47,16 @@ pip-dist: pip-sdist pip-bdist .PHONY: pip-dist-check pip-dist-check: twine check pip_dist/* + + +.PHONY: rpm-dist +rpm-dist: + python3 setup.py sdist --dist-dir=rpm/SOURCES + rpmbuild -ba --define "_topdir `pwd`/rpm" rpm/SPECS/python-tarantool.spec + mkdir -p rpm_dist + mv rpm/SRPMS/*.rpm -t rpm_dist + mv rpm/RPMS/noarch/*.rpm -t rpm_dist + +.PHONY: rpm-dist-check +rpm-dist-check: + rpm -K --nosignature rpm_dist/*.rpm diff --git a/rpm/SPECS/python-tarantool.spec b/rpm/SPECS/python-tarantool.spec new file mode 100644 index 00000000..b1dae43d --- /dev/null +++ b/rpm/SPECS/python-tarantool.spec @@ -0,0 +1,61 @@ +# Based on https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/installing_and_using_dynamic_programming_languages/assembly_packaging-python-3-rpms_installing-and-using-dynamic-programming-languages +# merged with python3 setup.py bdist_rpm --spec-only result. + +%define srcname tarantool +%define version %(python3 setup.py --version) + +Name: python-%{srcname} +Version: %{version} +Release: 1%{?dist} +Summary: Python client library for Tarantool + +License: BSD +Group: Development/Libraries +URL: https://github.com/tarantool/tarantool-python + +BuildArch: noarch +Source: %{srcname}-%{version}.tar.gz +Vendor: tarantool-python AUTHORS + +BuildRequires: python3-setuptools +BuildRequires: python3-wheel + +%global _description %{expand: +Python client library for Tarantool.} + +%description %_description + + +%package -n python3-%{srcname} + +Requires: python3-msgpack +Requires: python3-pandas +Requires: python3-pytz + +Summary: %{summary} + +Obsoletes: tarantool-python <= 0.9.0 + +%description -n python3-%{srcname} %_description + + +%prep +%setup -n %{srcname}-%{version} + + +%build +python3 setup.py build + + +%install +python3 setup.py install --single-version-externally-managed -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES + + +%clean +rm -rf $RPM_BUILD_ROOT + + +%files -n python3-%{srcname} -f INSTALLED_FILES + + +%defattr(-,root,root) diff --git a/rpm/tarantool-python.spec b/rpm/tarantool-python.spec deleted file mode 100644 index 2b9e6431..00000000 --- a/rpm/tarantool-python.spec +++ /dev/null @@ -1,117 +0,0 @@ -Summary: Python client library for Tarantool Database -Name: tarantool-python -Version: 0.9.0 -Release: 1%{?dist} -Source0: tarantool-python-%{version}.tar.gz -License: BSD -Group: Development/Libraries -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot -Prefix: %{_prefix} -BuildArch: noarch -Vendor: Konstantin Cherkasoff -Requires: python-msgpack -Url: https://github.com/tarantool/tarantool-python -BuildRequires: python-setuptools -%description -Python driver for Tarantool 1.6 -=============================== - -This package is a pure-python client library for `Tarantool`_. - -`Documentation`_ | `Downloads`_ | `PyPI`_ | `GitHub`_ | `Issue tracker`_ - -.. _`Documentation`: http://tarantool-python.readthedocs.org/en/latest/ -.. _`Downloads`: http://pypi.python.org/pypi/tarantool#downloads -.. _`PyPI`: http://pypi.python.org/pypi/tarantool -.. _`GitHub`: https://github.com/tarantool/tarantool-python -.. _`Issue tracker`: https://github.com/tarantool/tarantool-python/issues - -.. image:: https://travis-ci.org/tarantool/tarantool-python.svg?branch=master - :target: https://travis-ci.org/tarantool/tarantool-python - -Download and Install --------------------- - -The recommended way to install ``tarantool`` package is using PIP -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -For Tarantool version < 1.6.0 you must get ``0.3.*`` connector version:: - - $ pip install tarantool\<0.4 - -For later Tarantool use version ``0.5.*`` connector version:: - - $ pip install tarantool\>0.4 - -You can also download zip archive, unpack it and run -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -:: - - $ python setup.py install - -To install development version of the package using pip -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -For Tarantool version < 1.6.0 you must get ``stable`` branch:: - - $ pip install git+https://github.com/tarantool/tarantool-python.git@stable - -For later Tarantool use ``master`` branch:: - - $ pip install git+https://github.com/tarantool/tarantool-python.git@master - --------------------------------------------------------------------------------- - -What is Tarantool? ------------------- - -`Tarantool`_ is a NoSQL database running inside a Lua program. It combines the network programming power of Node.JS with data persistency capabilities of Redis. It's open source, `BSD licensed`_. - -Features --------- - - * Lua packages for non-blocking I/O, fibers and HTTP - * MsgPack data format and MsgPack based client-server protocol - * Two data engines: - * 100% in-memory with optional persistence - * 2-level disk-based B-tree, to use with large data sets (powered by `Sophia`_) - * secondary key and index iterators support (can be non-unique and composite) - * multiple index types: HASH, BITSET, TREE - * asynchronous master-master replication - * authentication and access control - - -See More -^^^^^^^^ - - * `Tarantool Homepage`_ - * `Tarantool at Github`_ - * `Tarantool User Guide`_ - * `Client-server Protocol Specification`_ - - -.. _`Tarantool`: -.. _`Tarantool Database`: -.. _`Tarantool Homepage`: http://tarantool.org -.. _`Tarantool at Github`: https://github.com/tarantool/tarantool -.. _`Tarantool User Guide`: http://tarantool.org/doc/user_guide.html -.. _`Client-server protocol specification`: http://tarantool.org/doc/dev_guide/box-protocol.html -.. _`Sophia`: http://sphia.org -.. _`BSD licensed`: http://www.gnu.org/licenses/license-list.html#ModifiedBSD - - -%prep -%setup -q -n %{name}-%{version} - -%build -python setup.py build - -%install -python setup.py install --single-version-externally-managed -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES - -%clean -rm -rf $RPM_BUILD_ROOT - -%files -f INSTALLED_FILES -%defattr(-,root,root) From af4c9564b6dbda896b487cd043abe06cd689824d Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Tue, 8 Nov 2022 18:33:09 +0300 Subject: [PATCH 12/18] test: make host more portable Docker container localhost resolve fails to connect test suites to test Tarantool instances. Part of #164, #198 --- test/suites/lib/tarantool_server.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/suites/lib/tarantool_server.py b/test/suites/lib/tarantool_server.py index 2640f5f4..56c1f06e 100644 --- a/test/suites/lib/tarantool_server.py +++ b/test/suites/lib/tarantool_server.py @@ -19,7 +19,7 @@ def check_port(port, rais=True): try: - sock = socket.create_connection(("localhost", port)) + sock = socket.create_connection(("0.0.0.0", port)) except socket.error: return True sock.close() @@ -103,7 +103,7 @@ def _admin(self, port): raise ValueError("Bad port number: '%s'" % port) if hasattr(self, 'admin'): del self.admin - self.admin = TarantoolAdmin('localhost', port) + self.admin = TarantoolAdmin('0.0.0.0', port) @property def log_des(self): @@ -147,7 +147,7 @@ def __init__(self, self.args['primary'] = self._socket.name self.args['admin'] = find_port() else: - self.host = 'localhost' + self.host = '0.0.0.0' self.args = {} self._socket = None self.args['primary'] = find_port() @@ -208,7 +208,7 @@ def wait_until_started(self): while True: try: - temp = TarantoolAdmin('localhost', self.args['admin']) + temp = TarantoolAdmin('0.0.0.0', self.args['admin']) while True: ans = temp('box.info.status')[0] if ans in ('running', 'hot_standby', 'orphan') or ans.startswith('replica'): From 2ebb83e3494b08da6c48469b340f0e7683b29408 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Tue, 8 Nov 2022 12:32:16 +0300 Subject: [PATCH 13/18] ci: run tests with RPM package See [1] about CentOS support. Fedora 37 is not tested yet since there is no Tarantool for it. 1. https://github.com/tarantool/tarantool-python/issues/257 Part of #164, #198 --- .github/workflows/packing.yml | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/.github/workflows/packing.yml b/.github/workflows/packing.yml index 082d90d7..07b30058 100644 --- a/.github/workflows/packing.yml +++ b/.github/workflows/packing.yml @@ -275,3 +275,61 @@ jobs: path: rpm_dist retention-days: 1 if-no-files-found: error + + run_tests_rpm: + needs: pack_rpm + + # We want to run on external PRs, but not on our own internal + # PRs as they'll be run by the push to the branch. + # + # The main trick is described here: + # https://github.com/Dart-Code/Dart-Code/pull/2375 + if: (github.event_name == 'push') || + (github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name != github.repository) + runs-on: ubuntu-latest + + container: + image: ${{ matrix.target.os }}:${{ matrix.target.dist }} + + strategy: + fail-fast: false + + matrix: + target: + - os: fedora + dist: '34' + - os: fedora + dist: '35' + - os: fedora + dist: '36' + + steps: + - name: Clone the connector repo + uses: actions/checkout@v3 + + - name: Setup Python and test running tools + run: dnf install -y python3 python3-libs python3-pip git make + + - name: Remove connector source code + run: python3 .github/scripts/remove_source_code.py + + - name: Install tarantool + run: | + curl -L https://tarantool.io/yeohchA/release/2/installer.sh | bash + dnf install -y tarantool tarantool-devel + + - name: Download RPM artifacts + uses: actions/download-artifact@v3 + with: + name: rpm_dist_${{ matrix.target.os }}_${{ matrix.target.dist }} + path: rpm_dist + + - name: Install the package from rpm artifacts + run: dnf install -y rpm_dist/python3-tarantool-*.noarch.rpm + + - name: Install test requirements + run: pip3 install -r requirements-test.txt + + - name: Run tests + run: make test-pure-install From 2b10313250d09d272315afd779936700aa9ab35b Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Tue, 8 Nov 2022 17:57:04 +0300 Subject: [PATCH 14/18] cd: publish RPM package Publish RPM package on tag. To test, comment "run only on tags" condition, change RWS_REPO to https://rws-dev.tarantool.org. See [1] about other OS support. 1. https://github.com/tarantool/tarantool-python/issues/257 Closes #164, part of #198 --- .github/workflows/packing.yml | 47 +++++++++++++++++++++++++++++++++++ CHANGELOG.md | 1 + README.rst | 17 +++++++++++++ docs/source/index.rst | 14 +++++++++++ 4 files changed, 79 insertions(+) diff --git a/.github/workflows/packing.yml b/.github/workflows/packing.yml index 07b30058..69e06b37 100644 --- a/.github/workflows/packing.yml +++ b/.github/workflows/packing.yml @@ -333,3 +333,50 @@ jobs: - name: Run tests run: make test-pure-install + + publish_rpm: + if: startsWith(github.ref, 'refs/tags') + + needs: + - run_tests_rpm + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + matrix: + target: + - os: fedora + dist: '34' + - os: fedora + dist: '35' + - os: fedora + dist: '36' + + steps: + - name: Clone the connector repo + uses: actions/checkout@v3 + + - name: Install tools for package publishing + run: sudo apt install -y curl make + + - name: Download RPM artifacts + uses: actions/download-artifact@v3 + with: + name: rpm_dist_${{ matrix.target.os }}_${{ matrix.target.dist }} + path: rpm_dist + + - name: Publish artifacts + run: | + export FILE_FLAGS=$(find rpm_dist/ -type f -regex '.*\.rpm' \ + | xargs -I {} sh -c 'echo -F $(basename {})=@{}' \ + | xargs) + echo $FILE_FLAGS + curl -v -LfsS -X PUT $RWS_REPO/release/modules/$OS/$DIST \ + -F product=python3-tarantool $FILE_FLAGS -u $RWS_AUTH + env: + RWS_REPO: https://rws.tarantool.org + RWS_AUTH: ${{ secrets.RWS_AUTH }} + OS: ${{ matrix.target.os }} + DIST: ${{ matrix.target.dist }} diff --git a/CHANGELOG.md b/CHANGELOG.md index bc960947..b98fea5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -188,6 +188,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Pack pip package with GitHub Actions (#198). - Publish pip package with GitHub Actions (#198). - Pack RPM package with GitHub Actions (#164, #198). +- Publish RPM package with GitHub Actions (#164, #198). ### Changed - Bump msgpack requirement to 1.0.4 (PR #223). diff --git a/README.rst b/README.rst index fa08ffa4..c8ea58f4 100644 --- a/README.rst +++ b/README.rst @@ -26,6 +26,23 @@ The recommended way to install the ``tarantool`` package is using ``pip``. $ pip3 install tarantool +With dnf +^^^^^^^^ + +You can install ``python3-tarantool`` RPM package if you use Fedora (34, 35, 36). + +Add the repository + +.. code-block:: bash + + $ curl -L https://tarantool.io/OtKysgx/release/2/installer.sh | bash + +and then install the package + +.. code-block:: bash + + $ dnf install -y python3-tarantool + ZIP archive ^^^^^^^^^^^ diff --git a/docs/source/index.rst b/docs/source/index.rst index 7f094b7e..47939873 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -14,6 +14,20 @@ Install Tarantool Python connector with ``pip`` (`PyPI`_ page): $ pip3 install tarantool +Otherwise, you can install ``python3-tarantool`` RPM package if you use Fedora (34, 35, 36). + +Add the repository + +.. code-block:: bash + + $ curl -L https://tarantool.io/OtKysgx/release/2/installer.sh | bash + +and then install the package + +.. code-block:: bash + + $ dnf install -y python3-tarantool + Source code is available on `GitHub`_. Documentation From c983db60b29c15bafc710d99b86a611c094410ed Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Tue, 8 Nov 2022 16:47:22 +0300 Subject: [PATCH 15/18] cd: pack deb package New deb spec files are based on stdeb plugin generated files [1] and Debian Style Guide for Packaging Python Libraries [2]. Beware that RPM name is changed based on recommendations for all mainstream distributives [2]. deb files are named with python3-tarantool prefix. Before the patch they were called tarantool-python (even though there wasn't new deb releases since 0.6.5). deb is suitable for distributives with Python 3.7 or newer. See [3] about pre-Python 3.7 systems support. Since deb requires changelog consistency to build, we generate a changelog entry for all nightly CI builds. 1. https://pypi.org/project/stdeb/ 2. https://wiki.debian.org/Python/LibraryStyleGuide?action=show&redirect=Python%2FPackaging 3. https://github.com/tarantool/tarantool-python/issues/257 Part of #198 --- .github/workflows/packing.yml | 46 +++++++++++++++++++++++++++++++++++ .gitignore | 9 +++++++ CHANGELOG.md | 1 + Makefile | 24 ++++++++++++++++++ debian/changelog | 12 ++++----- debian/compat | 2 +- debian/control | 22 ++++++++++------- debian/files | 1 - debian/rules | 17 ++++++++++--- debian/source/format | 2 +- debian/source/options | 1 + 11 files changed, 116 insertions(+), 21 deletions(-) delete mode 100644 debian/files create mode 100644 debian/source/options diff --git a/.github/workflows/packing.yml b/.github/workflows/packing.yml index 69e06b37..4bd734c5 100644 --- a/.github/workflows/packing.yml +++ b/.github/workflows/packing.yml @@ -380,3 +380,49 @@ jobs: RWS_AUTH: ${{ secrets.RWS_AUTH }} OS: ${{ matrix.target.os }} DIST: ${{ matrix.target.dist }} + + pack_deb: + # We want to run on external PRs, but not on our own internal + # PRs as they'll be run by the push to the branch. + # + # The main trick is described here: + # https://github.com/Dart-Code/Dart-Code/pull/2375 + if: (github.event_name == 'push') || + (github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name != github.repository) + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + steps: + - name: Clone the connector repo + uses: actions/checkout@v3 + # Checkout all tags for correct version computation + with: + fetch-depth: 0 + + - name: Install deb packing tools + run: | + sudo apt install -y devscripts equivs + + - name: Make changelog entry for non-release build + if: startsWith(github.ref, 'refs/tags') != true + run: make deb-changelog-entry + + - name: Install build tools + run: sudo mk-build-deps -i --tool "apt-get --no-install-recommends -y" + env: + DEBIAN_FRONTEND: noninteractive + + - name: Pack source and binary deb + run: make deb-dist + + - name: Verify the package + run: make deb-dist-check + + - name: Archive deb artifacts + uses: actions/upload-artifact@v3 + with: + name: deb_dist + path: deb_dist diff --git a/.gitignore b/.gitignore index 3392efa8..e8e7e210 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,8 @@ sophia venv/* +.eggs + tarantool/version.py pip_dist @@ -32,3 +34,10 @@ rpm/BUILD rpm/RPMS rpm_dist + +debian/python3-tarantool +debian/*debhelper* +debian/files +debian/*.substvars + +deb_dist diff --git a/CHANGELOG.md b/CHANGELOG.md index b98fea5c..4526d9d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -189,6 +189,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Publish pip package with GitHub Actions (#198). - Pack RPM package with GitHub Actions (#164, #198). - Publish RPM package with GitHub Actions (#164, #198). +- Pack deb package with GitHub Actions (#198). ### Changed - Bump msgpack requirement to 1.0.4 (PR #223). diff --git a/Makefile b/Makefile index 58752456..4bf34be6 100644 --- a/Makefile +++ b/Makefile @@ -60,3 +60,27 @@ rpm-dist: .PHONY: rpm-dist-check rpm-dist-check: rpm -K --nosignature rpm_dist/*.rpm + + +.PHONY: deb-changelog-entry +deb-changelog-entry: + DEBEMAIL=admin@tarantool.org dch --distribution unstable \ + --package "python3-tarantool" \ + --newversion $$(python3 setup.py --version) \ + "Nightly build" + +.PHONY: deb-dist +deb-dist: + dpkg-source -b . + dpkg-buildpackage -rfakeroot -us -uc + mkdir -p deb_dist + find .. -maxdepth 1 -type f -regex '.*/python3-tarantool_.*\.deb' \ + -or -regex '.*/python3-tarantool_.*\.buildinfo' \ + -or -regex '.*/python3-tarantool_.*\.changes' \ + -or -regex '.*/python3-tarantool_.*\.dsc' \ + -or -regex '.*/python3-tarantool_.*\.tar\.xz' \ + | xargs -I {} mv {} deb_dist/ + +.PHONY: deb-dist-check +deb-dist-check: + dpkg -I deb_dist/*.deb diff --git a/debian/changelog b/debian/changelog index 9d7607e1..cc553664 100644 --- a/debian/changelog +++ b/debian/changelog @@ -100,7 +100,7 @@ tarantool-python (0.9.0-0) unstable; urgency=medium * Tarantool Enterprise testing workflow on GitHub actions (PR #220). - -- Georgy Moiseev Mon, 20 Jun 2022 18:00:00 +0300 + -- Georgy Moiseev Mon, 20 Jun 2022 18:00:00 +0300 tarantool-python (0.8.0-0) unstable; urgency=medium @@ -286,7 +286,7 @@ tarantool-python (0.8.0-0) unstable; urgency=medium - Fixed formatting and wording in README (PR #215). - Clarified license of the project (BSD-2-Clause) (#197, PR #210). - -- Alexander Turenko Fri, 29 Apr 2022 22:30:00 +0300 + -- Alexander Turenko Fri, 29 Apr 2022 22:30:00 +0300 tarantool-python (0.7.1-0) unstable; urgency=medium @@ -295,7 +295,7 @@ tarantool-python (0.7.1-0) unstable; urgency=medium It is pure technical release. It fixes the dependency on the msgpack library. - -- Alexander Turenko Mon, 28 Dec 2020 04:01:30 +0300 + -- Alexander Turenko Mon, 28 Dec 2020 04:01:30 +0300 tarantool-python (0.7.0-0) unstable; urgency=medium @@ -376,7 +376,7 @@ tarantool-python (0.7.0-0) unstable; urgency=medium * test: ensure compatibility with Python 3 for some testing / documentation building code (PR #181). - -- Alexander Turenko Mon, 28 Dec 2020 03:11:10 +0300 + -- Alexander Turenko Mon, 28 Dec 2020 03:11:10 +0300 tarantool-python (0.6.6-0) unstable; urgency=medium @@ -398,7 +398,7 @@ tarantool-python (0.6.6-0) unstable; urgency=medium * Fixed a string representation of a Response object without data (say, authentication response) (#139). - -- Alexander Turenko Fri, 14 Jun 2019 23:14:07 +0300 + -- Alexander Turenko Fri, 14 Jun 2019 23:14:07 +0300 tarantool-python (0.6.5-0) unstable; urgency=medium @@ -419,7 +419,7 @@ tarantool-python (0.6.5-0) unstable; urgency=medium * Eliminated deprecation warnings on Python 3 (#114). * Add TCP_NODEPLAY back (it was removed in 0.6.4) (#127). - -- Alexander Turenko Tue, 19 Mar 2019 03:40:01 +0300 + -- Alexander Turenko Tue, 19 Mar 2019 03:40:01 +0300 tarantool-python (0.6.4-0) unstable; urgency=medium diff --git a/debian/compat b/debian/compat index 45a4fb75..f599e28b 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -8 +10 diff --git a/debian/control b/debian/control index e96c3bda..dc7869fc 100644 --- a/debian/control +++ b/debian/control @@ -1,13 +1,17 @@ -Source: tarantool-python -Maintainer: Konstantin Cherkasoff +Source: python3-tarantool +Maintainer: tarantool-python AUTHORS Section: python Priority: optional -Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3), debhelper (>= 7) +# See https://github.com/astraw/stdeb/issues/175 for dependencies +Build-Depends: python3, python3-dev, python3-pip, python3-setuptools, + python3-distutils, python3-wheel, python3-stdeb, dh-python, + debhelper (>= 10) Standards-Version: 3.9.1 +Homepage: https://github.com/tarantool/tarantool-python -Package: tarantool-python -Architecture: any -Depends: ${misc:Depends}, python-all (>= 2.6.6-3), python-msgpack | msgpack-python -Description: Python client library for Tarantool Database - Python driver for Tarantool 1.6 - This package is a pure-python client library for Tarantool. +Package: python3-tarantool +Replaces: tarantool-python (<< 0.9.1~) +Breaks: tarantool-python (<< 0.9.1~) +Architecture: all +Depends: ${misc:Depends}, ${python3:Depends} +Description: Python client library for Tarantool. diff --git a/debian/files b/debian/files deleted file mode 100644 index 7114a7c0..00000000 --- a/debian/files +++ /dev/null @@ -1 +0,0 @@ -python-tarantool_0.5.0-1_all.deb python optional diff --git a/debian/rules b/debian/rules index 61ddec49..658c3ceb 100755 --- a/debian/rules +++ b/debian/rules @@ -1,9 +1,20 @@ #!/usr/bin/make -f -# This file was automatically generated by stdeb 0.6.0+git at -# Thu, 12 Feb 2015 13:46:33 +0300 +# This file was automatically generated by stdeb 0.10.0 at +# Wed, 02 Nov 2022 17:29:57 +0300 %: - dh $@ --with python2 --buildsystem=python_distutils + dh $@ --with python3 --buildsystem=python_distutils +override_dh_auto_clean: + python3 setup.py clean -a + find . -name \*.pyc -exec rm {} \; +override_dh_auto_build: + python3 setup.py build --force + +override_dh_auto_install: + python3 setup.py install --force --root=debian/python3-tarantool --no-compile -O0 --install-layout=deb --prefix=/usr + +override_dh_python2: + dh_python2 --no-guessing-versions diff --git a/debian/source/format b/debian/source/format index 163aaf8d..89ae9db8 100644 --- a/debian/source/format +++ b/debian/source/format @@ -1 +1 @@ -3.0 (quilt) +3.0 (native) diff --git a/debian/source/options b/debian/source/options new file mode 100644 index 00000000..05679d19 --- /dev/null +++ b/debian/source/options @@ -0,0 +1 @@ +extend-diff-ignore="\.egg-info$" From e360e618ba011eaed8e7b99592a2d40b48c8cdf6 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Tue, 8 Nov 2022 18:34:23 +0300 Subject: [PATCH 16/18] fix: timezone offset with old pytz and pandas It seems that older pandas and pytz distributions (for example, ones from Debian 10 deb repositories) are prone to issues when pytz timezone offset ignores current datetime value [1]. Using explicit localize is both valid in modern version and fixes the bug for older ones. 1. https://stackoverflow.com/questions/11473721/weird-timezone-issue-with-pytz Part of #198 --- CHANGELOG.md | 1 + Makefile | 2 +- tarantool/msgpack_ext/types/datetime.py | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4526d9d3..12b7ea27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -211,6 +211,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Puting test files in pip package (#238). - Make connection close idempotent (#250). - readthedocs version (#255). +- timezone offset with old pytz and pandas (#198). ## 0.9.0 - 2022-06-20 diff --git a/Makefile b/Makefile index 4bf34be6..1ab6441b 100644 --- a/Makefile +++ b/Makefile @@ -64,7 +64,7 @@ rpm-dist-check: .PHONY: deb-changelog-entry deb-changelog-entry: - DEBEMAIL=admin@tarantool.org dch --distribution unstable \ + DEBEMAIL=admin@tarantool.org dch --distribution unstable -b \ --package "python3-tarantool" \ --newversion $$(python3 setup.py --version) \ "Nightly build" diff --git a/tarantool/msgpack_ext/types/datetime.py b/tarantool/msgpack_ext/types/datetime.py index f5912dda..d2e4b903 100644 --- a/tarantool/msgpack_ext/types/datetime.py +++ b/tarantool/msgpack_ext/types/datetime.py @@ -291,9 +291,9 @@ def __init__(self, *, timestamp=None, year=None, month=None, datetime = pandas.to_datetime(timestamp, unit='s') if not timestamp_since_utc_epoch: - self._datetime = datetime.replace(tzinfo=tzinfo) + self._datetime = datetime.tz_localize(tzinfo) else: - self._datetime = datetime.replace(tzinfo=pytz.UTC).tz_convert(tzinfo) + self._datetime = datetime.tz_localize(pytz.UTC).tz_convert(tzinfo) else: if nsec is not None: microsecond = nsec // NSEC_IN_MKSEC @@ -306,7 +306,7 @@ def __init__(self, *, timestamp=None, year=None, month=None, year=year, month=month, day=day, hour=hour, minute=minute, second=sec, microsecond=microsecond, - nanosecond=nanosecond, tzinfo=tzinfo) + nanosecond=nanosecond).tz_localize(tzinfo) def _interval_operation(self, other, sign=1): """ From c6a2081ba3d33f97aa9435a95f53657b3584c169 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Tue, 8 Nov 2022 17:39:20 +0300 Subject: [PATCH 17/18] ci: run tests with deb package See [1] about older versions support. Only LTS Ubuntu versions are included here. 1. https://github.com/tarantool/tarantool-python/issues/257 Part of #198 --- .github/workflows/packing.yml | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/.github/workflows/packing.yml b/.github/workflows/packing.yml index 4bd734c5..a69f4c04 100644 --- a/.github/workflows/packing.yml +++ b/.github/workflows/packing.yml @@ -426,3 +426,71 @@ jobs: with: name: deb_dist path: deb_dist + + run_tests_deb: + needs: pack_deb + + # We want to run on external PRs, but not on our own internal + # PRs as they'll be run by the push to the branch. + # + # The main trick is described here: + # https://github.com/Dart-Code/Dart-Code/pull/2375 + if: (github.event_name == 'push') || + (github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name != github.repository) + runs-on: ubuntu-latest + + container: + image: ${{ matrix.target.os }}:${{ matrix.target.dist }} + + strategy: + fail-fast: false + + matrix: + target: + - os: ubuntu + dist: focal # 20.04 + - os: ubuntu + dist: jammy # 22.04 + - os: debian + dist: buster # 10 + - os: debian + dist: bullseye # 11 + + steps: + - name: Clone the connector repo + uses: actions/checkout@v3 + + - name: Prepare apt + run: apt update + + - name: Setup Python + run: apt install -y python3 python3-pip git + + - name: Remove connector source code + run: python3 .github/scripts/remove_source_code.py + + - name: Install tarantool ${{ matrix.tarantool }} + run: | + apt install -y curl + curl -L https://tarantool.io/yeohchA/release/2/installer.sh | bash + apt install -y tarantool tarantool-dev + env: + DEBIAN_FRONTEND: noninteractive + + - name: Download deb artifacts + uses: actions/download-artifact@v3 + with: + name: deb_dist + path: deb_dist + + - name: Install the package from deb artifacts + run: apt install -y `pwd`/deb_dist/python3-tarantool_*.deb + env: + DEBIAN_FRONTEND: noninteractive + + - name: Install test requirements + run: pip3 install -r requirements-test.txt + + - name: Run tests + run: make test-pure-install From b23193ae02477a9571c4322e7a22536d83f4fb2e Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Tue, 8 Nov 2022 18:08:16 +0300 Subject: [PATCH 18/18] cd: publish deb package Publish deb artifacts on tag. To test, comment "run only on tags" condition, change RWS_REPO to https://rws-dev.tarantool.org. See [1] about other OS support. 1. https://github.com/tarantool/tarantool-python/issues/257 Closes #198 --- .github/workflows/packing.yml | 49 +++++++++++++++++++++++++++++++++++ CHANGELOG.md | 1 + README.rst | 18 +++++++++++++ docs/source/index.rst | 15 +++++++++++ 4 files changed, 83 insertions(+) diff --git a/.github/workflows/packing.yml b/.github/workflows/packing.yml index a69f4c04..e413d4e1 100644 --- a/.github/workflows/packing.yml +++ b/.github/workflows/packing.yml @@ -494,3 +494,52 @@ jobs: - name: Run tests run: make test-pure-install + + publish_deb: + if: startsWith(github.ref, 'refs/tags') + + needs: + - run_tests_deb + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + matrix: + target: + - os: ubuntu + dist: focal # 20.04 + - os: ubuntu + dist: jammy # 22.04 + - os: debian + dist: buster # 10 + - os: debian + dist: bullseye # 11 + + steps: + - name: Clone the connector repo + uses: actions/checkout@v3 + + - name: Install tools for package publishing + run: sudo apt install -y curl make + + - name: Download deb artifacts + uses: actions/download-artifact@v3 + with: + name: deb_dist + path: deb_dist + + - name: Publish artifacts + run: | + export FILE_FLAGS=$(find deb_dist/ -type f -regex '.*\.deb' -or -regex '.*\.dsc' \ + | xargs -I {} sh -c 'echo -F $(basename {})=@{}' \ + | xargs) + echo $FILE_FLAGS + curl -v -LfsS -X PUT $RWS_REPO/release/modules/$OS/$DIST \ + -F product=python3-tarantool $FILE_FLAGS -u $RWS_AUTH + env: + RWS_REPO: https://rws.tarantool.org + RWS_AUTH: ${{ secrets.RWS_AUTH }} + OS: ${{ matrix.target.os }} + DIST: ${{ matrix.target.dist }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 12b7ea27..7a99faff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -190,6 +190,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Pack RPM package with GitHub Actions (#164, #198). - Publish RPM package with GitHub Actions (#164, #198). - Pack deb package with GitHub Actions (#198). +- Publish deb package with GitHub Actions (#198). ### Changed - Bump msgpack requirement to 1.0.4 (PR #223). diff --git a/README.rst b/README.rst index c8ea58f4..ff92c6cd 100644 --- a/README.rst +++ b/README.rst @@ -43,6 +43,24 @@ and then install the package $ dnf install -y python3-tarantool +With apt +^^^^^^^^ + +You can install ``python3-tarantool`` deb package if you use +Debian (10, 11) or Ubuntu (20.04, 22.04). + +Add the repository + +.. code-block:: bash + + $ curl -L https://tarantool.io/OtKysgx/release/2/installer.sh | bash + +and then install the package + +.. code-block:: bash + + $ apt install -y python3-tarantool + ZIP archive ^^^^^^^^^^^ diff --git a/docs/source/index.rst b/docs/source/index.rst index 47939873..a8b7cc38 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -28,6 +28,21 @@ and then install the package $ dnf install -y python3-tarantool +Otherwise, you can install ``python3-tarantool`` deb package if you use Debian (10, 11) +or Ubuntu (20.04, 22.04). + +Add the repository + +.. code-block:: bash + + $ curl -L https://tarantool.io/OtKysgx/release/2/installer.sh | bash + +and then install the package + +.. code-block:: bash + + $ apt install -y python3-tarantool + Source code is available on `GitHub`_. Documentation