Skip to content

Commit

Permalink
template global config in pixi init
Browse files Browse the repository at this point in the history
  • Loading branch information
moritzwilksch committed Jan 3, 2025
1 parent 9acd6d0 commit dc58d10
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion src/cli/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
use clap::{Parser, ValueEnum};
use miette::{Context, IntoDiagnostic};
use minijinja::{context, Environment};
use pixi_config::{get_default_author, Config};
use pixi_config::{get_default_author, Config, S3Config};
use pixi_consts::consts;
use pixi_manifest::{
pyproject::PyProjectManifest, DependencyOverwriteBehavior, FeatureName, SpecType,
Expand Down Expand Up @@ -81,6 +81,22 @@ version = "{{ version }}"
{% if extra_index_urls %}extra-index-urls = {{ extra_index_urls }}{% endif %}
{%- endif %}
{%- if s3 %}
[s3]
{%- if s3["endpoint-url"] %}
endpoint-url = "{{ s3["endpoint-url"] }}"
{%- endif %}
{%- if s3.region %}
{%- endif %}
{%- if s3.region %}
region = "{{ s3.region }}"
{%- endif %}
{%- if s3["force-path-style"] %}
force-path-style = {{ s3["force-path-style"] }}
{%- endif %}
{%- endif %}
[tasks]
[dependencies]
Expand Down Expand Up @@ -109,6 +125,22 @@ default = { solve-group = "default" }
{{env}} = { features = {{ features }}, solve-group = "default" }
{%- endfor %}
{%- if s3 %}
[tool.pixi.s3]
{%- if s3["endpoint-url"] %}
endpoint-url = "{{ s3["endpoint-url"] }}"
{%- endif %}
{%- if s3.region %}
{%- endif %}
{%- if s3.region %}
region = "{{ s3.region }}"
{%- endif %}
{%- if s3["force-path-style"] %}
force-path-style = {{ s3["force-path-style"] }}
{%- endif %}
{%- endif %}
[tool.pixi.tasks]
"#;
Expand Down Expand Up @@ -142,6 +174,22 @@ platforms = {{ platforms }}
{% if extra_index_urls %}extra-index-urls = {{ extra_index_urls }}{% endif %}
{%- endif %}
{%- if s3 %}
[tool.pixi.s3]
{%- if s3["endpoint-url"] %}
endpoint-url = "{{ s3["endpoint-url"] }}"
{%- endif %}
{%- if s3.region %}
{%- endif %}
{%- if s3.region %}
region = "{{ s3.region }}"
{%- endif %}
{%- if s3["force-path-style"] %}
force-path-style = {{ s3["force-path-style"] }}
{%- endif %}
{%- endif %}
[tool.pixi.pypi-dependencies]
{{ pypi_package_name }} = { path = ".", editable = true }
Expand Down Expand Up @@ -237,6 +285,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
&platforms,
None,
&vec![],
config.s3_config,
);
let mut project = Project::from_str(&pixi_manifest_path, &rv)?;
let channel_config = project.channel_config();
Expand Down Expand Up @@ -327,6 +376,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
channels,
platforms,
environments,
s3 => config.s3_config,
},
)
.unwrap();
Expand Down Expand Up @@ -382,6 +432,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
platforms,
index_url => index_url.as_ref(),
extra_index_urls => &extra_index_urls,
s3 => config.s3_config,
},
)
.unwrap();
Expand Down Expand Up @@ -427,6 +478,7 @@ pub async fn execute(args: Args) -> miette::Result<()> {
&platforms,
index_url.as_ref(),
&extra_index_urls,
config.s3_config,
);
save_manifest_file(&pixi_manifest_path, rv)?;
};
Expand Down Expand Up @@ -465,6 +517,7 @@ fn render_project(
platforms: &Vec<String>,
index_url: Option<&Url>,
extra_index_urls: &Vec<Url>,
s3_config: S3Config,
) -> String {
env.render_named_str(
consts::PROJECT_MANIFEST,
Expand All @@ -477,6 +530,7 @@ fn render_project(
platforms,
index_url,
extra_index_urls,
s3 => s3_config,
},
)
.unwrap()
Expand Down

0 comments on commit dc58d10

Please sign in to comment.