Skip to content

Commit

Permalink
Add datafusion-python (#69)
Browse files Browse the repository at this point in the history
* Added Python project.

* Update python/Cargo.toml

Co-authored-by: Andy Grove <andygrove@users.noreply.github.com>

* Update python/Cargo.toml

Co-authored-by: Uwe L. Korn <xhochy@users.noreply.github.com>

* Added license and black formatting.

* License

* Fixing build.

* TesTestt

* Bumped to latest DataFusion.

* Bumped nightly.

* Bumped pyarrow in tests.

* Added some tests back.

Co-authored-by: Andy Grove <andygrove@users.noreply.github.com>
Co-authored-by: Uwe L. Korn <xhochy@users.noreply.github.com>
  • Loading branch information
3 people authored May 4, 2021
1 parent e271e4d commit 46bde0b
Show file tree
Hide file tree
Showing 28 changed files with 2,244 additions and 1 deletion.
89 changes: 89 additions & 0 deletions .github/workflows/python_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: Build
on:
push:
tags:
- v*

jobs:
build-python-mac-win:
name: Mac/Win
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8]
os: [macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-01-06

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install maturin
- name: Build Python package
run: cd python && maturin build --release --no-sdist --strip --interpreter python${{matrix.python_version}}

- name: List wheels
if: matrix.os == 'windows-latest'
run: dir python/target\wheels\

- name: List wheels
if: matrix.os != 'windows-latest'
run: find ./python/target/wheels/

- name: Archive wheels
uses: actions/upload-artifact@v2
with:
name: dist
path: python/target/wheels/*

build-manylinux:
name: Manylinux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build wheels
run: docker run --rm -v $(pwd):/io konstin2/maturin build --release --manylinux
- name: Archive wheels
uses: actions/upload-artifact@v2
with:
name: dist
path: python/target/wheels/*

release:
name: Publish in PyPI
needs: [build-manylinux, build-python-mac-win]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
58 changes: 58 additions & 0 deletions .github/workflows/python_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: Python test
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Rust toolchain
run: |
rustup toolchain install nightly-2021-01-06
rustup default nightly-2021-01-06
rustup component add rustfmt
- name: Cache Cargo
uses: actions/cache@v2
with:
path: /home/runner/.cargo
key: cargo-maturin-cache-
- name: Cache Rust dependencies
uses: actions/cache@v2
with:
path: /home/runner/target
key: target-maturin-cache-
- uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Install Python dependencies
run: python -m pip install --upgrade pip setuptools wheel
- name: Run tests
run: |
cd python/
export CARGO_HOME="/home/runner/.cargo"
export CARGO_TARGET_DIR="/home/runner/target"
python -m venv venv
source venv/bin/activate
pip install maturin==0.10.4 toml==0.10.1 pyarrow==4.0.0
maturin develop
python -m unittest discover tests
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ members = [
"ballista/rust/core",
"ballista/rust/executor",
"ballista/rust/scheduler",
]
]

exclude = ["python"]
1 change: 1 addition & 0 deletions dev/release/rat_exclude_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,4 @@ rust-toolchain
benchmarks/queries/q*.sql
ballista/rust/scheduler/testdata/*
ballista/ui/scheduler/yarn.lock
python/rust-toolchain
22 changes: 22 additions & 0 deletions python/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
19 changes: 19 additions & 0 deletions python/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

target
venv
20 changes: 20 additions & 0 deletions python/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

/target
Cargo.lock
venv
57 changes: 57 additions & 0 deletions python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

[package]
name = "datafusion"
version = "0.2.1"
homepage = "https://github.com/apache/arrow"
repository = "https://github.com/apache/arrow"
authors = ["Apache Arrow <dev@arrow.apache.org>"]
description = "Build and run queries against data"
readme = "README.md"
license = "Apache-2.0"
edition = "2018"

[dependencies]
tokio = { version = "1.0", features = ["macros", "rt", "rt-multi-thread", "sync"] }
rand = "0.7"
pyo3 = { version = "0.12.1", features = ["extension-module"] }
datafusion = { git = "https://github.com/apache/arrow-datafusion.git", rev = "2423ff0d" }

[lib]
name = "datafusion"
crate-type = ["cdylib"]

[package.metadata.maturin]
requires-dist = ["pyarrow>=1"]

classifier = [
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"License :: OSI Approved",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python",
"Programming Language :: Rust",
]
Loading

0 comments on commit 46bde0b

Please sign in to comment.