ddelange / pipgrip

Lightweight pip dependency resolver with deptree preview functionality based on the PubGrub algorithm
Other
185 stars 14 forks source link

:bug: Fix package reports on Google Colab #132

Closed ddelange closed 11 months ago

ddelange commented 11 months ago

Somehow Google Colab is forcing colored report output, and even adding --no-color isn't disabling it. Switching to temp file to make pipgrip robust to this config.

The ANSI escapes result in:

Traceback (most recent call last):
  File "/usr/local/bin/pipgrip", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/pipgrip/cli.py", line 446, in main
    solution = solver.solve()
  File "/usr/local/lib/python3.10/dist-packages/pipgrip/libs/mixology/version_solver.py", line 74, in solve
    if not self._run():
  File "/usr/local/lib/python3.10/dist-packages/pipgrip/libs/mixology/version_solver.py", line 90, in _run
    next_package = self._choose_package_version()
  File "/usr/local/lib/python3.10/dist-packages/pipgrip/libs/mixology/version_solver.py", line 363, in _choose_package_version
    versions = self._source.versions_for(term.package, term.constraint.constraint)
  File "/usr/local/lib/python3.10/dist-packages/pipgrip/libs/mixology/package_source.py", line 77, in versions_for
    return self._versions_for(package, constraint)
  File "/usr/local/lib/python3.10/dist-packages/pipgrip/package_source.py", line 192, in _versions_for
    self.discover_and_add(package.req.__str__())
  File "/usr/local/lib/python3.10/dist-packages/pipgrip/package_source.py", line 148, in discover_and_add
    to_create = discover_dependencies_and_versions(
  File "/usr/local/lib/python3.10/dist-packages/pipgrip/pipper.py", line 516, in discover_dependencies_and_versions
    report = _get_package_report(
  File "/usr/local/lib/python3.10/dist-packages/pipgrip/pipper.py", line 323, in _get_package_report
    report = json.loads(out)
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 6 (char 5)
codecov[bot] commented 11 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (cc060d8) 78.36% compared to head (4ebf389) 78.39%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #132 +/- ## ========================================== + Coverage 78.36% 78.39% +0.02% ========================================== Files 29 29 Lines 2834 2837 +3 Branches 794 798 +4 ========================================== + Hits 2221 2224 +3 Misses 444 444 Partials 169 169 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

github-actions[bot] commented 11 months ago

Released 0.10.11