Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit c3d188e

Browse files
authored
feat: add entry_points so that ibis 2 can discover this backend (#38)
* feat: add `entry_points` so that ibis 2 can discover this backend * install in editable mode so that entrypoints are available * attempt to avoid circular dependency * import ibis before ibis_bigquery * try installing to HOME for GitHub Actions * workaround for editable install pep517 * second try at workaround * prepend workaround
1 parent 7348bf2 commit c3d188e

File tree

5 files changed

+51
-18
lines changed

5 files changed

+51
-18
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ jobs:
4646
unit-tests:
4747
name: Unit Tests
4848
runs-on: ubuntu-latest
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
python_version: ["3.7", "3.8", "3.9"]
4953
steps:
5054

5155
- name: checkout
@@ -57,10 +61,10 @@ jobs:
5761
repository: ibis-project/ibis
5862
path: ibis
5963

60-
- name: setup python
64+
- name: set up python ${{ matrix.python-version }}
6165
uses: actions/setup-python@v2
6266
with:
63-
python-version: "3.7"
67+
python-version: ${{ matrix.python-version }}
6468

6569
- name: install dependencies
6670
run: ./ci/install_deps.sh

ci/install_deps.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
set -e
44
set -x
55

6+
# See https://github.com/pypa/pip/issues/7953
7+
echo "import site
8+
import sys
9+
site.ENABLE_USER_SITE = '--user' in sys.argv[1:]
10+
$(cat ./ibis/setup.py)" > ./ibis/setup.py
11+
612
python -m pip install --upgrade pip
7-
python -m pip install ./ibis
8-
python -m pip install .
9-
python -m pip install pytest
13+
python -m pip install --user -e ./ibis
14+
python -m pip install --user -e .
15+
python -m pip install --user pytest

setup.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
"""Ibis BigQuery backend."""
22

33
import pathlib
4+
import site
5+
import sys
46
from typing import Dict
57

68
import setuptools
79

10+
# See https://github.com/pypa/pip/issues/7953
11+
site.ENABLE_USER_SITE = "--user" in sys.argv[1:]
12+
813
# Package metadata.
914

1015
name = "ibis-bigquery"
@@ -32,23 +37,26 @@
3237
version=version,
3338
description=description,
3439
long_description=readme,
35-
url='https://github.com/ibis-project/ibis-bigquery',
40+
url="https://github.com/ibis-project/ibis-bigquery",
3641
packages=setuptools.find_packages(),
37-
python_requires='>=3.7',
42+
python_requires=">=3.7",
3843
install_requires=[
39-
'ibis-framework', # TODO require ibis 2.0 when it's released
40-
'google-cloud-bigquery >=1.12.0,<3.0.0dev',
41-
'google-cloud-bigquery-storage >=1.0.0,<3.0.0dev',
42-
'pyarrow >=1.0.0,<4.0.0dev',
43-
'pydata-google-auth',
44+
"ibis-framework", # TODO require ibis 2.0 when it's released
45+
"google-cloud-bigquery >=1.12.0,<3.0.0dev",
46+
"google-cloud-bigquery-storage >=1.0.0,<3.0.0dev",
47+
"pyarrow >=1.0.0,<4.0.0dev",
48+
"pydata-google-auth",
4449
],
4550
classifiers=[
4651
release_status,
47-
'Operating System :: OS Independent',
48-
'Intended Audience :: Science/Research',
49-
'Programming Language :: Python',
50-
'Programming Language :: Python :: 3',
51-
'Topic :: Scientific/Engineering',
52+
"Operating System :: OS Independent",
53+
"Intended Audience :: Science/Research",
54+
"Programming Language :: Python",
55+
"Programming Language :: Python :: 3",
56+
"Topic :: Scientific/Engineering",
5257
],
53-
license='Apache 2.0',
58+
license="Apache 2.0",
59+
entry_points={
60+
"ibis.backends": ["bigquery = ibis_bigquery"],
61+
},
5462
)

tests/unit/test_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import ibis # noqa: F401
12
import pytest
23

34
import ibis_bigquery.client

tests/unit/test_entry_points.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""Test to verify that the package is discoverable from Ibis v2."""
2+
3+
import ibis
4+
5+
6+
def test_has_bigquery():
7+
assert hasattr(ibis, "bigquery")
8+
9+
10+
def test_compile():
11+
expr = ibis.literal(1)
12+
result = ibis.bigquery.compile(expr)
13+
expected = "SELECT 1"
14+
assert expected in result

0 commit comments

Comments
 (0)