From abb1b59c789a6ab11951c491a8c1e92e7a1d51ec Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Fri, 7 Oct 2022 16:52:20 +0300 Subject: [PATCH 1/7] setup: get package requirements from file Package dependencies in setup.py is outdated. Part of #238 --- setup.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 4aa0e7f1..b86b8209 100755 --- a/setup.py +++ b/setup.py @@ -50,6 +50,14 @@ def read(*parts): with codecs.open(filename, encoding='utf-8') as fp: return fp.read() +def get_dependencies(file): + root = os.path.dirname(os.path.realpath(__file__)) + requirements = os.path.join(root, file) + result = [] + if os.path.isfile(requirements): + with open(requirements) as f: + return f.read().splitlines() + raise RuntimeError("Unable to get dependencies from file " + file) def find_version(*file_paths): version_file = read(*file_paths) @@ -82,8 +90,6 @@ def find_version(*file_paths): ], cmdclass=cmdclass, command_options=command_options, - install_requires=[ - 'msgpack>=1.0.4', - ], + install_requires=get_dependencies('requirements.txt'), python_requires='>=3', ) From 0051dc4371fee10fbbbae1b374faddeab2ca186a Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Mon, 10 Oct 2022 10:59:22 +0300 Subject: [PATCH 2/7] setup: fix MANIFEST Part of #238 --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 4a9fa44b..fc2d7b26 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ include README.rst include README.txt include setup.py -recursive-include src/tarantool/ *.py +recursive-include tarantool/ *.py From 2bc92a1098e1915b3f0aaa31e0fca5b4a349536e Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Mon, 10 Oct 2022 15:02:38 +0300 Subject: [PATCH 3/7] setup: fix MANIFEST usage See [1]. 1. https://stackoverflow.com/questions/3596979/manifest-in-ignored-on-python-setup-py-install-no-data-files-installed Part of #238 --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index b86b8209..82f49232 100755 --- a/setup.py +++ b/setup.py @@ -72,6 +72,7 @@ def find_version(*file_paths): name="tarantool", packages=["tarantool"], package_dir={"tarantool": os.path.join("tarantool")}, + include_package_data=True, version=find_version('tarantool', '__init__.py'), platforms=["all"], author="tarantool-python AUTHORS", From e98da1a444d25e39326b7fdec09b58b5f9ce4007 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Tue, 11 Oct 2022 13:09:29 +0300 Subject: [PATCH 4/7] setup: list package without path Modern Python expects package name instead of full folder path [1]. 1. https://docs.python.org/3/distutils/setupscript.html#listing-whole-packages Part of #238 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 82f49232..82f1edfc 100755 --- a/setup.py +++ b/setup.py @@ -71,7 +71,7 @@ def find_version(*file_paths): setup( name="tarantool", packages=["tarantool"], - package_dir={"tarantool": os.path.join("tarantool")}, + package_dir={"tarantool": "tarantool"}, include_package_data=True, version=find_version('tarantool', '__init__.py'), platforms=["all"], From 3d03b99c1d39528762b088a79f8c354950b834bf Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Tue, 11 Oct 2022 17:17:30 +0300 Subject: [PATCH 5/7] setup: fix subpackages install Windows ``pip install`` resulted in missing msgpack_ext folder scripts. Package finder together with empty inits fixes it. Part of #238 --- CHANGELOG.md | 1 + setup.py | 6 +++--- tarantool/msgpack_ext/__init__.py | 0 tarantool/msgpack_ext/types/__init__.py | 0 4 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 tarantool/msgpack_ext/__init__.py create mode 100644 tarantool/msgpack_ext/types/__init__.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f518c55..e02a335d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -143,6 +143,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Update documentation index, quick start and guide pages (#67). ### Fixed +- Package build (#238). ## 0.9.0 - 2022-06-20 diff --git a/setup.py b/setup.py index 82f1edfc..9354dcc6 100755 --- a/setup.py +++ b/setup.py @@ -5,9 +5,9 @@ import re try: - from setuptools import setup + from setuptools import setup, find_packages except ImportError: - from distutils.core import setup + from distutils.core import setup, find_packages # Extra commands for documentation management cmdclass = {} @@ -70,7 +70,7 @@ def find_version(*file_paths): setup( name="tarantool", - packages=["tarantool"], + packages=find_packages("."), package_dir={"tarantool": "tarantool"}, include_package_data=True, version=find_version('tarantool', '__init__.py'), diff --git a/tarantool/msgpack_ext/__init__.py b/tarantool/msgpack_ext/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tarantool/msgpack_ext/types/__init__.py b/tarantool/msgpack_ext/types/__init__.py new file mode 100644 index 00000000..e69de29b From 8bb2c3790bd91d71fa6e8d58d2d688bdf81e80ee Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Tue, 11 Oct 2022 13:30:39 +0300 Subject: [PATCH 6/7] ci: run pure install tests GitHub actions clone the repo for test files, install current branch module with pip and run unittest (same as ran under setup.py) tests. "Run tests" stage is full of ResourceWarning messages. It's not clear why these messages are suppressed by `setup.py test`. We also can't disable these warning separately from application warnings (some tests rely on application warnings). Part of #238 --- .github/workflows/testing.yml | 128 ++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index fdb427e3..1bfdb420 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -148,6 +148,57 @@ jobs: env: TEST_TNT_SSL: ${{ matrix.tarantool == '2.10.0-1-gfa775b383-r486-linux-x86_64' }} + run_tests_with_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. + # + # 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-20.04 + + strategy: + fail-fast: false + + matrix: + tarantool: + - '2.10' + python: + - '3.6' + - '3.7' + - '3.8' + - '3.9' + - '3.10' + steps: + - 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: + tarantool-version: ${{ matrix.tarantool }} + + - name: Setup Python for tests + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + + - name: Install the package with pip + run: pip install git+$GITHUB_SERVER_URL/$GITHUB_REPOSITORY@$GITHUB_REF_NAME + + - name: Install test requirements + run: pip install -r requirements-test.txt + + - name: Run tests + run: python -m unittest discover -v + run_tests_ce_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. @@ -224,3 +275,80 @@ jobs: run: | cat tarantool.log || true kill $(cat tarantool.pid) || true + + run_tests_with_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. + # + # 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-2022 + + strategy: + fail-fast: false + + matrix: + tarantool: + - '2.10.0.g0a5ce0b9c-1' + python: + - '3.10' + steps: + - 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: Install the package with pip + run: pip install git+$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY@$env:GITHUB_REF_NAME + + - name: Install test requirements + run: pip install -r requirements-test.txt + + - name: Setup WSL for tarantool + uses: Vampire/setup-wsl@v1 + with: + distribution: Ubuntu-20.04 + + - name: Install tarantool ${{ matrix.tarantool }} for WSL + shell: wsl-bash_Ubuntu-20.04 {0} + run: | + curl -L https://tarantool.io/release/2/installer.sh | bash -s + sudo apt install -y tarantool=${{ matrix.tarantool }} tarantool-dev=${{ matrix.tarantool }} + + - 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: python -m unittest discover -v + + - name: Stop test tarantool instance + if: ${{ always() }} + shell: wsl-bash_Ubuntu-20.04 {0} + run: | + cat tarantool.log || true + kill $(cat tarantool.pid) || true From c3d45e4b93859ed827adc9786d0d55a58de61eb5 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Fri, 14 Oct 2022 10:55:34 +0300 Subject: [PATCH 7/7] ci: extend Windows test matrix Part of #238 --- .github/workflows/testing.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 1bfdb420..a128ee56 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -214,11 +214,13 @@ jobs: strategy: fail-fast: false matrix: + # Use reduced test matrix cause Windows pipelines are long. tarantool: - '1.10' - '2.8' - '2.10.0.g0a5ce0b9c-1' python: + - '3.6' - '3.10' steps: @@ -292,9 +294,11 @@ jobs: fail-fast: false matrix: + # Use reduced test matrix cause Windows pipelines are long. tarantool: - '2.10.0.g0a5ce0b9c-1' python: + - '3.6' - '3.10' steps: - name: Clone the connector repo