Skip to content

Commit

Permalink
build: Rename prql-python to prqlc / prqlc-python (#4188)
Browse files Browse the repository at this point in the history
  • Loading branch information
max-sixty authored Feb 8, 2024
1 parent 366cfb2 commit 591c2a5
Show file tree
Hide file tree
Showing 24 changed files with 135 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Dev Container for Rust, website, prql-js and prql-python
// Dev Container for Rust, website, prql-js and prqlc-python
{
"image": "ghcr.io/prql/prql-devcontainer-base:latest",
"features": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: build-wheel
description:
"Use maturin to build python dists of prql-python. Conditional `if` checks
"Use maturin to build python dists of prqlc-python. Conditional `if` checks
ensure only the correct OS build is called."
inputs:
target:
Expand All @@ -15,26 +15,28 @@ runs:
if: inputs.target == 'source'
with:
command: sdist
args: -o target/python -m prqlc/bindings/python/Cargo.toml
args: -o target/python -m prqlc/bindings/prqlc-python/Cargo.toml
- uses: PyO3/maturin-action@v1
if: runner.os == 'Linux' && inputs.target != 'source'
with:
target: ${{ inputs.target }}
manylinux: auto
command: build
args: --release -o target/python -m prqlc/bindings/python/Cargo.toml
args:
--release -o target/python -m prqlc/bindings/prqlc-python/Cargo.toml
- uses: PyO3/maturin-action@v1
if: runner.os == 'Windows' && inputs.target != 'source'
with:
command: build
args: --release -o target/python -m prqlc/bindings/python/Cargo.toml
args:
--release -o target/python -m prqlc/bindings/prqlc-python/Cargo.toml
- uses: PyO3/maturin-action@v1
if: runner.os == 'macOS' && inputs.target != 'source'
with:
command: build
args:
--release -o target/python --target universal2-apple-darwin -m
prqlc/bindings/python/Cargo.toml
prqlc/bindings/prqlc-python/Cargo.toml
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ updates:
commit-message:
prefix: "chore: "

- directory: ".github/actions/build-prql-python"
- directory: ".github/actions/build-prqlc-python"
commit-message:
prefix: "chore: "
package-ecosystem: "github-actions"
Expand All @@ -72,7 +72,7 @@ updates:
interval: "daily"

- package-ecosystem: pip
directory: "prqlc/bindings/python"
directory: "prqlc/bindings/prqlc-python"
schedule:
interval: daily
commit-message:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,11 @@ jobs:
steps:
- name: 📂 Checkout code
uses: actions/checkout@v4
- uses: ./.github/actions/build-prql-python
- uses: ./.github/actions/build-prqlc-python
with:
target: ${{ matrix.target }}

publish-prql-python:
publish-prqlc-python:
runs-on: ubuntu-latest
needs: [build-python-wheels]
if: github.event_name == 'release'
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/test-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: 📂 Checkout code
uses: actions/checkout@v4
- name: Build wheel
uses: ./.github/actions/build-prql-python
uses: ./.github/actions/build-prqlc-python
with:
target: ${{ matrix.os == 'ubuntu-latest' && 'x86_64' || '' }}
- uses: actions/download-artifact@v3
Expand All @@ -42,7 +42,8 @@ jobs:
uses: actions/cache@v4
with:
path: .nox
key: nox-${{ hashFiles('prqlc/bindings/python/pyproject.toml') }}
key:
nox-${{ hashFiles('prqlc/bindings/prqlc-python/pyproject.toml') }}
- name: Run tests and typing
shell: bash
run: nox -s tests typing -f prqlc/bindings/python/noxfile.py
run: nox -s tests typing -f prqlc/bindings/prqlc-python/noxfile.py
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
- prqlc/bindings/prqlc-c/**
- .github/workflows/test-php.yaml
python:
- prqlc/bindings/python/**
- prqlc/bindings/prqlc-python/**
- .github/workflows/test-python.yaml
rust:
- "**/*.rs"
Expand Down
20 changes: 10 additions & 10 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [
"prqlc/bindings/java",
"prqlc/bindings/js",
"prqlc/bindings/prqlc-c",
"prqlc/bindings/python",
"prqlc/bindings/prqlc-python",
"prqlc/prql-compiler-macros",
"prqlc/prql-compiler",
"prqlc/prqlc-ast",
Expand Down
4 changes: 2 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ tasks:
cmds:
# TODO:
# - Add `prql-python` tests.
# - We could add `prql-lib` here.
# - Add `prqlc-python` tests.
# - We could add `prqlc-c` here.
# - We deliberately don't test some other bindings, such as `prql-php`,
# given they require more dependencies and aren't yet supported.
- task: test-lint
Expand Down
6 changes: 3 additions & 3 deletions prqlc/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ version: "3"

includes:
bindings-python:
taskfile: ./bindings/python
dir: ./bindings/python
taskfile: ./bindings/prqlc-python
dir: ./bindings/prqlc-python

vars:
packages_core: -p prqlc-ast -p prqlc-parser -p prqlc
packages_addon: -p prql-compiler-macros -p compile-files
packages_bindings: -p prql -p prql-java -p prql-js -p prqlc-c -p prql-python
packages_bindings: -p prql -p prql-java -p prql-js -p prqlc-c -p prqlc-python

tasks:
fmt:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
build = "build.rs"
name = "prql-python"
name = "prqlc-python"
publish = false

edition.workspace = true
Expand All @@ -11,15 +11,15 @@ version.workspace = true

[lib]
crate-type = ["cdylib"]
name = "prql_python"
doctest = false
doc = false
doctest = false

[target.'cfg(not(target_family="wasm"))'.dependencies]
pyo3 = {version = "0.20.2", features = ["abi3-py37"]}

[dependencies]
prqlc = {path = "../../prqlc", default-features = false}
# Renamed to avoid conflicts in lib.rs
prqlc_lib = {package = "prqlc", path = "../../prqlc", default-features = false}

[dev-dependencies]
insta = {version = "1.34", features = ["colors", "glob", "yaml"]}
Expand All @@ -30,3 +30,9 @@ pyo3-build-config = "0.20.2"
[package.metadata.release]
tag-name = "{{version}}"
tag-prefix = ""

# We want the package to be named `prqlc`, but the crate is named `prqlc-python`
# to avoid a conflict with other cargo artifacts. This option renames the
# package to `prqlc`.
[package.metadata.maturin]
name = "prqlc"
44 changes: 44 additions & 0 deletions prqlc/bindings/prqlc-python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Python bindings to `prqlc`

The `prqlc-python` crate offer Rust bindings to the `prqlc` Rust library,
published to a python package named `prqlc`.

The main entry point is a Python method `prqlc.compile(query: str) -> str`.

The package is consumed by [pyprql](https://github.com/prql/pyprql) &
[dbt-prql](https://github.com/prql/dbt-prql).

<!-- TODO: change -->
<!-- <https://pypi.org/project/prqlc/>. -->

The crate is not published to crates.io; only to PyPI at
<https://pypi.org/project/prql-python/>.

## Installation

`pip install prqlc`

## Usage

```python
import prqlc

prql_query = """
from employees
join salaries (==emp_id)
group {employees.dept_id, employees.gender} (
aggregate {
avg_salary = average salaries.salary
}
)
"""

options = prqlc.CompileOptions(
format=True, signature_comment=True, target="sql.postgres"
)

sql = prqlc.compile(prql_query)
sql_postgres = prqlc.compile(prql_query, options)
```

Relies on [pyo3](https://github.com/PyO3/pyo3) for all the magic.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nox session configuration."""

import os
from pathlib import Path
from typing import List
Expand All @@ -15,28 +16,28 @@
nox.options.reuse_existing_virtualenvs = False


def _install_prql_python(session: Session) -> None:
def _install_prqlc(session: Session) -> None:
session.install(
"-v",
# We'd like to prevent `prql_python` from being installed from PyPI, but we do
# We'd like to prevent `prqlc` from being installed from PyPI, but we do
# want to install its dependencies from there, and currently there's no way in
# plain pip of doing that (https://github.com/pypa/pip/issues/11440).
# "--no-index",
f"--find-links={Path('..', '..', '..', 'target', 'python')}",
"prql_python[test]",
"prqlc[test]",
)


@nox.session(python=VERSIONS) # type: ignore[misc]
def tests(session: Session) -> None:
"""Run the test suite with pytest."""
print("CWD", os.getcwd())
_install_prql_python(session)
_install_prqlc(session)
session.run("pytest", str(Path("python", "tests")))


@nox.session(python=VERSIONS) # type: ignore[misc]
def typing(session: Session) -> None:
"""Check types with mypy"""
_install_prql_python(session)
_install_prqlc(session)
session.run("mypy")
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ classifiers = [
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
name = "prql-python"
name = "prqlc"
requires-python = ">=3.8"

[tool.maturin]
Expand All @@ -21,6 +21,9 @@ requires-python = ">=3.8"

features = ["pyo3/extension-module"]

# The module is named `prqlc` rather than `prqlc-python`.
module-name = "prqlc"

[project.optional-dependencies]
test = [
"pytest >= 7",
Expand Down
Loading

0 comments on commit 591c2a5

Please sign in to comment.