Skip to content

Commit

Permalink
Remove option to add extra dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sanders41 committed Nov 26, 2024
1 parent b1931b5 commit 11bcfb6
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 700 deletions.
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,24 +199,6 @@ python-project create -s
docs are referencing. For example in this repository the repo url would be
`https://github.com/sanders41/python-project-generator`

- Extra Python Dependencies

These are extra packages you want to include in the project that are not provided by default.
For example specifying `fastapi, camel-converter` here will inculde these two packages in the
dependencies. If the project is an application the version will be pinned to the latest release
of the packages, and if it is a library the latest release will be used for the minimum version.
If you would like to specify a specific version instead you can by specifying the version with an
`@`. For example `fastapi@0.115.0, camel-converter@4.0.0`. When creating an appliction FastAPI
will be pinned to `0.115.0` and Camel Converter will be pinned to `4.0.0`, or if creating a
library these versions will be used for the minimum version.

- Extra Python Dev Dependencies

These are extra packages you want to include in the project's dev dependencies that are not
provided by default. For example specifying `pytest-xdist` here will include this package in the
dev dependencies. If you would like to specify a specific version instead of checking for the
latest you can by specifying the version with an `@`. For example `pytest-xdist@3.6.1`.

After running the generator a new directory will be created with the name you used for the
`Project Slug`. Change to this directory then install the python packages and pre-commit hooks.

Expand Down
12 changes: 0 additions & 12 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,6 @@ pub enum Param {
/// Remove the save download latest packages value
ResetDownloadLatestPackages,

/// Extra Python dependencies to include in the project
ExtraPythonPackages { value: Vec<String> },

/// Remove the saved extra Python dependencies
ResetExtraPythonPackages,

/// Extra Python dev dependencies to include in the project
ExtraPythonDevPackages { value: Vec<String> },

/// Remove the saved extra Python dev dependencies
ResetExtraPythonDevPackages,

/// Rerset the config to the default values
Reset,

Expand Down
46 changes: 0 additions & 46 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ pub struct Config {
pub use_multi_os_ci: Option<bool>,
pub include_docs: Option<bool>,
pub download_latest_packages: Option<bool>,
pub extra_python_packages: Option<Vec<String>>,
pub extra_python_dev_packages: Option<Vec<String>>,

#[serde(skip)]
config_dir: Rc<Option<PathBuf>>,
Expand Down Expand Up @@ -66,8 +64,6 @@ impl Default for Config {
use_multi_os_ci: None,
include_docs: None,
download_latest_packages: None,
extra_python_packages: None,
extra_python_dev_packages: None,
config_dir: config_dir(),
config_file_path: config_file_path(),
}
Expand Down Expand Up @@ -101,8 +97,6 @@ impl Config {
use_multi_os_ci: config.use_multi_os_ci,
include_docs: config.include_docs,
download_latest_packages: config.download_latest_packages,
extra_python_packages: config.extra_python_packages,
extra_python_dev_packages: config.extra_python_dev_packages,
config_dir: self.config_dir.clone(),
config_file_path: self.config_file_path.clone(),
};
Expand Down Expand Up @@ -362,26 +356,6 @@ impl Config {
Ok(())
}

pub fn save_extra_python_packages(&self, value: Vec<String>) -> Result<()> {
self.handle_save_config(|config| &mut config.extra_python_packages, Some(value))?;
Ok(())
}

pub fn reset_extra_python_packages(&self) -> Result<()> {
self.handle_save_config(|config| &mut config.extra_python_packages, None)?;
Ok(())
}

pub fn save_extra_python_dev_packages(&self, value: Vec<String>) -> Result<()> {
self.handle_save_config(|config| &mut config.extra_python_packages, Some(value))?;
Ok(())
}

pub fn reset_extra_python_dev_packages(&self) -> Result<()> {
self.handle_save_config(|config| &mut config.extra_python_packages, None)?;
Ok(())
}

fn handle_save_config<F, T>(&self, func: F, value: Option<T>) -> Result<()>
where
F: FnOnce(&mut Self) -> &mut Option<T>,
Expand Down Expand Up @@ -436,26 +410,6 @@ impl Config {
print_config_value("Use Multi OS CI", &config.use_multi_os_ci);
print_config_value("Include Docs", &config.include_docs);
print_config_value("Download Latest Packages", &config.download_latest_packages);
let extra_python_packages_label = "Extra Python Packages";
if let Some(extra_python_packages) = config.extra_python_packages {
let extra_python_packages_str = extra_python_packages.join(", ");
println!(
"{}: {extra_python_packages_str}",
extra_python_packages_label.blue()
);
} else {
println!("{}: null", extra_python_packages_label.blue());
}
let extra_python_dev_packages_label = "Extra Python Dev Packages";
if let Some(extra_python_dev_packages) = config.extra_python_dev_packages {
let extra_python_dev_packages_str = extra_python_dev_packages.join(", ");
println!(
"{}: {extra_python_dev_packages_str}",
extra_python_dev_packages_label.blue()
);
} else {
println!("{}: null", extra_python_dev_packages_label.blue());
}
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/github_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1580,8 +1580,6 @@ mod tests {
use_multi_os_ci: true,
include_docs: false,
docs_info: None,
extra_python_packages: None,
extra_python_dev_packages: None,
download_latest_packages: false,
project_root_dir: Some(tempdir().unwrap().path().to_path_buf()),
}
Expand Down
2 changes: 0 additions & 2 deletions src/licenses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,6 @@ mod tests {
use_multi_os_ci: true,
include_docs: false,
docs_info: None,
extra_python_packages: None,
extra_python_dev_packages: None,
download_latest_packages: false,
project_root_dir: Some(tempdir().unwrap().path().to_path_buf()),
}
Expand Down
26 changes: 0 additions & 26 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,30 +389,6 @@ fn main() {
exit(1);
}
}
Param::ExtraPythonPackages { value } => {
if let Err(e) = Config::default().save_extra_python_packages(value) {
print_error(e);
exit(1);
}
}
Param::ResetExtraPythonPackages {} => {
if let Err(e) = Config::default().reset_extra_python_packages() {
print_error(e);
exit(1);
}
}
Param::ExtraPythonDevPackages { value } => {
if let Err(e) = Config::default().save_extra_python_dev_packages(value) {
print_error(e);
exit(1);
}
}
Param::ResetExtraPythonDevPackages {} => {
if let Err(e) = Config::default().reset_extra_python_dev_packages() {
print_error(e);
exit(1);
}
}
Param::Reset => {
if Config::reset().is_err() {
let message = "Error resetting config.";
Expand Down Expand Up @@ -468,8 +444,6 @@ mod tests {
use_multi_os_ci: true,
include_docs: false,
docs_info: None,
extra_python_packages: None,
extra_python_dev_packages: None,
download_latest_packages: false,
project_root_dir: Some(base),
};
Expand Down
21 changes: 0 additions & 21 deletions src/package_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,27 +137,6 @@ impl PythonPackageVersion {
}
}

#[derive(Debug)]
pub struct ExtraPythonPackageVersion {
pub package: String,
pub version: String,
}

impl ExtraPythonPackageVersion {
pub fn new(package: String) -> Result<Self> {
if let Some(p) = package.split_once("@") {
Ok(ExtraPythonPackageVersion {
package: p.0.to_string(),
version: p.1.to_string(),
})
} else {
let version = get_latest_python_version(&package)?;

Ok(ExtraPythonPackageVersion { package, version })
}
}
}

#[derive(Debug)]
pub struct RustPackageVersion {
pub name: String,
Expand Down
Loading

0 comments on commit 11bcfb6

Please sign in to comment.