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

datanommer.models will break with upcoming poetry update - pkg_resources.DistributionNotFound: The 'datanommer.models' distribution was not found and is required by the application #1048

Closed
hrnciar opened this issue Oct 10, 2022 · 1 comment

Comments

@hrnciar
Copy link

hrnciar commented Oct 10, 2022

Hello,

I am working on updating poetry in Fedora and I found out that this update will break datanommer.models. It's caused by this change - python-poetry/poetry-core#394. From now on poetry normalizes datanommer.models into datanommer_models.

On line 162 dot should be replaced with a dash or wrapped in try-except block.

dist = pkg_resources.get_distribution("datanommer.models")

Alternatively, you can migrate to importlib.metadata and use it instead of pkg_resources. It might fix this problem.

pytest traceback
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

context = <sqlalchemy.dialects.postgresql.psycopg2.PGExecutionContext_psycopg2 object at 0x7fa8404666d0>

    def source_version_default(context):
>       dist = pkg_resources.get_distribution("datanommer.models")

../../BUILDROOT/python-datanommer-models-1.0.4-4.fc38.x86_64/usr/lib/python3.11/site-packages/datanommer/models/__init__.py:162: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

dist = Requirement.parse('datanommer.models')

    def get_distribution(dist):
        """Return a current distribution object for a Requirement or string"""
        if isinstance(dist, str):
            dist = Requirement.parse(dist)
        if isinstance(dist, Requirement):
>           dist = get_provider(dist)

/usr/lib/python3.11/site-packages/pkg_resources/__init__.py:478: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

moduleOrReq = Requirement.parse('datanommer.models')

    def get_provider(moduleOrReq):
        """Return an IResourceProvider for the named module or requirement"""
        if isinstance(moduleOrReq, Requirement):
>           return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]

/usr/lib/python3.11/site-packages/pkg_resources/__init__.py:354: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pkg_resources.WorkingSet object at 0x7fa841d91190>
requirements = ('datanommer.models',)

    def require(self, *requirements):
        """Ensure that distributions matching `requirements` are activated
    
        `requirements` must be a string or a (possibly-nested) sequence
        thereof, specifying the distributions and versions required.  The
        return value is a sequence of the distributions that needed to be
        activated to fulfill the requirements; all relevant distributions are
        included, even if they were already activated in this working set.
        """
>       needed = self.resolve(parse_requirements(requirements))

/usr/lib/python3.11/site-packages/pkg_resources/__init__.py:909: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pkg_resources.WorkingSet object at 0x7fa841d91190>, requirements = []
env = <pkg_resources.Environment object at 0x7fa83fb5e3d0>, installer = None
replace_conflicting = False, extras = None

    def resolve(self, requirements, env=None, installer=None,  # noqa: C901
                replace_conflicting=False, extras=None):
        """List all distributions needed to (recursively) meet `requirements`
    
        `requirements` must be a sequence of ``Requirement`` objects.  `env`,
        if supplied, should be an ``Environment`` instance.  If
        not supplied, it defaults to all distributions available within any
        entry or distribution in the working set.  `installer`, if supplied,
        will be invoked with each requirement that cannot be met by an
        already-installed distribution; it should return a ``Distribution`` or
        ``None``.
    
        Unless `replace_conflicting=True`, raises a VersionConflict exception
        if
        any requirements are found on the path that have the correct name but
        the wrong version.  Otherwise, if an `installer` is supplied it will be
        invoked to obtain the correct version of the requirement and activate
        it.
    
        `extras` is a list of the extras to be used with these requirements.
        This is important because extra requirements may look like `my_req;
        extra = "my_extra"`, which would otherwise be interpreted as a purely
        optional requirement.  Instead, we want to be able to assert that these
        requirements are truly required.
        """
    
        # set up the stack
        requirements = list(requirements)[::-1]
        # set of processed requirements
        processed = {}
        # key -> dist
        best = {}
        to_activate = []
    
        req_extras = _ReqExtras()
    
        # Mapping of requirement to set of distributions that required it;
        # useful for reporting info about conflicts.
        required_by = collections.defaultdict(set)
    
        while requirements:
            # process dependencies breadth-first
            req = requirements.pop(0)
            if req in processed:
                # Ignore cyclic or redundant dependencies
                continue
    
            if not req_extras.markers_pass(req, extras):
                continue
    
            dist = best.get(req.key)
            if dist is None:
                # Find the best distribution and add it to the map
                dist = self.by_key.get(req.key)
                if dist is None or (dist not in req and replace_conflicting):
                    ws = self
                    if env is None:
                        if dist is None:
                            env = Environment(self.entries)
                        else:
                            # Use an empty environment and workingset to avoid
                            # any further conflicts with the conflicting
                            # distribution
                            env = Environment([])
                            ws = WorkingSet([])
                    dist = best[req.key] = env.best_match(
                        req, ws, installer,
                        replace_conflicting=replace_conflicting
                    )
                    if dist is None:
                        requirers = required_by.get(req, None)
>                       raise DistributionNotFound(req, requirers)
E                       pkg_resources.DistributionNotFound: The 'datanommer.models' distribution was not found and is required by the application

/usr/lib/python3.11/site-packages/pkg_resources/__init__.py:795: DistributionNotFound
@abompard
Copy link
Member

Fixed in 7998f06, thanks.

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