Skip to content
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

fastentrypoints enforces dependencies #1050

Closed
bertsky opened this issue Jun 1, 2023 · 1 comment
Closed

fastentrypoints enforces dependencies #1050

bertsky opened this issue Jun 1, 2023 · 1 comment
Assignees

Comments

@bertsky
Copy link
Collaborator

bertsky commented Jun 1, 2023

In #882 we introduced fastentrypoints, replacing pkg_resources so our processors would spin up faster.

However, it seems that this causes the entry point to put a hard constraint on all package requirements, e.g. when using Torch 2.0.1 despite Kraken allowing only <1.14 (for no good reason BTW):

crash log

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 629, in _build_master
    ws.require(__requires__)
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 966, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 827, in resolve
    dist = self._resolve_dist(
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 873, in _resolve_dist
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (torch 2.0.1+cu118 (/usr/local/lib/python3.8/site-packages), Requirement.parse('torch<1.14,>=1.11'), {'kraken'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/ocrd-kraken-segment", line 33, in <module>
    sys.exit(load_entry_point('ocrd-kraken', 'console_scripts', 'ocrd-kraken-segment')())
  File "/usr/local/bin/ocrd-kraken-segment", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/build/ocrd_kraken/ocrd_kraken/cli/segment.py", line 2, in <module>
    from ocrd.decorators import ocrd_cli_options, ocrd_cli_wrap_processor
  File "/build/core/ocrd/ocrd/__init__.py", line 17, in <module>
    from ocrd.processor.base import run_processor, run_cli, Processor
  File "/build/core/ocrd/ocrd/processor/__init__.py", line 1, in <module>
    from .base import (
  File "/build/core/ocrd/ocrd/processor/base.py", line 12, in <module>
    from pkg_resources import resource_filename
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3327, in <module>
    def _initialize_master_working_set():
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3301, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3339, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 631, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 644, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 827, in resolve
    dist = self._resolve_dist(
  File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 868, in _resolve_dist
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'torch<1.14,>=1.11' distribution was not found and is required by kraken

This goes away when replacing the entry point by the simple direct importer again.

@bertsky
Copy link
Collaborator Author

bertsky commented Jun 7, 2023

Reverted via #1041

@bertsky bertsky closed this as completed Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants