Skip to content

Automatic package detection fails if any field contains --- #130

@Titou325

Description

@Titou325

Hi!

We are starting to use scip-python to index our codebases, but have encountered a few issues getting the dependency detection to work properly.

It seems that for some libraries, notably for numpy, the pip show numpy may return additional fields, which in turn contain ---.
In the case of Numpy, the License: field returns something like this:

Name: numpy
Version: 1.26.0
Summary: Fundamental package for array computing in Python
Home-page: https://numpy.org
Author: Travis E. Oliphant et al.
Author-email: None
License: Copyright (c) 2005-2023, NumPy Developers.
        All rights reserved.

        [........]

        THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

        ----

        This binary distribution of NumPy also bundles the following software:


        Name: GCC runtime library
        Files: .dylibs/*

However this breaks the parsing script at https://github.com/sourcegraph/scip-python/blob/scip/packages/pyright-scip/src/virtualenv/environment.ts#L40C7-L40C7 which expects triple dashes to separate packages.

An easy fix would be to replace split('---') with split('\n---') to prevent taking into account any nested ---.

I have attached a PR.

Thanks for the hard work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions