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

Update dependencies #186

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
1,916 changes: 904 additions & 1,012 deletions Cargo.lock

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions Cargo.toml
Expand Up @@ -14,42 +14,42 @@ categories = ["development-tools::build-utils"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "^1"
termcolor = "^1.1"
atty = "^0.2.14"
data-encoding = "^2.1.2"
directories = "^2.0.2"
anyhow = "1"
termcolor = "1.1"
atty = "0.2.14"
data-encoding = "2.1.2"
directories = "4.0.1"
flate2 = "1.0.12"
fs_extra = "^1.1.0"
rust-ini = "0.13"
xz2 = "^0.1.6"
regex = "^1.1.9"
ring = "^0.16.9"
fs_extra = "1.1.0"
rust-ini = { version = "0.18.0", features = ["inline-comment"] }
xz2 = "0.1.6"
regex = "1.1.9"
ring = "0.16.9"
# We disable, by omission, suggestions, so it doesn't think `pyflow ipython` is a misspelling
# of `pyflow python`.
structopt = { version = "^0.3.3", default_features = false, features = ["color", "wrap_help", "doc"] }
serde = {version = "^1.0.101", features = ["derive"]}
tar = "^0.4.26"
toml = "^0.5.1"
zip = "^0.5.2"
nom = "^5.1.2"
clap = { version = "4.1.6", default_features = false, features = ["color", "derive", "error-context", "help", "std", "usage", "wrap_help"] }
serde = {version = "1.0.101", features = ["derive"]}
tar = "0.4.26"
toml = "0.7.2"
zip = "0.6.4"
nom = "7.1.3"
# We don't use native TLS, to avoid dependency issues on different linux distros.
reqwest = { version = "^0.9.21", default-features = false, features = ["rustls-tls"] }
reqwest = { version = "0.11.14", default-features = false, features = ["blocking", "brotli", "deflate", "gzip", "json", "rustls-tls"] }

# Vendorize OpenSSl on Linux, to avoid compatibility problems.
# todo: target-specific features aren't currently supported.
#[target.'cfg(target_os = "linux")'.dependencies]
#reqwest = { version = "^0.9.21", default-features = false, features = ["rustls-tls"] }
#reqwest = { version = "0.9.21", default-features = false, features = ["rustls-tls"] }
#
#[target.'cfg(not(target_os = "linux"))'.dependencies]
#reqwest = "^0.9.21"
#reqwest = "0.9.21"

mockall_double = "^0.2.0"
indoc = "1.0.3"
mockall_double = "0.3.0"
indoc = "2.0.0"

[dev-dependencies]
rstest = "0.10.0"
mockall = "^0.9"
rstest = "0.16.0"
mockall = "0.11.3"

[package.metadata.deb]
section = "Python"
Expand Down
2 changes: 1 addition & 1 deletion RELEASE_CHECKLIST.md
Expand Up @@ -40,7 +40,7 @@ users, and binaries built on other OSes appear not to work on these due to OpenS
1. Run `cargo package` and `cargo publish` (Any os).
1. Run `snapcraft login`, then `snapcraft push --release=stable pyflow_x.x.x_amd64.snap` on Ubuntu.
1. For the Windows and Ubuntu wheels, run `twine upload (wheelname)`.
1. Add a release on [Github](https://github.com/David-OConnor/seed/releases), following the format of previous releases.
1. Add a release on [Github](https://github.com/David-OConnor/pyflow/releases), following the format of previous releases.
1. Upload the following binaries to the release page: zipped Windows binary (This is all `Scoop` needs),
Linux binary, Msi, Deb, Rpm.

Expand Down
42 changes: 31 additions & 11 deletions src/actions/clear.rs
@@ -1,6 +1,5 @@
use std::{fs, path::Path};

use crate::util::{self, abort, success};
use crate::util::{self, abort, paths::PyflowDirs, success};
use std::fs;

#[derive(Clone)]
enum ClearChoice {
Expand All @@ -18,7 +17,7 @@ impl ToString for ClearChoice {
}

/// Clear `Pyflow`'s cache. Allow the user to select which parts to clear based on a prompt.
pub fn clear(pyflow_path: &Path, cache_path: &Path, script_env_path: &Path) {
pub fn clear(pyflow_dirs: &PyflowDirs) {
let result = util::prompts::list(
"Which cached items would you like to clear?",
"choice",
Expand All @@ -37,29 +36,50 @@ pub fn clear(pyflow_path: &Path, cache_path: &Path, script_env_path: &Path) {
// todo: DRY
match result.1 {
ClearChoice::Dependencies => {
if fs::remove_dir_all(&cache_path).is_err() {
let dep_cache_path = pyflow_dirs.dep_cache_path();
if fs::remove_dir_all(dep_cache_path).is_err() {
abort(&format!(
"Problem removing the dependency-cache path: {:?}",
cache_path
dep_cache_path
));
}
}
ClearChoice::ScriptEnvs => {
if fs::remove_dir_all(&script_env_path).is_err() {
let script_envs_dir = pyflow_dirs.script_envs_dir();
if fs::remove_dir_all(&script_envs_dir).is_err() {
abort(&format!(
"Problem removing the script env path: {:?}",
script_env_path
script_envs_dir
));
}
}
ClearChoice::PyInstalls => {}
ClearChoice::All => {
if fs::remove_dir_all(&pyflow_path).is_err() {
let data_dir = pyflow_dirs.data_dir();
if fs::remove_dir_all(&data_dir).is_err() {
abort(&format!(
"Problem removing the Pyflow path: {:?}",
pyflow_path
"Problem removing the Pyflow data directory: {:?}",
data_dir
));
}
let cache_dir = pyflow_dirs.cache_dir();
if data_dir != cache_dir {
if fs::remove_dir_all(&cache_dir).is_err() {
abort(&format!(
"Problem removing the Pyflow cache directory: {:?}",
cache_dir
));
}
}
let state_dir = pyflow_dirs.state_dir();
if data_dir != state_dir && cache_dir != state_dir {
if fs::remove_dir_all(&state_dir).is_err() {
abort(&format!(
"Problem removing the Pyflow state directory: {:?}",
state_dir
));
}
}
}
}
success("Cache is cleared")
Expand Down
6 changes: 2 additions & 4 deletions src/actions/init.rs
@@ -1,12 +1,10 @@
use std::path::PathBuf;

use termcolor::Color;

use crate::{
files,
pyproject::Config,
util::{self, abort},
};
use std::path::PathBuf;
use termcolor::Color;

pub fn init(cfg_filename: &str) {
let cfg_path = PathBuf::from(cfg_filename);
Expand Down
16 changes: 6 additions & 10 deletions src/actions/install.rs
@@ -1,21 +1,17 @@
use std::path::Path;

use termcolor::Color;

use crate::{
dep_types::{LockPackage, Version},
util::{self, process_reqs, Os, Paths},
util::{self, deps::sync, process_reqs, Os, Paths},
Config,
};

use util::deps::sync;
use std::path::Path;
use termcolor::Color;

// TODO: Refactor this function
#[allow(clippy::too_many_arguments)]
pub fn install(
cfg_path: &Path,
cfg: &Config,
git_path: &Path,
git_dir: &Path,
paths: &Paths,
found_lock: bool,
packages: &[String],
Expand All @@ -38,8 +34,8 @@ pub fn install(

let dont_uninstall = util::find_dont_uninstall(&updated_reqs, &up_dev_reqs);

let updated_reqs = process_reqs(updated_reqs, git_path, paths);
let up_dev_reqs = process_reqs(up_dev_reqs, git_path, paths);
let updated_reqs = process_reqs(updated_reqs, git_dir, paths);
let up_dev_reqs = process_reqs(up_dev_reqs, git_dir, paths);

sync(
paths,
Expand Down
6 changes: 2 additions & 4 deletions src/actions/list.rs
@@ -1,12 +1,10 @@
use std::{path::Path, process};

use termcolor::Color;

use crate::{
dep_types::Req,
pyproject,
util::{self, abort, print_color, print_color_},
};
use std::{path::Path, process};
use termcolor::Color;

/// List all installed dependencies and console scripts, by examining the `libs` and `bin` folders.
/// Also include path requirements, which won't appear in the `lib` folder.
Expand Down
25 changes: 16 additions & 9 deletions src/actions/mod.rs
@@ -1,19 +1,26 @@
mod clear;
mod init;
mod install;
mod list;
mod new;
mod package;
mod reset;
mod run;
mod switch;

pub use clear::clear;

mod init;
pub use init::init;

mod install;
pub use install::install;

mod list;
pub use list::list;

mod new;
pub use new::new;

mod package;
pub use package::package;

mod reset;
pub use reset::reset;

mod run;
pub use run::run;

mod switch;
pub use switch::switch;
16 changes: 7 additions & 9 deletions src/actions/new.rs
@@ -1,17 +1,15 @@
use crate::{
commands,
util::{self, abort, success},
Config,
};
use std::{
error::Error,
fs,
path::{Path, PathBuf},
};

use termcolor::Color;

use crate::{
commands,
util::{self, abort, success},
Config,
};

const GITIGNORE_INIT: &str = indoc::indoc! {r##"
# General Python ignores
build/
Expand All @@ -29,8 +27,8 @@ __pypackages__/

pub const NEW_ERROR_MESSAGE: &str = indoc::indoc! {r#"
Problem creating the project. This may be due to a permissions problem.
If on linux, please try again with `sudo`.
"#};
If on linux, please try again with `sudo`."#
};

pub fn new(name: &str) {
if new_internal(name).is_err() {
Expand Down
3 changes: 1 addition & 2 deletions src/actions/package.rs
@@ -1,10 +1,9 @@
use std::path::Path;

use crate::{
build,
dep_types::{LockPackage, Version},
util::{self, deps::sync},
};
use std::path::Path;

pub fn package(
paths: &util::Paths,
Expand Down
3 changes: 1 addition & 2 deletions src/actions/reset.rs
@@ -1,9 +1,8 @@
use std::{fs, process};

use crate::{
pyproject,
util::{abort, success},
};
use std::{fs, process};

pub fn reset() {
let pcfg = pyproject::current::get_config().unwrap_or_else(|| process::exit(1));
Expand Down
6 changes: 2 additions & 4 deletions src/actions/run.rs
@@ -1,8 +1,6 @@
use std::path::Path;

use regex::Regex;

use crate::{commands, pyproject::Config, util::abort};
use regex::Regex;
use std::path::Path;

/// Execute a python CLI tool, either specified in `pyproject.toml`, or in a dependency.
pub fn run(lib_path: &Path, bin_path: &Path, vers_path: &Path, cfg: &Config, args: Vec<String>) {
Expand Down
4 changes: 1 addition & 3 deletions src/actions/switch.rs
@@ -1,9 +1,7 @@
use crate::{files, pyproject, util};
use std::{path::PathBuf, process};

use termcolor::Color;

use crate::{files, pyproject, util};

/// Updates `pyproject.toml` with a new python version
pub fn switch(version: &str) {
let mut pcfg = pyproject::current::get_config().unwrap_or_else(|| process::exit(1));
Expand Down
5 changes: 2 additions & 3 deletions src/build.rs
@@ -1,7 +1,6 @@
use crate::{dep_types::Req, util};
use regex::Regex;
use std::{collections::HashMap, path::Path};
use std::{env, fs, process::Command};
use std::{collections::HashMap, env, fs, path::Path, process::Command};
use termcolor::Color;

// https://packaging.python.org/tutorials/packaging-projects/
Expand Down Expand Up @@ -238,7 +237,7 @@ pub(crate) fn publish(bin_path: &Path, cfg: &crate::Config) {

#[cfg(test)]
pub mod test {
use super::*;
use super::{cfg_to_setup, serialize_py_list, HashMap};
use crate::dep_types::{
Constraint, Req,
ReqType::{Caret, Exact},
Expand Down