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

fix: python dependency specification #2483

Merged
merged 14 commits into from
Mar 1, 2024
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ jobs:
!target/**/glaredb
!target/**/pgprototest
key: ${{ runner.os }}-cargo-glaredb-build-${{ github.ref_name }}
- run: just python venv
- run: just python build
- run: just python test

Expand Down
22 changes: 9 additions & 13 deletions bindings/python/justfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
set fallback
VENV := env_var_or_default("VENV", "../../.venv")
VENV := env_var_or_default("VENV", ".venv")
VENV_BIN := VENV / "bin"

@venv:
python3 -c "import virtualenv" || python3 -m pip --quiet install virtualenv
python3 -m virtualenv {{VENV}} --quiet

## Set up virtual environment and install requirements
@requirements: venv
{{VENV_BIN}}/python -m pip --quiet install --upgrade pip
{{VENV_BIN}}/pip --quiet install -r requirements.txt
if python3 -c "import virtualenv"; then python3 -m virtualenv {{VENV}}; else python3 -m venv {{VENV}}; fi
{{VENV_BIN}}/python -m pip install --upgrade pip
greyscaled marked this conversation as resolved.
Show resolved Hide resolved
{{VENV_BIN}}/pip install -r requirements.txt

## Compile and install py-glaredb for development
build *args: requirements
build *args:
@unset CONDA_PREFIX
{{VENV_BIN}}/maturin develop {{args}}

test: requirements
{{VENV_BIN}}/pytest -s
test:
{{VENV_BIN}}/pytest --rootdir={{justfile_directory()}}

## Run autoformatting and linting
fmt: venv
fmt:
{{VENV_BIN}}/ruff .
{{VENV_BIN}}/mypy
cargo fmt --all

example path: requirements
example path:
{{VENV_BIN}}/python examples/{{path}}.py
21 changes: 20 additions & 1 deletion bindings/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,32 @@ build-backend = "maturin"
name = "glaredb"
description = "GlareDB is a fast SQL database for querying and analyzing distributed data."
readme = "README.md"
version = "0.0.0"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]


[project.optional-dependencies]
great-expectations = [
"great_expectations",
"great_expectations[postgresql]",
]
pandas = [
"pandas",
"pandasai",
]
polars = [
"polars",
]
pyarrow = [
"pyarrow",
]


[project.urls]
Homepage = "https://glaredb.com"
Documentation = "https://docs.glaredb.com"
Expand All @@ -27,4 +46,4 @@ line-length = 88
fix = true
ignore = [
"F841" # unused variables
]
]
13 changes: 5 additions & 8 deletions bindings/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
maturin==1.0.1
virtualenv==20.23.1
ruff==0.0.275
# this requirements.txt is for development deps only
maturin==1.4.0
black==23.3.0
blackdoc==0.3.8
mypy==1.3.0
pytest
ruff==0.0.275
typos==1.15
pyarrow
pandas
polars
pytest
pandasai
great_expectations[postgresql]
great_expectations
pyarrow
Empty file.
7 changes: 3 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,15 @@ protoc:
rm protoc.zip
fi


# Installs python dependencies for testing
venv:
python3 -c "import virtualenv" || python3 -m pip --quiet install virtualenv
python3 -m virtualenv .venv --quiet
if python3 -c "import virtualenv"; then python3 -m virtualenv {{VENV}}; else python3 -m venv {{VENV}}; fi
{{VENV_BIN}}/python -m pip install --upgrade pip
{{VENV_BIN}}/python -m pip install poetry
{{VENV_BIN}}/poetry -C tests install

# Runs pytest in the tests directory.
pytest *args:
{{VENV_BIN}}/poetry -C tests install --no-root
{{VENV_BIN}}/poetry -C tests lock --no-update
{{VENV_BIN}}/poetry -C tests run pytest --rootdir={{invocation_directory()}}/tests {{ if args == "" {'tests'} else {args} }}

Expand Down
Loading