Skip to content

In-place copy of a package gets metadata from installed package #94181

Closed
@jaraco

Description

@jaraco

I built an in-place version of numpy with python setup.py build_ext -i (note that that will not have a .dist-info dir at the root of the repo, distutils doesn't produce that), and then used PYTHONPATH to switch between the numpy installed into the conda env and this in-place build:

$ echo $PYTHONPATH
/home/rgommers/code/numpy

Then open IPython and:

>>> import numpy as np
>>> np.__version__
'1.24.0.dev0+291.g2c5f407cf6'
>>> import importlib.metadata
>>> importlib.metadata.version("numpy")
'1.22.3'

So rather than returning None or raising an exception, I'm getting the metadata for the wrong package.

I haven't yet decided if metadata items being undefined should result in None or raise an Exception (maybe KeyError).

Either way would be fine with me, as long as it's not silently returning incorrect metadata. There will be other cases like that other than numpy, and PYTHONPATH is pretty commonly used to switch around packages when developing. A .dist-info directory may be required to get correct metadata, but it being missing should not cause incorrect results - that's a clear bug.

Originally posted by @rgommers in #91216 (comment)

Metadata

Metadata

Assignees

Labels

pendingThe issue will be closed if no feedback is providedtopic-importlib

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions