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

[🚀 Feature]: Configurable selenium-manager build #15009

Open
tjuhaszrh opened this issue Jan 2, 2025 · 2 comments
Open

[🚀 Feature]: Configurable selenium-manager build #15009

tjuhaszrh opened this issue Jan 2, 2025 · 2 comments

Comments

@tjuhaszrh
Copy link

Feature and motivation

Hello,

To package selenium-manager for Fedora (and likely for other distributions), it is essential to download all dependencies from the distribution's repository. However, selenium-manager depends on packages such as debpkg or apple-flat-pkg, which are not available in Fedora and are unlikely to be included. This causes build failures due to missing dependencies.

It would be beneficial if the build process were more configurable to accommodate specific environments. Currently, the workaround involves manually patching and removing unnecessary dependencies and the functions that rely on them, which is not ideal.

Usage example

Configuring selenium-manager: Making Unavailable Dependencies Optional

[package]
name = "selenium-manager"
version = "1.0.0"
edition = "2021"

[dependencies]
clap = { version = "4.5.20", features = ["derive", "cargo"] }
log = "0.4.22"
env_logger = "0.11.5"
regex = "1.11.0"
tokio = { version = "1.40.0", default-features = false, features = ["macros", "net", "rt-multi-thread"] }
tempfile = "3.13.0"
reqwest = { version = "0.12.8", default-features = false, features = ["rustls-tls"] }
zip = { version = "2.2.0", default-features = false, features = ["deflate-zlib"] }
directories = "5.0.1"
serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.128"
flate2 = "1.0.34"
tar = "0.4.42"
walkdir = "2.5.0"
exitcode = "1.1.2"
toml = "0.8.19"
bzip2 = "0.4.4"
anyhow = { version = "1.0.89", default-features = false, features = ["backtrace", "std"] }
which = "6.0.3"

# Optional dependencies (platform-specific)
sevenz-rust = { version = "0.6.1", optional = true }
infer = { version = "0.16.0", optional = true }
debpkg = { version = "0.6.0", optional = true }
apple-flat-package = { version = "0.18.0", optional = true }

// Making changes to files.rs to make it configurable
// Removing dependencies and logic related to optional packages

- use crate::{format_one_arg, format_three_args, run_shell_command_by_os, Command, Logger, CP_VOLUME_COMMAND, HDIUTIL_ATTACH_COMMAND, HDIUTIL_DETACH_COMMAND, MACOS, MSIEXEC_INSTALL_COMMAND};
+ use crate::{Logger};  // Keep only essential imports mandatory

use anyhow::anyhow;
use anyhow::Error;

// Removed dependencies that require optional features:
- use apple_flat_package::PkgReader;
use bzip2::read::BzDecoder;
use directories::BaseDirs;
use flate2::read::GzDecoder;

// Removed constants related to unsupported formats when optional dependencies aren't included:
- const ZIP: &str = "zip";
- const GZ: &str = "gz";
- const XML: &str = "xml";
- const HTML: &str = "html";
- const BZ2: &str = "bz2";
- const PKG: &str = "pkg";
- const DMG: &str = "dmg";
- const EXE: &str = "exe";
- const DEB: &str = "deb";
- const MSI: &str = "msi";
- const SEVEN_ZIP_HEADER: &[u8; 6] = b"7z\xBC\xAF\x27\x1C";
- const UNCOMPRESS_MACOS_ERR_MSG: &str = "{} files are only supported in macOS";

// Handling compression formats conditionally when dependencies are available
#[cfg(feature = "sevenz-rust")]
pub fn uncompress_sfx(compressed_file: &str, target: &Path, log: &Logger) -> Result<(), Error> {
    // Decompressing logic that requires 'sevenz-rust'
    sevenz_rust::decompress(...);
}

// Similarly for other dependencies
Copy link

github-actions bot commented Jan 2, 2025

@tjuhaszrh, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@decathorpe
Copy link

Yes - this is usually handled with target-specific dependencies and conditional compilation, see

https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies (for specifiying platform-specific dependencies in Cargo.toml) and

https://doc.rust-lang.org/reference/conditional-compilation.html#forms-of-conditional-compilation (for how to handle conditional compilation in Rust source code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants