Skip to content

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

Merged
clarka34 merged 15 commits into
mainfrom
355-ewoks-install-pixi-always-installs-the-default-environment
Nov 5, 2026
Merged

clarka34 merged 15 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
@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 87.14286% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/ewoks/_requirements/pixi.py 84.61% 4 Missing ⚠️
src/ewoks/_requirements/utils/base_manager.py 78.94% 4 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
@clarka34

clarka34 commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

Thanks @woutdenolf! Sorry for the delay on this. I wanted to check that the tests were also passing for windows.

To address the comments:
ewoks execute --env runs the wrong Python

  • I removed .pixi/envs/default from ENVIRONMENT_SUBDIRS. from_location now scans .pixi/envs/*: it uses the only environment, or default with a warning when there are several, or raises when there are several and none is default.
  • ewoks execute --env now prints which environment it runs in.

Empty default env is still created

  • I changed create_environment, so that it no longer runs pixi install. The environment is only created when the requirements are installed.

_owns / is_native still assume default

  • default is still the placeholder before files_environment picks the environment of the files. I left this as is because is_native always runs first, and the docstring of environment() now explains it.

pixi add --environment needs pixi >= 0.74

  • I removed --environment from pixi add. Now, ewoks is always added to the default feature, then pixi install --environment <name> installs the named environment. This works because named environments include the default feature (unless they set no-default-feature).

PIXI_ENVIRONMENT_NAME vs sys.prefix

  • The name now comes only from sys.prefix

@clarka34
clarka34 requested a review from woutdenolf November 5, 2026 09:11
Comment thread src/ewoks/_requirements/pixi.py Resolved
Comment thread src/ewoks/_requirements/pixi.py Resolved
Comment thread src/ewoks/_requirements/pixi.py Resolved
@woutdenolf

Copy link
Copy Markdown
Member

Some suggestions but LGTM otherwise. Thanks!

Co-authored-by: Wout De Nolf <wout.de_nolf@esrf.eu>
@clarka34

clarka34 commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

Thanks for the suggestions! I applied your changes.

@clarka34
clarka34 merged commit 4a6b2c3 into main Nov 5, 2026
16 checks passed
@clarka34
clarka34 deleted the 355-ewoks-install-pixi-always-installs-the-default-environment branch November 6, 2026 12:00
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