Skip to content

feat: add Python/pip support to CLI scanner#5

Open
yuchengpersonal wants to merge 1 commit intodusan-maintains:mainfrom
yuchengpersonal:feat/add-python-support
Open

feat: add Python/pip support to CLI scanner#5
yuchengpersonal wants to merge 1 commit intodusan-maintains:mainfrom
yuchengpersonal:feat/add-python-support

Conversation

@yuchengpersonal
Copy link
Copy Markdown

Summary

This PR adds support for scanning Python dependencies, addressing issue #2.

Changes

  • Added parseRequirementsTxt() function: Parses requirements.txt files and extracts package names (handles various version specifiers like ==, >=, etc.)
  • Added parsePyprojectToml() function: Parses pyproject.toml files and extracts dependencies from the [project] section
  • Added readRequirementsTxt() and readPyprojectToml() functions: Handle file reading and validation for Python project files
  • Updated readPackageJson() function: Now detects Python project files first, falling back to package.json if no Python files are found
  • Updated error messages: Now mention all supported file types (package.json, requirements.txt, pyproject.toml)

Usage

Users can now run the scanner in Python projects:

# In a directory with requirements.txt or pyproject.toml
npx oss-health-scan

# Or specify a directory
npx oss-health-scan path/to/python-project

Testing

Tested with sample requirements.txt:

  • Correctly parses package names with various version specifiers
  • Ignores comments and empty lines
  • Handles -r and other pip options gracefully

Related Issue

Fixes #2

Add support for scanning Python dependencies from:
- requirements.txt
- pyproject.toml

Changes:
- Add parseRequirementsTxt() to parse requirements.txt files
- Add parsePyprojectToml() to parse pyproject.toml dependencies
- Add readRequirementsTxt() and readPyprojectToml() functions
- Update readPackageJson() to detect and handle Python project files
- Update error message to mention all supported file types

Fixes dusan-maintains#2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Python/pip support to CLI scanner

1 participant