Files
pack/examples/python-pip/app.py
T
db4b126204 fix: support idiomatic version files when determining resolved python version (#378)
* fix: ensure idiomatic version files are detected via explicit environment variables

When mise is run with MISE_CEILING_PATHS to sandbox the environment, it
cannot read the root mise.toml which contains the
idiomatic_version_file_enable_tools setting. This caused .python-version,
.node-version, and .ruby-version files to potentially be ignored.

This fix explicitly sets MISE_IDIOMATIC_VERSION_FILE_ENABLE_TOOLS via
environment variable to ensure these version files are always detected,
regardless of whether the root mise.toml is accessible.

* chore: add tmp/ to gitignore for temporary test files

* refactor: extract idiomatic version file tools to shared constant and add test

- Create IdiomaticVersionFileTools constant in core/mise package
- Update both mise.go and mise_step_builder.go to use shared constant
- Add TestGetPackageVersionsWithIdiomaticVersionFile to test .python-version detection

Why the original tests didn't catch this:
- TestGetPackageVersions uses python-uv-tool-versions which has .tool-versions
- Mise reads .tool-versions by default without idiomatic_version_file setting
- The new test uses python-uv which has .python-version (idiomatic version file)
- This ensures idiomatic version file detection is properly tested going forward

* test: add .python-version integration test to python-pip example

- Remove unit test in favor of integration test coverage
- Add .python-version (3.11) to python-pip example
- Update app.py to print Python version
- Update test.json to assert Python 3.11 is used

This ensures .python-version files (different from default 3.13) are
properly detected and used during builds. The integration test covers
the full build pipeline, catching issues that unit tests alone would miss.

* docs: document why python-pip uses Python 3.11 for testing

Explain that .python-version is set to 3.11 (different from default 3.13)
to ensure idiomatic version file detection is properly tested.

* refactor: use specific patch version and remove unnecessary MISE_EXPERIMENTAL

- Update .python-version to 3.11.14 (specific patch version)
- Update test.json to assert full version 3.11.14
- Remove MISE_EXPERIMENTAL=1 (testing confirms it's not needed)
- Update README to reflect patch version

Using a specific patch version makes the test more precise and better
validates that the exact version from .python-version is being used.

* refactor: improve python-pip test clarity and use 3.11.11

- Change patch version to 3.11.11
- Move documentation to inline comment in .python-version
- Fix output message from "Hello from UV" to "Hello from pip"
- Remove separate README.md file

The inline comment explains why this specific version is used without
needing a separate documentation file.

* Revert "chore: add tmp/ to gitignore for temporary test files"

This reverts commit 2f767deca2ae04ee12f866182bee6c82354dbbce.

* test: remove comment from .python-version

interesting, found a mise idiomatic parsing bug

* test: update snapshots

---------

Co-authored-by: Hanzo Dev <[email protected]>
2026-01-15 07:19:18 -07:00

14 lines
330 B
Python

import sys
import numpy as np
import pandas as pd
import os
path = os.environ['PATH']
assert path.startswith("/app/.venv/bin"), f"Expected PATH to start with /app/.venv/bin but got {path}"
print(f"Python version: {sys.version.split()[0]}")
print("numpy", np.__version__)
print("pandas", pd.__version__)
print("Hello from pip")