pgcentralfoundation / pgrx

Build Postgres Extensions with Rust!
Other
3.7k stars 249 forks source link

Can't build with local pgrx repo #1865

Closed kysshsy closed 2 months ago

kysshsy commented 2 months ago

I want to build with local repo of pgrx and expose some functions of Postgres. So I changed the Cargo.toml. pgrx = {path = "/home/kyss/labs/pgrx/pgrx"} and I run git checkout v0.12.4 in pgrx repo.

And run cargo build in pg_analytics repo(which use pgrx as a dependency).

❯ cargo b                                                                                                                                  (base)
    Skipping git submodule `https://github.com/duckdb/duckdb` due to update strategy in .gitmodules
     Locking 6 packages to latest compatible versions
      Adding pgrx v0.12.4 (/home/kyss/labs/pgrx/pgrx)
      Adding pgrx-bindgen v0.12.4 (/home/kyss/labs/pgrx/pgrx-bindgen)
      Adding pgrx-macros v0.12.4 (/home/kyss/labs/pgrx/pgrx-macros)
      Adding pgrx-pg-config v0.12.4 (/home/kyss/labs/pgrx/pgrx-pg-config)
      Adding pgrx-pg-sys v0.12.4 (/home/kyss/labs/pgrx/pgrx-pg-sys)
      Adding pgrx-sql-entity-graph v0.12.4 (/home/kyss/labs/pgrx/pgrx-sql-entity-graph)
   Compiling pgrx-pg-sys v0.12.4
   Compiling pgrx-pg-sys v0.12.4 (/home/kyss/labs/pgrx/pgrx-pg-sys)
error: failed to run custom build command for `pgrx-pg-sys v0.12.4`

Caused by:
  process didn't exit successfully: `/home/kyss/labs/pg_analytics/target/debug/build/pgrx-pg-sys-2454794c7bfeb8b8/build-script-bindgen` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=PGRX_BUILD_VERBOSE
  cargo:rerun-if-env-changed=PGRX_PG_SYS_GENERATE_BINDINGS_FOR_RELEASE
  cargo:rerun-if-env-changed=PGRX_PG_CONFIG_PATH
  cargo:rerun-if-env-changed=PGRX_PG_CONFIG_AS_ENV
  cargo:rerun-if-env-changed=LLVM_CONFIG_PATH
  cargo:rerun-if-env-changed=LIBCLANG_PATH
  cargo:rerun-if-env-changed=LIBCLANG_STATIC_PATH
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=PGRX_PG_SYS_GENERATE_BINDINGS_FOR_RELEASE
  cargo:rerun-if-changed=include
  cargo:rerun-if-changed=cshim
  cargo:rerun-if-changed=/home/kyss/.pgrx/config.toml

  --- stderr
  build_paths=BuildPaths { manifest_dir: "/home/kyss/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-pg-sys-0.12.4", out_dir: "/home/kyss/labs/pg_analytics/target/debug/build/pgrx-pg-sys-35470a1b85a4194a/out", src_dir: "/home/kyss/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-pg-sys-0.12.4/src/include", shim_src: "/home/kyss/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-pg-sys-0.12.4/cshim", shim_dst: "/home/kyss/labs/pg_analytics/target/debug/build/pgrx-pg-sys-35470a1b85a4194a/out/cshim" }
  Error: Did not find `pg$VERSION` feature. `pgrx-pg-sys` requires one of `pg12`, `pg13`, `pg14`, `pg15`, `pg16`, `pg17` to be set

  Location:
      /home/kyss/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-bindgen-0.12.4/src/build.rs:192:28
warning: build failed, waiting for other jobs to finish...

Cargo.toml

[package]
name = "pg_analytics"
description = "Postgres for analytics, powered by DuckDB"
version = "0.1.4"
edition = "2021"
license = "AGPL-3.0"

[lib]
crate-type = ["cdylib", "rlib"]

[features]
default = ["pg16"]
pg12 = ["pgrx/pg12", "pgrx-tests/pg12"]
pg13 = ["pgrx/pg13", "pgrx-tests/pg13"]
pg14 = ["pgrx/pg14", "pgrx-tests/pg14"]
pg15 = ["pgrx/pg15", "pgrx-tests/pg15"]
pg16 = ["pgrx/pg16", "pgrx-tests/pg16"]
pg_test = []

[dependencies]
anyhow = "1.0.88"
async-std = { version = "1.13.0", features = ["tokio1", "attributes"] }
chrono = "0.4.38"
duckdb = { git = "https://github.com/paradedb/duckdb-rs.git", features = [
  "bundled",
  "extensions-full",
], rev = "e532dd6" }
pgrx =  {path = "/home/kyss/labs/pgrx/pgrx"}
serde = "1.0.210"
serde_json = "1.0.128"
signal-hook = "0.3.17"
sqlparser = "0.50.0"
strum = { version = "0.26.3", features = ["derive"] }
supabase-wrappers = { git = "https://github.com/paradedb/wrappers.git", default-features = false, rev = "19d6132" }
thiserror = "1.0.63"
uuid = "1.10.0"

[dev-dependencies]
aws-config = "1.5.6"
aws-sdk-s3 = "1.49.0"
bigdecimal = { version = "0.3.1", features = ["serde"] }
bytes = "1.7.1"
datafusion = "37.1.0"
deltalake = { version = "0.17.3", features = ["datafusion"] }
futures = "0.3.30"
pgrx-tests = "0.12.4"
rstest = "0.19.0"
serde_arrow = { version = "0.11.7", features = ["arrow-51"] }
soa_derive = "0.13.0"
sqlx = { version = "0.7.4", features = [
  "postgres",
  "runtime-async-std",
  "time",
  "bigdecimal",
  "uuid",
  "chrono",
] }
tempfile = "3.12.0"
testcontainers = "0.16.7"
testcontainers-modules = { version = "0.4.3", features = ["localstack"] }
time = { version = "0.3.36", features = ["serde"] }
geojson = "0.24.1"

[[bin]]
name = "pgrx_embed_pg_analytics"
path = "src/bin/pgrx_embed.rs"
eeeebbbbrrrr commented 2 months ago

Because pg_analytics has a dependency that also uses pgrx (the supabase-wrappers), instead of modifying Cargo.toml the way you did, add this at the end:

[patch.crates-io]
pgrx = { path = "/home/kyss/labs/pgrx/pgrx"}

That should clue cargo into using your version of pgrx for the top-level pg_analytics crate and all its dependencies that need it.

lizardoluis commented 2 weeks ago

Hi @eeeebbbbrrrr, I have a similar situation, but my Cargo.toml does not include PGRX. We do have a dependency that includes it, but this project itself doesn't. Is there a way to overcome this issue?

Adding the PGRX as dependency would be a solution, but in this case I would have to add that pgrx_embed! macro too. And I would like to avoid that.

eeeebbbbrrrr commented 2 weeks ago

pgrx isn't meant to be a transient dependency. You'll need to structure your code with that in mind.