Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyO3 experiment #83

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,165 changes: 1,165 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[workspace]
members = [
"c-questdb-client/questdb-rs-ffi",
"pystr-to-utf8",
"egress"
]
exclude = [
"c-questdb-client/system_test/tls_proxy"
]
resolver = "2"
2 changes: 1 addition & 1 deletion RELEASING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Inside the VM, open a terminal (or use the terminal Window in VSCode) and run th
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3 \
-m pip install -U pip
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3 \
-m pip install -U setuptools wheel twine Cython cibuildwheel pandas numpy pyarrow
-m pip install -U setuptools setuptools-rust wheel twine Cython cibuildwheel pandas numpy pyarrow

Smoke-testing the build
-----------------------
Expand Down
1 change: 1 addition & 0 deletions ci/pip_install_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def main(args):
ensure_timezone()
pip_install('pip')
pip_install('setuptools')
pip_install('setuptools-rust')
try_pip_install('fastparquet>=2023.10.1')

if args.pandas_version is not None and args.pandas_version != '':
Expand Down
2 changes: 1 addition & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Cython>=0.29.32
wheel>=0.34.2
cibuildwheel>=2.11.2
Sphinx>=5.0.2
sphinx-rtd-theme>=1.0.0
twine>=4.0.1
bump2version>=1.0.1
pandas>=1.3.5
numpy>=1.21.6
pyarrow>=10.0.1
fastparquet>=2023.10.1
setuptools-rust>=1.9.0
288 changes: 288 additions & 0 deletions egress/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions egress/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "egress"
version = "0.1.0"
edition = "2021"

[dependencies]
pyo3 = { version = "0.21.1", features = ["extension-module"] }

[lib]
name = "questdb_egress"
crate-type = ["cdylib"]
9 changes: 9 additions & 0 deletions egress/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use std::env;

fn main() {
let target = env::var("TARGET").unwrap();
if target.contains("apple-darwin") {
println!("cargo:rustc-link-arg=-Wl,-undefined");
println!("cargo:rustc-link-arg=-Wl,dynamic_lookup");
}
}
16 changes: 16 additions & 0 deletions egress/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use pyo3::prelude::*;

/// Formats the sum of two numbers as string.
#[pyfunction]
fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
Ok((a + b).to_string())
}

/// A Python module implemented in Rust. The name of this function must match
/// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to
/// import the module.
#[pymodule]
fn egress(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
Ok(())
}
3 changes: 2 additions & 1 deletion proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import subprocess
import shlex
import pathlib
import glob
import platform

PROJ_ROOT = pathlib.Path(__file__).parent
Expand Down Expand Up @@ -233,11 +232,13 @@ def sdist():

@command
def clean():
_rmtree(PROJ_ROOT / 'target')
_rmtree(PROJ_ROOT / 'build')
_rmtree(PROJ_ROOT / 'dist')
_rmtree(PROJ_ROOT / 'c-questdb-client' / 'questdb-rs-ffi' / 'target')
_rmtree(PROJ_ROOT / 'c-questdb-client' / 'build')
_rmtree(PROJ_ROOT / 'pystr-to-utf8' / 'target')
_rmtree(PROJ_ROOT / 'egress' / 'target')
_rmtree(PROJ_ROOT / 'src' / 'questdb.egg-info')
_rmtree(PROJ_ROOT / 'venv')
_rmtree(PROJ_ROOT / 'wheelhouse')
Expand Down
Loading