-
Notifications
You must be signed in to change notification settings - Fork 776
[release/13.0] Add WithPip following Node.js patterns and rename AddPythonScript to AddPythonApp #12704
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Created PythonPipInstallerResource for pip package installation - Added WithPip extension method following WithNpm/WithYarn pattern - Renamed WithUvEnvironment to WithUv (with obsolete redirect) - Auto-detect requirements.txt and call WithPip in run mode - Pip executable is resolved from virtual environment - Updated all usages in tests, playground, and templates - Fixed test failures by filtering for PythonAppResource specifically Co-authored-by: davidfowl <[email protected]>
- WithUv now defaults to ["sync", "--python"] to bootstrap Python automatically - Added optional args parameter to allow customization of uv sync arguments - Updated documentation to reflect the new --python flag - Updated tests to verify the new default arguments - All tests passing Co-authored-by: davidfowl <[email protected]>
- Created PythonPackageManagerAnnotation, PythonInstallCommandAnnotation, and PythonPackageInstallerAnnotation - Created unified PythonInstallerResource to replace separate pip and uv resources - Refactored WithPip and WithUv to use shared AddInstaller helper method - Package manager methods now replace each other (WithPip after WithUv replaces uv with pip, and vice versa) - Added tests to verify replacement behavior - All 77 tests passing Co-authored-by: davidfowl <[email protected]>
…ironmentResource) These have been replaced by the unified PythonInstallerResource Co-authored-by: davidfowl <[email protected]>
- Auto-detect pyproject.toml and add WithUv (takes precedence over requirements.txt) - Auto-detect requirements.txt and add WithPip (fallback if no pyproject.toml) - Added 4 tests to verify auto-detection behavior - All 81 tests passing Co-authored-by: davidfowl <[email protected]>
- WithPip now detects which file exists and uses the appropriate install command - pyproject.toml: uses 'pip install .' - requirements.txt: uses 'pip install -r requirements.txt' - Auto-detection now uses pip for both pyproject.toml and requirements.txt - Updated tests to verify pip is used for both file types - All 81 tests passing Co-authored-by: davidfowl <[email protected]>
- Created PythonVenvCreatorResource to create virtual environment if it doesn't exist - Venv creator runs before the installer (pip/uv) when using pip - Only creates venv if not using uv and venv doesn't exist - Installer waits for venv creator to complete before running - All 81 tests passing Co-authored-by: davidfowl <[email protected]>
- Removed WithUvEnvironment (obsolete method) - Removed env.Uv property from PythonEnvironmentAnnotation - Infer UV usage from PythonPackageManagerAnnotation instead - Don't fail if there's no package manager configured (just don't run installer) - Create venv only when package manager needs it (checked via pyvenv.cfg) - Support both python and python3 commands for venv creation - On Windows: try py launcher first, fallback to python - On Unix: try python3 first, fallback to python - Updated all documentation references from WithUvEnvironment to WithUv - All 81 tests passing Co-authored-by: davidfowl <[email protected]>
- Added optional bool parameter createIfNotExists (defaults to true) - When false, disables automatic venv creation - Added CreateVenvIfNotExists property to PythonEnvironmentAnnotation - AddVenvCreator now checks this flag before creating venv - Added 3 tests to verify the behavior - All 84 tests passing Co-authored-by: davidfowl <[email protected]>
- Moved venv creator management to BeforeStartEvent in AddPythonAppCore - Venv creators are now keyed by directory path, not resource name - Multiple resources sharing same venv directory use single venv creator - WithPip creates default .venv if no virtual environment configured - WithUv disables venv creation (uv handles it) - WithVirtualEnvironment createIfNotExists parameter controls venv creation - All venv creation logic runs at BeforeStart to respect final annotation state - Installer waits for venv creator if it exists Co-authored-by: davidfowl <[email protected]>
- Removed directory-based venv creator sharing approach - Created one venv creator per resource as a child resource (simpler, clearer) - Use TryCreateResourceBuilder to check for existing venv creator - WithVirtualEnvironment(createIfNotExists: false) removes venv creator - WithPip creates venv creator after adding package manager annotation - WithUv disables venv creation (uv handles it) - Installer waits for venv creator when it exists - All 92 tests passing Co-authored-by: davidfowl <[email protected]>
- Venv is now created even when there's no package manager configured - If no pyproject.toml or requirements.txt exists, venv creator is still added - WithVirtualEnvironment(createIfNotExists: false) removes venv creator regardless of package manager - Fixed linting issues with null checks - 85/92 tests passing (7 tests failing, need investigation) Co-authored-by: davidfowl <[email protected]>
- Moved wait dependency setup to BeforeStartEvent as suggested - This allows methods to add/remove resources dynamically - Wait relationships are established based on final resource state - Currently 10/92 tests failing - issue is BeforeStartEvent fires after Build() in tests - Need different approach or tests need adjustment to use app.StartAsync() to trigger event Co-authored-by: davidfowl <[email protected]>
… use FindFullPathFromPath pattern - Renamed SetupWaitDependencies to SetupDependencies - SetupDependencies now only runs in run mode (BeforeStartEvent subscription only in run mode) - Make venv and installer resources children with WithParentRelationship - Updated IsPythonCommandAvailable to use FindFullPathFromPath pattern like BicepCompiler - Added PublishBeforeStartEventAsync helper for tests (not yet used) - Build passing, ready to add test calls to publish event Co-authored-by: davidfowl <[email protected]>
- Updated tests to filter for PythonAppResource when checking single executable resource - Made tests that check WaitAnnotation async and call PublishBeforeStartEventAsync - Removed unnecessary annotation clearing from SetupDependencies (AddInstaller never sets them) - All 92 Python hosting tests passing Co-authored-by: davidfowl <[email protected]>
- Replaced manual search with TryCreateResourceBuilder pattern - Follows the same pattern used in Node.js hosting extensions - More idiomatic and cleaner code - All 92 tests passing Co-authored-by: davidfowl <[email protected]>
- Renamed AddPythonScript to AddPythonApp (main entry point method) - Added [OverloadResolutionPriority(1)] attribute to AddPythonApp - Made obsolete AddPythonApp (old) into AddPythonScript (obsolete) - Updated XML doc comments to reference new method names - All 92 tests passing Co-authored-by: davidfowl <[email protected]>
…rectly - Removed obsolete AddPythonScript method (was previously AddPythonApp) - Renamed AddPythonScript (main entry point) to AddPythonApp - Added [OverloadResolutionPriority(1)] to AddPythonApp - Updated all test usages from AddPythonScript to AddPythonApp - Updated all XML documentation references - Build passing, all tests updated Co-authored-by: davidfowl <[email protected]>
- Changed default args from ["sync", "--python"] to ["sync"] - The --python flag requires a value, causing "error: a value is required for '--python'" - uv sync alone will auto-detect Python from pyproject.toml or system - Users can still pass custom args like ["sync", "--python", "3.11"] if needed - All 92 tests passing Co-authored-by: eerhardt <[email protected]>
Contributor
Author
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12704Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12704" |
eerhardt
approved these changes
Nov 5, 2025
davidfowl
approved these changes
Nov 5, 2025
Member
|
@joperezr why don't these PRs have a milestone? Is the policy bot broken for these PRs? |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #12667 to release/13.0
/cc @davidfowl @copilot
Customer Impact
Big API changes to align the python patterns with the JavaScript patterns. Also made python work without uv.
Testing
Automated and manual.
Risk
Medium
Regression?
No