Skip to content

Conversation

@vdusek
Copy link
Contributor

@vdusek vdusek commented Jan 27, 2026

This is just a draft for you guys @vladfrangu, @l2ysho, from Claude based on our long Slack conversation. I'll be happy to answer your potential questions about Python projects, but I won't be able to further help you with the implementation.

This unblocks apify/actor-templates#361.


Enhance Python project detection to support standard package layouts without enforcing specific directory names. This change makes the CLI more flexible and user-friendly for Python developers.

Changes

  • Enhanced project detection: Now detects Python projects by checking for pyproject.toml, requirements.txt, or .py files (not just __main__.py)
  • Package discovery: Automatically discovers Python packages in CWD and src/ subdirectory
  • Smart entrypoint resolution: Selects the entrypoint when exactly one package is found
  • Better error messages: Provides clear, actionable guidance for all failure scenarios:
    • No packages found (with structure examples)
    • Multiple packages found (with list and usage example)
    • Mixed Python/Node.js projects detected
  • Backwards compatible: Existing projects with src/__main__.py continue to work

Implementation Details

  • Added isPythonProject() for flexible project detection
  • Added discoverPythonPackages() to find valid packages (level 1 and 2 only)
  • Added findPythonEntrypoint() with enhanced error handling
  • Added mixed project detection to prevent ambiguous configurations
  • Updated test to properly test "no detection" scenario

Testing

  • All existing Python tests pass
  • No regressions in other test suites
  • Supports standard Python layouts: my_package/, src/my_package/

Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com

Enhance Python project detection to support standard package layouts without enforcing specific directory names. This change makes the CLI more flexible and user-friendly for Python developers.

## Changes

- **Enhanced project detection**: Now detects Python projects by checking for `pyproject.toml`, `requirements.txt`, or `.py` files (not just `__main__.py`)
- **Package discovery**: Automatically discovers Python packages in CWD and `src/` subdirectory
- **Smart entrypoint resolution**: Selects the entrypoint when exactly one package is found
- **Better error messages**: Provides clear, actionable guidance for all failure scenarios:
  - No packages found (with structure examples)
  - Multiple packages found (with list and usage example)
  - Mixed Python/Node.js projects detected
- **Backwards compatible**: Existing projects with `src/__main__.py` continue to work

## Implementation Details

- Added `isPythonProject()` for flexible project detection
- Added `discoverPythonPackages()` to find valid packages (level 1 and 2 only)
- Added `findPythonEntrypoint()` with enhanced error handling
- Added mixed project detection to prevent ambiguous configurations
- Updated test to properly test "no detection" scenario

## Testing

- All existing Python tests pass
- No regressions in other test suites
- Supports standard Python layouts: `my_package/`, `src/my_package/`

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@vdusek vdusek added this to the 133rd sprint - Tooling team milestone Jan 27, 2026
@vdusek vdusek self-assigned this Jan 27, 2026
@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Jan 27, 2026
@github-actions github-actions bot added the tested Temporary label used only programatically for some analytics. label Jan 27, 2026
@vdusek vdusek changed the title feat: improve Python project detection and entrypoint resolution fix: Improve Python project detection and entrypoint resolution Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants