aboutcode-org / aboutcode-org/scancode-toolkit

Detect setuptools.setup() calls when parsing setup.py

Đang mở
#2,742 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug package scan package-formats starter
Ngôn ngữ chính
Python
Star
2.6k
Fork
791
Merge trung bình
1 ngày 12 giờ
Pull request đã merge (30 ngày)
5

Mô tả

### Description

A somewhat common pattern for setup.py is to have `import setuptools;setuptools.setup()`-like calls
We do not parse these correctly

See https://github.com/search?q="setuptools.setup"+filename%3Asetup.py+language%3APython+language%3APython&type=Code&ref=advsearch&l=Python&l=Python and https://raw.githubusercontent.com/BlueBrain/BluePyOpt/6d4185479bc6dddb3daad84fa27e0b8457d69652/setup.py as reported in https://github.com/oss-review-toolkit/ort/issues/4578 by @alex4200

The fix should be to detect a`setuptools.setup` call in the AST the same way we detect `setup()` call, and this should be straightforward.

### How To Reproduce

1. fetch https://raw.githubusercontent.com/BlueBrain/BluePyOpt/6d4185479bc6dddb3daad84fa27e0b8457d69652/setup.py
2. run a package scan: `scancode -p setup.py --yaml -`
3. The `dependencies` should not be empty for the `package_manifest`

Editing the setup.py and replace `setuptools.setup` by `setup` is enough to get the dependencies alright:
```
dependencies:
- purl: pkg:pypi/numpy
requirement: '>=1.6'
scope: install
is_runtime: yes
is_optional: no
is_resolved: no
- purl: pkg:pypi/pandas
requirement: '>=0.18'
scope: install
is_runtime: yes
is_optional: no
is_resolved: no
- purl: pkg:pypi/deap
requirement:
scope: install
is_runtime: yes
is_optional: no
is_resolved: no
- purl: pkg:pypi/efel
requirement: '>=2.13'
scope: install
is_runtime: yes
is_optional: no
is_resolved: no
- purl: pkg:pypi/ipyparallel
requirement:
scope: install
is_runtime: yes
is_optional: no
is_resolved: no
- purl: pkg:pypi/pickleshare
requirement: '>=0.7.3'
scope: install
is_runtime: yes
is_optional: no
is_resolved: no
- purl: pkg:pypi/jinja2
requirement: '>=2.8'
scope: install
is_runtime: yes
is_optional: no
is_resolved: no
- purl: pkg:pypi/future
requirement:
scope: install
is_runtime: yes
is_optional: no
is_resolved: no
- purl: pkg:pypi/pebble
requirement: '>=4.3.10'
scope: install
is_runtime: yes
is_optional: no
is_resolved: no
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.