Skip to content

Conversation

FindHao
Copy link
Member

@FindHao FindHao commented Oct 4, 2025

Problem

After installing the package via pip install, running tritonparse --help resulted in the following error:

Traceback (most recent call last):
  File "/scratch/findhao/miniconda3/envs/test/bin/tritonparse", line 3, in <module>
    from tritonparse.run import main
ModuleNotFoundError: No module named 'tritonparse.run'

Root Cause: The pyproject.toml entry point was configured as tritonparseoss = "tritonparse.run:main", but the run.py file was located at the project root instead of inside the tritonparse/ package directory.

Solution

Restructured the CLI entry point to follow standard Python package conventions:

  1. Created tritonparse/cli.py: Moved the complete CLI implementation into the package directory
  2. Modified root run.py: Converted it into a lightweight wrapper that imports from tritonparse.cli
  3. Updated entry points: Changed references from tritonparse.run to tritonparse.cli in both __main__.py and pyproject.toml

This approach:

  • ✅ Fixes the ModuleNotFoundError after installation
  • ✅ Maintains backward compatibility (root run.py still works)
  • ✅ Uses clearer naming (cli.py explicitly indicates command-line interface)
  • ✅ Follows standard Python package structure conventions
  • ✅ Centralizes CLI implementation in a single maintainable location

Changes

New Files

  • tritonparse/cli.py: Complete CLI implementation with argparse setup and command handlers

Modified Files

  • run.py: Simplified to a wrapper that imports and calls main() from tritonparse.cli
  • tritonparse/__main__.py: Updated import from .run to .cli
  • pyproject.toml: Changed entry point from tritonparse.run:main to tritonparse.cli:main

Testing

All three entry points now work correctly:

# 1. Installed command-line tool
$ tritonparseoss --help
usage: tritonparseoss [-h] [--version] {parse,reproduce} ...
...

# 2. Direct script execution
$ python run.py --help
usage: tritonparseoss [-h] [--version] {parse,reproduce} ...
...

# 3. Module execution
$ python -m tritonparse --help
usage: tritonparseoss [-h] [--version] {parse,reproduce} ...
...

Impact

  • Users: Can now successfully use the tritonparseoss command after installation
  • Developers: Root run.py continues to work for local development
  • Maintenance: Single source of truth for CLI logic in tritonparse/cli.py

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 4, 2025
Summary:
- Moved the main application logic from `run.py` to a new `cli.py` file for better organization.
- Updated `pyproject.toml` to reflect the new entry point for the CLI.
- Adjusted `__main__.py` to import the main function from `cli.py`.
- This change enhances the modularity of the codebase and prepares for future CLI enhancements.

Files modified: `pyproject.toml`, `run.py`, `tritonparse/__main__.py`, `tritonparse/cli.py` (new file).
@FindHao FindHao force-pushed the findhao/fix_pip_package branch from 2638a9b to 139980a Compare October 6, 2025 22:38
@FindHao FindHao marked this pull request as draft October 6, 2025 22:39
Copy link

meta-codesync bot commented Oct 6, 2025

@FindHao has imported this pull request. If you are a Meta employee, you can view this in D84015472.

@FindHao FindHao marked this pull request as ready for review October 6, 2025 23:45
@meta-codesync meta-codesync bot closed this in c67b5f6 Oct 7, 2025
Copy link

meta-codesync bot commented Oct 7, 2025

@FindHao merged this pull request in c67b5f6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants