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

Moves unnecessary deps out of critical build path #645

Merged
merged 12 commits into from
Aug 26, 2022
15 changes: 1 addition & 14 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ resolver = "2"
members = [
"cargo-pgx",
"pgx",
"pgx-paths",
"pgx-macros",
"pgx-pg-config",
"pgx-pg-sys",
Expand Down
1 change: 0 additions & 1 deletion cargo-pgx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ semver = "1.0.9"
owo-colors = { version = "3.4.0", features = [ "supports-colors" ] }
env_proxy = "0.4.1"
num_cpus = "1.13.1"
pgx-paths = { path = "../pgx-paths", version = "=0.5.0-beta.0" }
pgx-pg-config = { path = "../pgx-pg-config", version = "=0.5.0-beta.0" }
pgx-pg-sys-stub = { path = "../pgx-pg-sys-stub", version = "=0.5.0-beta.0" }
pgx-utils = { path = "../pgx-utils", version = "=0.5.0-beta.0" }
Expand Down
3 changes: 1 addition & 2 deletions cargo-pgx/src/command/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use crate::command::version::pgx_default;
use crate::CommandExecute;
use eyre::{eyre, WrapErr};
use owo_colors::OwoColorize;
use pgx_paths::prefix_path;
use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx, SUPPORTED_MAJOR_VERSIONS};
use pgx_pg_config::{prefix_path, PgConfig, PgConfigSelector, Pgx, SUPPORTED_MAJOR_VERSIONS};
use rayon::prelude::*;

use std::collections::HashMap;
Expand Down
8 changes: 5 additions & 3 deletions cargo-pgx/src/command/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ use crate::{
use cargo_toml::Manifest;
use eyre::{eyre, WrapErr};
use owo_colors::OwoColorize;
use pgx_paths::{get_target_dir, versioned_so_name};
use pgx_pg_config::PgConfig;
use pgx_pg_config::{get_target_dir, PgConfig};
use std::{
io::BufReader,
path::{Path, PathBuf},
Expand Down Expand Up @@ -156,7 +155,10 @@ pub(crate) fn install_extension(
dest.push(&pkgdir);
let so_name = if versioned_so {
let extver = get_version(&package_manifest_path)?;
versioned_so_name(&extname, &extver)
// Note: This originally was a call into versioned_so_name, but in an effort to eliminate crate dependencies,
// and because it was a single format! line, it was decided that inlining the single format! line was best in
// order to reduce a dependency.
format!("{}-{}", &extname, &extver)
BradyBonnette marked this conversation as resolved.
Show resolved Hide resolved
} else {
extname.clone()
};
Expand Down
3 changes: 1 addition & 2 deletions cargo-pgx/src/command/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use crate::{
};
use cargo_toml::Manifest;
use eyre::{eyre, WrapErr};
use pgx_paths::get_target_dir;
use pgx_pg_config::PgConfig;
use pgx_pg_config::{get_target_dir, PgConfig};
use std::path::{Path, PathBuf};

/// Create an installation package directory.
Expand Down
3 changes: 1 addition & 2 deletions cargo-pgx/src/command/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ use eyre::{eyre, WrapErr};
use object::Object;
use once_cell::sync::OnceCell;
use owo_colors::OwoColorize;
use pgx_paths::get_target_dir;
use pgx_pg_config::{PgConfig, Pgx};
use pgx_pg_config::{get_target_dir, PgConfig, Pgx};
use pgx_pg_sys_stub::PgxPgSysStub;
use pgx_utils::sql_entity_graph::{PgxSql, SqlGraphEntity};
use std::{
Expand Down
3 changes: 1 addition & 2 deletions cargo-pgx/src/command/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ Use of this source code is governed by the MIT license that can be found in the

use cargo_toml::Manifest;
use eyre::{eyre, WrapErr};
use pgx_paths::get_target_dir;
use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx};
use pgx_pg_config::{get_target_dir, PgConfig, PgConfigSelector, Pgx};
use std::{
path::{Path, PathBuf},
process::{Command, Stdio},
Expand Down
20 changes: 0 additions & 20 deletions pgx-paths/Cargo.toml

This file was deleted.

3 changes: 0 additions & 3 deletions pgx-paths/README.md

This file was deleted.

1 change: 1 addition & 0 deletions pgx-pg-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ eyre = "0.6.8"
owo-colors = "3.4.0"
serde = { version = "1.0.137", features = [ "derive" ] }
serde_derive = "1.0.137"
serde_json = "1.0.81"
toml = "0.5.9"
tracing = "0.1.34"
url = "2.2.2"
7 changes: 7 additions & 0 deletions pgx-pg-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ use url::Url;
pub static BASE_POSTGRES_PORT_NO: u16 = 28800;
pub static BASE_POSTGRES_TESTING_PORT_NO: u16 = 32200;

// These methods were originally in `pgx-utils`, but in an effort to consolidate
// dependencies, the decision was made to package them into wherever made the
// most sense. In this case, it made the most sense to put them into this
// pgx-pg-config crate. That doesnt mean they can't be moved at a later date.
mod path_methods;
pub use path_methods::{get_target_dir, prefix_path};

BradyBonnette marked this conversation as resolved.
Show resolved Hide resolved
#[derive(Clone)]
pub struct PgVersion {
major: u16,
Expand Down
37 changes: 13 additions & 24 deletions pgx-paths/src/lib.rs → pgx-pg-config/src/path_methods.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
/*
Portions Copyright 2019-2021 ZomboDB, LLC.
Portions Copyright 2021-2022 Technology Concepts & Design, Inc. <[email protected]>

All rights reserved.

Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/

use eyre::{eyre, WrapErr};
use serde_json::value::Value as JsonValue;
use std::{path::PathBuf, process::Command};

// Originally part of `pgx-utils`
pub fn prefix_path<P: Into<PathBuf>>(dir: P) -> String {
let mut path = std::env::split_paths(&std::env::var_os("PATH").expect("failed to get $PATH"))
.collect::<Vec<_>>();

path.insert(0, dir.into());
std::env::join_paths(path)
.expect("failed to join paths")
.into_string()
.expect("failed to construct path")
}

// Originally part of `pgx-utils`
pub fn get_target_dir() -> eyre::Result<PathBuf> {
let mut command = Command::new("cargo");
command
Expand Down Expand Up @@ -38,18 +42,3 @@ pub fn get_target_dir() -> eyre::Result<PathBuf> {
)),
}
}

pub fn prefix_path<P: Into<PathBuf>>(dir: P) -> String {
let mut path = std::env::split_paths(&std::env::var_os("PATH").expect("failed to get $PATH"))
.collect::<Vec<_>>();

path.insert(0, dir.into());
std::env::join_paths(path)
.expect("failed to join paths")
.into_string()
.expect("failed to construct path")
}

pub fn versioned_so_name(extension_name: &str, extension_version: &str) -> String {
format!("{}-{}", extension_name, extension_version)
}
1 change: 0 additions & 1 deletion pgx-pg-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ bindgen = { version = "0.59.2", default-features = false, features = ["runtime"]
build-deps = "0.1.4"
owo-colors = "3.4.0"
num_cpus = "1.13.1"
pgx-paths = { path = "../pgx-paths/", version = "=0.5.0-beta.0" }
pgx-pg-config= { path = "../pgx-pg-config/", version = "=0.5.0-beta.0" }
pgx-utils = { path = "../pgx-utils/", version = "=0.5.0-beta.0" }
proc-macro2 = "1.0.39"
Expand Down
3 changes: 1 addition & 2 deletions pgx-pg-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ extern crate build_deps;

use bindgen::callbacks::MacroParsingBehavior;
use eyre::{eyre, WrapErr};
use pgx_paths::prefix_path;
use pgx_pg_config::{PgConfig, PgConfigSelector, Pgx, SUPPORTED_MAJOR_VERSIONS};
use pgx_pg_config::{prefix_path, PgConfig, PgConfigSelector, Pgx, SUPPORTED_MAJOR_VERSIONS};
use pgx_utils::rewriter::PgGuardRewriter;
use quote::{quote, ToTokens};
use rayon::prelude::*;
Expand Down
1 change: 0 additions & 1 deletion pgx-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ owo-colors = "3.4.0"
once_cell = "1.10.0"
libc = "0.2.126"
pgx = { path = "../pgx", default-features = false, version= "=0.5.0-beta.0" }
pgx-paths = { path = "../pgx-paths", version= "=0.5.0-beta.0" }
pgx-macros = { path = "../pgx-macros", version= "=0.5.0-beta.0" }
pgx-pg-config = { path = "../pgx-pg-config", version= "=0.5.0-beta.0" }
pgx-utils = { path = "../pgx-utils", version= "=0.5.0-beta.0" }
Expand Down
3 changes: 1 addition & 2 deletions pgx-tests/src/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use eyre::{eyre, WrapErr};
use once_cell::sync::Lazy;
use owo_colors::OwoColorize;
use pgx::*;
use pgx_paths::get_target_dir;
use pgx_pg_config::{createdb, PgConfig, Pgx};
use pgx_pg_config::{createdb, get_target_dir, PgConfig, Pgx};
use postgres::error::DbError;
use postgres::Client;
use std::collections::HashMap;
Expand Down
1 change: 0 additions & 1 deletion pgx-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ convert_case = "0.5.0"
eyre = "0.6.8"
owo-colors = "3.4.0"
petgraph = "0.6.0"
pgx-paths = { path = "../pgx-paths", version = "=0.5.0-beta.0" }
proc-macro2 = { version = "1.0.39", features = [ "span-locations" ] }
quote = "1.0.18"
regex = "1.5.5"
Expand Down
6 changes: 4 additions & 2 deletions pgx-utils/src/sql_entity_graph/pgx_sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ All rights reserved.
Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
use eyre::{eyre, WrapErr};
use pgx_paths::versioned_so_name;
use std::{any::TypeId, collections::HashMap, fmt::Debug, path::Path};

use owo_colors::{OwoColorize, XtermColors};
Expand Down Expand Up @@ -548,7 +547,10 @@ impl PgxSql {
return if self.versioned_so {
let extname = &self.extension_name;
let extver = &self.control.default_version;
format!("$libdir/{}", versioned_so_name(extname, extver))
// Note: This originally was a call into versioned_so_name, but in an effort to eliminate crate dependencies,
// and because it was a single format! line, it was decided that inlining the single format! line was best in
// order to reduce a dependency.
format!("$libdir/{}-{}", extname, extver)
BradyBonnette marked this conversation as resolved.
Show resolved Hide resolved
} else {
String::from("MODULE_PATHNAME")
};
Expand Down