jfrog / build-info-go

build-info-go is a Go library and a CLI, which allows generating build-info for a source code project.
https://www.buildinfo.org
Apache License 2.0
61 stars 34 forks source link

Strange assumptions made about poetry virtualenvs #113

Open rvodden opened 1 year ago

rvodden commented 1 year ago

Describe the bug

Poetry build is making very strange assumptions about the nature of the virtualenv which poetry creates.

Current behavior

As far as I'm aware I have a completely normal poetry setup. I'm using pyenv to manage my virtual environments. When I run bi poetry install i get the following output:

[Error] failed extracting python site package form the following virtual env "/home/rvodden/.pyenv/versions/3.10.7/envs/library"

Reproduction steps

install pyenv create a virtualenv using pyenv create a poetry project in that virtualenv run bi poetry install

Expected behavior

I'd expect bi to use correct semantics to establish the location of site-packages. For example, this command:

poetry run python -c 'import site; print(site.getsitepackages())'

will reliably report the location of site-packages. I don't really follow the logic which is employed to extract the site-packages location here: https://github.com/jfrog/build-info-go/blob/main/utils/pythonutils/poetryutils.go#L211-L217

It looks to be making very specific assumptions about how virtualenvs are arranged which at first glance would appear to be more likely to be incorrect than correct in the majority of circumstances

Operating system type and version

ubuntu 20.04 i686

rvodden commented 1 year ago

I have raised the following pull request to address this issue. Note that my original suggestion of using the site package doesn't work when using the python virtualenv module, and so I've used the sysconfig package instead.

https://github.com/jfrog/build-info-go/pull/114