Skip to content

355 ewoks install pixi always installs the default environment - #356

Open
clarka34 wants to merge 11 commits into
mainfrom
355-ewoks-install-pixi-always-installs-the-default-environment
Open

clarka34 wants to merge 11 commits into
mainfrom
355-ewoks-install-pixi-always-installs-the-default-environment

Conversation

@clarka34

Copy link
Copy Markdown
Member

PR summary

Closes #355

ewoks install with pixi always installed the default environment of the workspace, even when the requirements were gathered in another pixi environment. The requirements now record the name of the pixi environment, and the install uses it.

Recording the pixi environment name

  • A new field, pixi_environment_name, was added to the pixi manager.
  • _gather_extra_fields() was added to BaseManager: each package manager can add its own fields to its manager info if needed.

Installing the pixi environment

  • files_environment() was added to BaseManager: each package manager can set the environment in which the files of the requirements are installed if needed. Ex: Pixi returns <workspace>/.pixi/envs/<pixi_environment_name> instead of <workspace>/.pixi/envs/default
  • pixi install and pixi add now pass --environment.
  • When installing the pixi files fails, the fallback still installs the python distributions in default.

Tests

  • Tests added for gathering the pixi environment name and for selecting the environment to install.

AI Disclosure

  • No AI used
  • Claude used for reviewing and tests

@clarka34 clarka34 self-assigned this Oct 22, 2026
@clarka34 clarka34 linked an issue Oct 22, 2026 that may be closed by this pull request
examples=[{"requirements.txt": "ewoks==7.0.0\nnetworkx==3.4.2\n"}],
)

@model_serializer(mode="wrap")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Adding this to put files at the end of the manager section so it's more readable.

"""Environment the manager creates at this location."""
return Environment.at_location(location, self.ENVIRONMENT_SUBDIR)

def files_environment(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Allows pixi to override this and install into the environment named in the requirements instead of default.

"""
return dict()

def _gather_extra_fields(self) -> Dict[str, str]:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Allows pixi to override this and add an extra field, pixi_environment_name, to record the environment name.

@clarka34

Copy link
Copy Markdown
Member Author

The CI issue will be fixed in: #357

@clarka34
clarka34 requested a review from woutdenolf October 22, 2026 12:47
@clarka34
clarka34 force-pushed the 355-ewoks-install-pixi-always-installs-the-default-environment branch from d006a93 to 4872766 Compare October 23, 2026 07:09
@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.44068% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/ewoks/_requirements/utils/base_manager.py 72.22% 5 Missing ⚠️
src/ewoks/_requirements/pixi.py 87.50% 2 Missing ⚠️
src/ewoks/_requirements/__init__.py 75.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@woutdenolf woutdenolf left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Claude found that the env name change (not necessarily called default) was not covered everywhere:

Location is unchanged, but the prefix is no longer always default. That breaks later lookups.

  • ewoks execute --env <name> runs the wrong Python

    • command_in_environment (__main__.py) uses Environment.from_location().
    • It only scans ENVIRONMENT_SUBDIRS: "", .venv, .pixi/envs/default.
    • create_environment still builds default first, so for a workspace installed from env test, from_location returns the empty default env, not .pixi/envs/test.
    • Only install_requirements returns the right environment.
    • Suggestion: make the lookup find the real environment (e.g. scan .pixi/envs/*, or record the subdir in the workspace). A test with a non-default name through from_location would cover it.
  • Empty default env is still created

    • create_environment runs pixi install on an empty manifest before the files are installed.
    • Wasteful, and it is what makes the point above silently pick the wrong env.
  • _owns / is_native still assume default

    • They compare against ENVIRONMENT_SUBDIR, so they return False for the non-default env.
    • Fine today because is_native runs before files_environment, but fragile.
  • pixi add --environment needs pixi >= 0.74

    • _add_ewoks now always passes --environment, also for default.
    • pixi add has no --environment option before 0.74, as far as I can tell: it came with inline environments (prefix-dev/pixi#6497).
    • So with an older pixi, ewoks install fails at its last step (adding ewoks), even for the default env.
    • Nothing checks the pixi version. I suggest passing --environment only when the name is not default. Otherwise, add a minimum version check like the one in poetry.py.
  • Minor

    • PIXI_ENVIRONMENT_NAME takes precedence over sys.prefix; they can disagree if the interpreter is not the one pixi activated.

Related: #353 (install location). Both need one way to resolve "the environment of a location" instead of fixed subdirs. I can make a follow-up for both.

@clarka34
clarka34 force-pushed the 355-ewoks-install-pixi-always-installs-the-default-environment branch from 6570627 to be75292 Compare November 3, 2026 16:08

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ewoks install: pixi always installs the default environment

2 participants