-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Python support to adhere to Python versions #3671
Comments
At least for
This at least tells you the minimum version to use. Similarly, a line like
might be contained. However, both types of entries are a bit inconvenient to parse. But even if the Python version to use would be known, another problem then is that you actually require that version to be installed. At least for our A completely different idea that I have in mind is to generally switch over to using GraalVM for ORT, and leverage its Python support to run pip programmatically, and somehow "pretending" to be the right Python version. |
Ping @pombredanne, being the Python guy here, do you have any good idea how to solve this problem? |
@sschuberth a way is to rely on If you want to go the dynamic pip route in anycase pip would resolve based on it current interpreter version and not some other version of Python. Note that pip now uses this bundled resolver https://github.com/sarugaku/resolvelib which you could also invoke directly and be in control of which os/python version/python/arch combo you are emulating. With that said there is no absolute right answer as each of these combos may resolve to different deps versions and different packages, unless you work from a lockfile, as each dep may be tagged like here
So to recap: each combo of
That said this is nothing really specific to Python AFAIK, just made ore visible here.
ScanCode knows how to parse these alright AFAIK. |
Does
Sure, because ScanCode is written in Python itself 😋 |
The resolvelib resolver library is "vendored" as-is in pip from what I can see (and I reckon I did study the code ;) ). FWIW, the vendoring is because pip cannot have external dependencies itself and needs things bundled to be able to bootstrap standalone.
Actually that's not really an advantage when we do static analysis. There is of course a clear and obvious advantage to use Python overall ;) but in the case of Python manifests proper, |
Except that you can more easily use the same Python libraries / functions as
You came to the wrong place for that statement 😄 When we meet in person again, I'll explain you why I basically like Python's syntax, but its ecosystem (and esp. dependency management) just sucks. I mean, there obviously are not even means to just query the transitive dependency tree without actually downloading all the binaries (that you don't need nor are interested in) and pretending to do a build (which is not what you want to do). But let's continue that discussion elsewhere 😉 |
Any progress on this? |
Why is this "inconvenient to parse"? classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
] There is always the nice |
I ran into this issue with the analyzer which was running python 3.6, but the project was developed for a newer python version. It had requirements like
Considering that the analyzer is creating a virtual environment, it would be nice if it could select a Python version. For my case I'll try running the analyzer with a newer Python version and running the Scanner with Python 3.6 as is required by Scancode toolkit. This will make it difficult to have an all-in-one Docker image though. |
The current version of ScanCode TK supports all Python versions from 3.6 to 3.9 .... so I am not sure what is the issue. We release the app bundle with support for Python 3.6 only for now... may be that's what is used here? |
To help the discussion, I looked into the available Python versions in Ubuntu, as that is currently used in the Dockerfile: For example the information on the default Python3 package in Focal can be found on the package page Considering that not all Python3.6+ versions are available in Bionic, perhaps we can create multiple Docker image variants for the analyzer with different tags? But considering the discussion above, it isn't necessary to have a complete Python installation, as long as the packages can be resolved for a specified Python version. That would make it far more flexible. |
@pombredanne my bad, I assumed this was still also an issue with ScanCode TK as there was another issue on that. Sorry for speaking bad about it then. I'll try switching to Focal to see if the entire setup works. If ScanCode is not holding us back, we could create multiple Docker image versions for specific Python versions for now. |
@nicorikken re:
You did not! :P
I chatted with @sschuberth about this a few weeks ago and there was an alternative... but I forgot which one! |
I started reworking the Docker image to Ubuntu 20.04, but now I see @heliocastro has already made this effort. And has also worked on multiple Python versions: #3613 #3902 I'll look into that work to see if I can remove my blockade. But on this issue, if we can avoid relying on system-wide Python versions for resolving Python dependencies, that would be great. |
Great work on ORT, it's an awesome project! I'm struggling with this issue. Wouldn't it be easier to be able to configure the project python version explictly, for example with an ENV variable as @heliocastro proposes in #3902 or with some other specific scanner yaml configuration? |
I just updated the new docker with final solution using pyenv, so please jump on #3902 to take a look. |
Some updates that are likely relevant here: https://github.com/nexB/python-inspector is now out and has been designed specifically to be integrated in ort. See also aboutcode-org#1 that we are refining there first before submitting to ort proper here. https://github.com/nexB/python-inspector features are that you can point it to requirements and pass it a target Python version and a target os/architecture and it will resolve the dependencies tree as pip does it, but without installing any of the packages. The target Python version and os can be different than the runtime Python and os. It internally uses the same resolution library as pip (resolvelib) and a pip requirements parser that we extracted from pip and is now in use in several other tools including CycloneDX. |
…ss-review-toolkit#3671 This PR replaces pipdeptree with python-inspector to resolve Python packages dependencies found in requirement files. python-inspector can resolve dependencies for any target Python version and OS (and not only the one running the tool). In this integration in ORT, it replaces pipdeptree pretty much in place as python-inspector implements a similar output data structure by design to ease the integration. Reference: https://github.com/nexB/python-inspector Reference: oss-review-toolkit#4637 Reference: oss-review-toolkit#3671 Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
…ss-review-toolkit#3671 This PR replaces pipdeptree with python-inspector to resolve Python packages dependencies found in requirement files. python-inspector can resolve dependencies for any target Python version and OS (and not only the one running the tool). In this integration in ORT, it replaces pipdeptree pretty much in place as python-inspector implements a similar output data structure by design to ease the integration. Reference: https://github.com/nexB/python-inspector Reference: oss-review-toolkit#4637 Reference: oss-review-toolkit#3671 Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
…ss-review-toolkit#3671 This PR replaces pipdeptree with python-inspector to resolve Python packages dependencies found in requirement files. python-inspector can resolve dependencies for any target Python version and OS (and not only the one running the tool). In this integration in ORT, it replaces pipdeptree pretty much in place as python-inspector implements a similar output data structure by design to ease the integration. Reference: https://github.com/nexB/python-inspector Reference: oss-review-toolkit#4637 Reference: oss-review-toolkit#3671 Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
…ss-review-toolkit#3671 This PR replaces pipdeptree with python-inspector to resolve Python packages dependencies found in requirement files. python-inspector can resolve dependencies for any target Python version and OS (and not only the one running the tool). In this integration in ORT, it replaces pipdeptree pretty much in place as python-inspector implements a similar output data structure by design to ease the integration. Reference: https://github.com/nexB/python-inspector Reference: oss-review-toolkit#4637 Reference: oss-review-toolkit#3671 Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
…ss-review-toolkit#3671 This PR replaces pipdeptree with python-inspector to resolve Python packages dependencies found in requirement files. python-inspector can resolve dependencies for any target Python version and OS (and not only the one running the tool). In this integration in ORT, it replaces pipdeptree pretty much in place as python-inspector implements a similar output data structure by design to ease the integration. Reference: https://github.com/nexB/python-inspector Reference: oss-review-toolkit#4637 Reference: oss-review-toolkit#3671 Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
…ss-review-toolkit#3671 This PR replaces pipdeptree with python-inspector to resolve Python packages dependencies found in requirement files. python-inspector can resolve dependencies for any target Python version and OS (and not only the one running the tool). In this integration in ORT, it replaces pipdeptree pretty much in place as python-inspector implements a similar output data structure by design to ease the integration. Reference: https://github.com/nexB/python-inspector Reference: oss-review-toolkit#4637 Reference: oss-review-toolkit#3671 Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
This PR replaces pipdeptree with python-inspector to resolve Python packages dependencies found in requirement files. python-inspector can resolve dependencies for any target Python version and OS (and not only the one running the tool). In this integration in ORT, it replaces pipdeptree pretty much in place as python-inspector implements a similar output data structure by design to ease the integration. Reference: https://github.com/nexB/python-inspector Reference: #4637 Reference: #3671 Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
This PR replaces pipdeptree with python-inspector to resolve Python packages dependencies found in requirement files. python-inspector can resolve dependencies for any target Python version and OS (and not only the one running the tool). In this integration in ORT, it replaces pipdeptree pretty much in place as python-inspector implements a similar output data structure by design to ease the integration. Reference: https://github.com/nexB/python-inspector Reference: oss-review-toolkit#4637 Reference: oss-review-toolkit#3671 Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
This PR replaces pipdeptree with python-inspector to resolve Python packages dependencies found in requirement files. python-inspector can resolve dependencies for any target Python version and OS (and not only the one running the tool). In this integration in ORT, it replaces pipdeptree pretty much in place as python-inspector implements a similar output data structure by design to ease the integration. Reference: https://github.com/nexB/python-inspector Reference: oss-review-toolkit#4637 Reference: oss-review-toolkit#3671 Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
This PR replaces pipdeptree with python-inspector to resolve Python packages dependencies found in requirement files. python-inspector can resolve dependencies for any target Python version and OS (and not only the one running the tool). In this integration in ORT, it replaces pipdeptree pretty much in place as python-inspector implements a similar output data structure by design to ease the integration. Reference: https://github.com/nexB/python-inspector Reference: oss-review-toolkit#4637 Reference: oss-review-toolkit#3671 Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
This PR replaces pipdeptree with python-inspector to resolve Python packages dependencies found in requirement files. python-inspector can resolve dependencies for any target Python version and OS (and not only the one running the tool). In this integration in ORT, it replaces pipdeptree pretty much in place as python-inspector implements a similar output data structure by design to ease the integration. Reference: https://github.com/nexB/python-inspector Reference: #4637 Reference: #3671 Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com> Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
@mnonnenmacher @fviernau can we already close this as 1208225 made the Python version configurable? |
Ticket linked with limitations[1] has been closed as Python version is now configurable. [1]: #3671 Signed-off-by: Thomas Steenbergen <thomas_steenbergen@epam.com>
Ticket linked with limitations[1] has been closed as Python version is now configurable. [1]: #3671 Signed-off-by: Thomas Steenbergen <thomas_steenbergen@epam.com>
For Python projects it is hard (impossible) to determine to which Python version they apply.
ORT has some mechanism which tries (1) Python 2.x and (2) Python 3. In particular, for the latter Python 3.6 is used.
When installing dependencies via
pip install -r requirements.txt
from pypi.org, pip considers only the dependencies which are compatible with the used Python version, 3.6.For example in a Python 3.7 project this can lead to the following two issues:
happens if none of the versions allowed by the constraints is compatible with Python 3.7.
the constraints does not equal the youngest 3.7 compatible version. In the worst case it can happen that the project uses the
latest version of a dependency while ORT resolves a really old (Python 3.6 compatible) version of that dependency.
The text was updated successfully, but these errors were encountered: