Skip to content

Set environment variables before installing dependencies #4330

Closed

Description

@0x1997

Problem description

I have a python & rust mixed project. My pyproject.toml is basically like this

[build-system]
requires = ["maturin>=1.8.6,<2.0"]
build-backend = "maturin"

[project]
name = "mypkg"
version = "1.0.0"
description = "mypkg"
readme = "README.md"
requires-python = ">=3.13"
dependencies = []

[project.scripts]
mypkg = "mypkg.main:run_module"

[tool.pixi.project]
channels = ["conda-forge"]
platforms = ["win-64"]

[tool.pixi.dependencies]
python = "3.13.*"

[tool.pixi.pypi-dependencies]
mypkg = { path = ".", editable = true }      # so I can use it like `pixi run mypkg --args`

# [tool.pixi.target.win.activation.env]
# ASSET_DIR = "web\\dist"
# PROTOC = "%CONDA_PREFIX%\\Library\\bin\\protoc.exe"
# SQLITE3_INCLUDE_DIR = "%CONDA_PREFIX%\\Library\\include"
# SQLITE3_LIB_DIR = "%CONDA_PREFIX%\\Library\\lib"

[tool.maturin]
module-name = "mypkg._mypkg"
features = ["pyo3/extension-module"]
manifest-path = "crates/mypkg/Cargo.toml"

The commented out sections of environment variables are needed by the build script of the rust crate. But they are not available when maturin is run. Updated PATH is also not available at that stage, so I need PROTOC instead of locating protoc from PATH.
Currently I have to manage them with another tool like mise which adds another layer of complexity.

Activity

  1. 0x1997 commented on Aug 13, 2025

    @0x1997
    Author

    @lucascolley Thanks, I tried to update my project accordingly but failed to pin python to 3.13.

    This is a sample repo.

    $ git clone https://github.com/0x1997/pixi-maturin.git
    $ pixi i
    Error:   × failed to solve requirements of environment 'default' for platform 'win-64'
      ├─▶ failed to solve the environment
      ╰─▶ Cannot solve the request because of: python 3.13.* cannot be installed because there are no viable options:
          └─ python 3.13.0 | 3.13.0 | 3.13.0 | 3.13.0 | 3.13.1 | 3.13.1 | 3.13.1 | 3.13.1 | 3.13.1 | 3.13.1 | 3.13.1 |
          3.13.1 | 3.13.1 | 3.13.1 | 3.13.2 | 3.13.2 | 3.13.2 | 3.13.2 | 3.13.3 | 3.13.3 | 3.13.3 | 3.13.3 | 3.13.5 |
          3.13.5 | 3.13.5 | 3.13.5 | 3.13.5 | 3.13.5 would require
             └─ python_abi 3.13.* *_cp313t, for which no candidates were found.
    
  2. lucascolley commented on Aug 13, 2025

    @lucascolley
    Member

    try adding python = "3.13.*" to package.host-dependencies?

    I think this is something we need to fix though, having a package available for multiple Python versions and automatically choosing one at the workspace level with a Python dependency. I will look into it.

  3. lucascolley commented on Aug 13, 2025

    @lucascolley
    Member

    just going to move this to a discussion as there isn't a clear bug/feature request yet

  4. locked and limited conversation to collaborators on Aug 13, 2025
  5. converted this issue into a discussion #4336 on Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions