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/packing.yml b/.github/workflows/packing.yml new file mode 100644 index 00000000..e413d4e1 --- /dev/null +++ b/.github/workflows/packing.yml @@ -0,0 +1,545 @@ +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 + + 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 + + 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 }} + + 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 + + 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 + + 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 }} + + 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 + + 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 + + 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/.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..72b90c88 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: | @@ -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. # @@ -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,16 +185,17 @@ 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: 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 - 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 @@ -235,10 +231,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 @@ -280,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. # @@ -306,26 +302,19 @@ 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: 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 @@ -350,8 +339,7 @@ jobs: env: REMOTE_TARANTOOL_HOST: localhost REMOTE_TARANTOOL_CONSOLE_PORT: 3302 - TEST_PURE_INSTALL: true - run: python -m unittest discover -v + run: make test-pure-install - name: Stop test tarantool instance if: ${{ always() }} diff --git a/.gitignore b/.gitignore index a27a5f42..e8e7e210 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,24 @@ sophia venv/* +.eggs + 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 + +debian/python3-tarantool +debian/*debhelper* +debian/files +debian/*.substvars + +deb_dist diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e95ec9b..7a99faff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -185,6 +185,12 @@ 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). +- 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). +- Publish deb package with GitHub Actions (#198). ### Changed - Bump msgpack requirement to 1.0.4 (PR #223). @@ -198,6 +204,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). @@ -205,6 +212,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 5d9f6382..1ab6441b 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,86 @@ -.PHONY: install test docs +.PHONY: install install: - pip install --editable . + pip3 install --editable . + + +.PHONY: test test: - python setup.py 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 + +.PHONY: coverage coverage: - python -m coverage run -p --source=. setup.py test + python3 -m coverage run -p --source=. setup.py test + +.PHONY: cov-html cov-html: - python -m coverage html -i + python3 -m coverage html -i + +.PHONY: cov-report 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 + python3 -m coverage report + + +.PHONY: docs docs: - python setup.py build_sphinx + 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/* + + +.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 + + +.PHONY: deb-changelog-entry +deb-changelog-entry: + DEBEMAIL=admin@tarantool.org dch --distribution unstable -b \ + --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/README.rst b/README.rst index 44e14b0c..ff92c6cd 100644 --- a/README.rst +++ b/README.rst @@ -24,7 +24,42 @@ The recommended way to install the ``tarantool`` package is using ``pip``. .. code-block:: bash - $ pip install tarantool + $ 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 + +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 ^^^^^^^^^^^ @@ -42,7 +77,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 +147,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 +159,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/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$" diff --git a/docs/source/index.rst b/docs/source/index.rst index 5e5a04ca..a8b7cc38 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -12,7 +12,36 @@ Install Tarantool Python connector with ``pip`` (`PyPI`_ page): .. code-block:: bash - $ pip install tarantool + $ 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 + +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`_. 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' 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) 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, 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): """ 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'):