Adding requirements which are not explicitly imported using import statement
- Dominant language
- Python
- Stars
- 7.5k
- Forks
- 424
- PR merge metrics
- No merged PRs in 30d
Description
What is the best way to add requirements such requirements to the file automatically with pipreqs?
Example:
beatifulsoup4 can use lxml as an html parser, but it's not imported by my scripts and as such pipreqs won't include it in requirements.txt
```
from bs4 import BeautifulSoup
soup = BeautifulSoup(start_page.text, "lxml")
```
another example is sqlalchemy using pyodbc to connect to SQL Server. Pyodbc is required for the script to run but it's not explicitly imported and pipreqs misses it.
```
import sqlalchemy
engine = sqlalchemy.create_engine(
"mssql+pyodbc://INSTANCE/DB?trusted_connection=yes&driver=ODBC+Driver+17+for+SQL+Server"
)
```
What should I do in this case, as I'm running pipreqs automatically as part of deployment and it removes pyodbc and lxml from requirements.txt...
Contributor guide
Research direction
The issue names no files, tests, or entry points. Start by tracing how pipreqs discovers imports, then determine how the BeautifulSoup/lxml and SQLAlchemy/pyodbc examples could identify runtime requirements and how completion would be verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlalchemy
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100