Skip to content

feat: pypi-options.dependency-overrides #3948

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

Open
wants to merge 34 commits into
base: main
Choose a base branch
from

Conversation

HernandoR
Copy link

@HernandoR HernandoR commented Jun 14, 2025

add dependency-overrides for overriding.

only updated manifest for now

related #3917 #3890

@HernandoR
Copy link
Author

I'm a little bit concerned about the union strategy for pypi-options.dependency-overrides.

For now, I followed a strategy like pypi-dependency: the requirements feature will override the default.
i.e. if a feature asks for numpy=">=2.0.0" while default numpy=">=2.1.0", it will union to numpy=">=2.0.0".

The order of union logic (b overwrite a) is referred to

pub fn pypi_dependencies(
&self,
platform: Option<Platform>,
) -> Option<Cow<'_, IndexMap<PypiPackageName, PixiPypiSpec>>> {
self.targets
.resolve(platform)
// Get the targets in reverse order, from least specific to most specific.
// This is required because the extend function will overwrite existing keys.
.rev()
.filter_map(|t| t.pypi_dependencies.as_ref())
.filter(|deps| !deps.is_empty())
.fold(None, |acc, deps| match acc {
None => Some(Cow::Borrowed(deps)),
Some(mut acc) => {
acc.to_mut().extend(
deps.into_iter()
.map(|(name, spec)| (name.clone(), spec.clone())),
);
Some(acc)
}
})
}
where, default comes last.

But I'm not quite sure the order of features in this snippet

fn pypi_options(&self) -> PypiOptions {
// Collect all the pypi-options from the features in one set,
// deduplicate them and sort them on feature index, default feature comes last.
let pypi_options: Vec<_> = self
.features()
.filter_map(|feature| {
if feature.pypi_options().is_none() {
self.workspace_manifest().workspace.pypi_options.as_ref()
} else {
feature.pypi_options()
}
})
.collect();
// Merge all the pypi options into one.
pypi_options
.into_iter()
.fold(PypiOptions::default(), |acc, opts| {
acc.union(opts)
.expect("merging of pypi-options should already have been checked")
})

@HernandoR
Copy link
Author

We need some tests on this feature. @tdejager can you assign someone?

@tdejager
Copy link
Contributor

@nichmor could you have a look seeing that I'm on holiday? Thanks! 🙏

@tdejager
Copy link
Contributor

Note you also need to add the specification to the full.toml file. Not sure about the name, on my phone currently. But contains all the available manifest options.

@tdejager
Copy link
Contributor

tdejager commented Jun 15, 2025

Yeah so the confusing thing for PyPI-options is that even when using no-default one can have workspace PyPI dependencies that are always added. And I think, but maybe @ruben-arts can verify is that we wanted the last defined feature to take precedence. However, I remember us explicitly going back and forth on this, and maybe deviating from how dependencies function. So I could very well be wrong. But I think how it is defined in code for PyPI-options is the correct way, so I'd suggest following that for now.

@HernandoR HernandoR force-pushed the lz/feat/pypi-overide branch from 277816c to b02834e Compare June 15, 2025 11:23
@HernandoR HernandoR force-pushed the lz/feat/pypi-overide branch from b02834e to 8106c97 Compare June 15, 2025 12:33
@HernandoR
Copy link
Author

HernandoR commented Jun 21, 2025

I rely heavily on this feature. Plz let me know when and how we can push this forward.

@nichmor nichmor self-assigned this Jun 22, 2025
@nichmor
Copy link
Contributor

nichmor commented Jun 22, 2025

I rely heavily on this feature. Plz let me know when and how we can push this forward.

assigning to me. I will review it tomorrow and let you know how we can continue with it.

@nichmor
Copy link
Contributor

nichmor commented Jun 23, 2025

I think we also need to write an integration test here. You can take a look at tests/integration_python/test_pypi_options.py and add a similar one for overrides. You will run pixi install and then you can assert that the override version is indeed present in the lockfile.

let me know if you will have questions

@HernandoR HernandoR force-pushed the lz/feat/pypi-overide branch 2 times, most recently from 1a92767 to aa7c530 Compare June 28, 2025 04:45
@HernandoR
Copy link
Author

@nichmor. I added an integration test. But I don't know how to run it without uninstalling my existing installed pixi

@tdejager
Copy link
Contributor

There are pixi tasks that use the compiled version :) Check the pixi.toml for the list of them :)

@HernandoR
Copy link
Author

@tdejager i updated the test case and passed test-integration-fast, but i don't know how to find the solved lock file.

@HernandoR
Copy link
Author

@nichmor I have added integration test, and verified that the generated lock file holds valid version.

@nichmor
Copy link
Contributor

nichmor commented Jul 4, 2025

@nichmor I have added integration test, and verified that the generated lock file holds valid version.

thanks for the update! I will take a look today.
meanwhile, could you please solve the merge conflicts? so we could run all the tests

@HernandoR HernandoR requested a review from nichmor July 5, 2025 09:08
@HernandoR HernandoR marked this pull request as ready for review July 5, 2025 09:08
Copy link
Author

@HernandoR HernandoR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to me

Copy link
Contributor

@nichmor nichmor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two small stuff and it is ready to merge!

@tdejager tdejager added the test:extra_slow Run the extra slow tests label Jul 11, 2025
@tdejager
Copy link
Contributor

I merged main and added extra slow tests, these test a lot of PyPI integration stuff :)

Copy link
Contributor

@nichmor nichmor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one small one and we are ready to go!

Copy link
Contributor

@nichmor nichmor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for the work!

I think if you fix the tests we can merge it

@HernandoR
Copy link
Author

@nichmor I can't reproduce this CI issue locally. It may be a temporary network problem. Could you please re-trigger the CI?

@HernandoR HernandoR requested a review from tdejager July 14, 2025 22:30
@HernandoR
Copy link
Author

I really got no clue of the relation between the failed CI test and changes in this PR.

@nichmor
Copy link
Contributor

nichmor commented Jul 17, 2025

It seems that it is related with the timeout - I will take a look tomorrow and will take care of merging it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test:extra_slow Run the extra slow tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants