python / importlib_metadata

Library to access metadata for Python packages
https://importlib-metadata.readthedocs.io
Apache License 2.0
123 stars 80 forks source link

importlib_metadata-6.0.0.dist-info directory is almost empty. Is it normal? #431

Closed HubTou closed 1 year ago

HubTou commented 1 year ago

Hello,

This is more a question than an issue.

Out of the 170 packages on my system, importlib-metada is the only one with an almost empty site-package/*/dist-info directory and (ironically!) no METADATA file inside. There's however an egg-info directory with similar information.

I don't see any side effect for this, but is it normal?

# cd /usr/local/lib/python3.9/site-packages

# ls -lR  importlib_metadata-6.0.0*
importlib_metadata-6.0.0-py3.9.egg-info:
total 20
-rw-r--r--  1 root  wheel     1  8 févr. 19:19 dependency_links.txt
-rw-r--r--  1 root  wheel  3679  8 févr. 19:19 PKG-INFO
-rw-r--r--  1 root  wheel   505  8 févr. 19:19 requires.txt
-rw-r--r--  1 root  wheel  1340  8 févr. 19:19 SOURCES.txt
-rw-r--r--  1 root  wheel    19  8 févr. 19:19 top_level.txt

importlib_metadata-6.0.0.dist-info:
total 4
-rw-r--r--  1 root  wheel  4  5 janv. 13:17 INSTALLER
-rw-r--r--  1 root  wheel  0  5 janv. 13:17 REQUESTED

# cat importlib_metadata-6.0.0.dist-info/INSTALLER
pip

# pip list | grep importlib
importlib-metadata            6.0.0

# pip show importlib-metadata
Name: importlib-metadata
Version: 6.0.0
Summary: Read metadata from Python packages
Home-page: https://github.com/python/importlib_metadata
Author: Jason R. Coombs
Author-email: jaraco@jaraco.com
License:
Location: /usr/local/lib/python3.9/site-packages
Requires: zipp
Required-by: keyring, Sphinx, twine
jaraco commented 1 year ago

I don't know if it's normal or not. I suspect it has something to do with how you installed the package. When I install it, only the .dist-info is installed:

 draft $ py -3.9 -m venv .venv
 draft $ py -m pip install -q -U pip
 draft $ py -m pip install importlib_metadata
Collecting importlib_metadata
  Using cached importlib_metadata-6.3.0-py3-none-any.whl (22 kB)
Collecting zipp>=0.5
  Using cached zipp-3.15.0-py3-none-any.whl (6.8 kB)
Installing collected packages: zipp, importlib_metadata
Successfully installed importlib_metadata-6.3.0 zipp-3.15.0
 draft $ ls -d1 .venv/lib/python3.9/site-packages/importlib*
.venv/lib/python3.9/site-packages/importlib_metadata
.venv/lib/python3.9/site-packages/importlib_metadata-6.3.0.dist-info

How the metadata is generated is mainly a function of the package installer (e.g. pip). This package doesn't do anything special for declaring metadata.

Can you investigate and provide more detail about how your system became configured as it was?

HubTou commented 1 year ago

Hello Jason,

I think this package initially got installed through a system package, then as I upgrade both my system packages (with the system tools) and my Python packages (with Python's pip), may be there was a glitch somewhere.

I'll experiment on a fresh VM to see if I can reproduce this.

Best regards,

Hubert

Le mar. 11 avr. 2023 à 03:15, Jason R. Coombs @.***> a écrit :

I don't know if it's normal or not. I suspect it has something to do with how you installed the package. When I install it, only the .dist-info is installed:

draft $ py -3.9 -m venv .venv draft $ py -m pip install -q -U pip draft $ py -m pip install importlib_metadata Collecting importlib_metadata Using cached importlib_metadata-6.3.0-py3-none-any.whl (22 kB) Collecting zipp>=0.5 Using cached zipp-3.15.0-py3-none-any.whl (6.8 kB) Installing collected packages: zipp, importlib_metadata Successfully installed importlib_metadata-6.3.0 zipp-3.15.0 draft $ ls -d1 .venv/lib/python3.9/site-packages/importlib* .venv/lib/python3.9/site-packages/importlib_metadata .venv/lib/python3.9/site-packages/importlib_metadata-6.3.0.dist-info

How the metadata is generated is mainly a function of the package installer (e.g. pip). This package doesn't do anything special for declaring metadata.

Can you investigate and provide more detail about how your system became configured as it was?

— Reply to this email directly, view it on GitHub https://github.com/python/importlib_metadata/issues/431#issuecomment-1502546303, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADWZ7CFDNCI63RB6FVTKCS3XASWDBANCNFSM6AAAAAAVNLHZDM . You are receiving this because you authored the thread.Message ID: @.***>

jaraco commented 1 year ago

Almost certainly, the issue is some corruption or artifact specific to the environment. The question is answered (it's not normal).

One side effect you'll get from this situation is that there will be multiple Distribution objects for a given name and some calls like importlib_metadata.distribution will return the first of those.

The fact that you're getting meaningful metadata seems to indicate that the precedence behavior (in here or in pip) may be doing a good job of resolving the ambiguity (or maybe you just got lucky).

Feel free to revive the conversation with more details, especially if you believe there's a behavior in this project that can be improved.

HubTou commented 1 year ago

Hello, I was not able to reproduce the issue. However I noticed on fresh installs that the egg-info comes from the package install and the dist-info comes from pip upgrades (which removes the egg-info directory on upgrade). As said by pip, "Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager". That's probably the origin of the issue, may be with previous versions of pip.

root# pkg install py39-importlib-metadata
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 3 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    py39-importlib-metadata: 6.0.0_1
    py39-setuptools: 63.1.0
    py39-zipp: 3.4.0

Number of packages to be installed: 3

The process will require 9 MiB more space.
1 MiB to be downloaded.

Proceed with this action? [y/N]: y
[1/3] Fetching py39-setuptools-63.1.0.pkg: 100%    1 MiB   1.1MB/s    00:01    
[2/3] Fetching py39-zipp-3.4.0.pkg: 100%    8 KiB   8.1kB/s    00:01    
[3/3]  Fetching py39-importlib-metadata-6.0.0_1.pkg: 100%   31 KiB  31.4kB/s    00:01    
Checking integrity... done (0 conflicting)
[1/3] Installing py39-setuptools-63.1.0...
[1/3] Extracting py39-setuptools-63.1.0: 100%
[2/3] Installing py39-zipp-3.4.0...
[2/3] Extracting py39-zipp-3.4.0: 100%
[3/3] Installing py39-importlib-metadata-6.0.0_1...
[3/3] Extracting py39-importlib-metadata-6.0.0_1: 100%

root# ls -l /usr/local/lib/python3.9/site-packages/
total 72
drwxr-xr-x  2 root  wheel   512 18 avr.  08:12 __pycache__
drwxr-xr-x  3 root  wheel   512 18 avr.  08:12 _distutils_hack
-rw-r--r--  1 root  wheel   151  2 avr.  03:15 distutils-precedence.pth
-rw-r--r--  1 root  wheel   151 18 avr.  07:54 distutils-precedence.pth.pkgsave
-rw-r--r--  1 root  wheel   185  2 avr.  03:15 easy-install.pth
-rw-r--r--  1 root  wheel   185  2 avr.  03:15 easy-install.pth.dist
drwxr-xr-x  3 root  wheel   512 18 avr.  08:12 importlib_metadata
drwxr-xr-x  2 root  wheel   512 18 avr.  08:12 importlib_metadata-6.0.0-py3.9.egg-info          # <= here
drwxr-xr-x  5 root  wheel   512 18 avr.  07:54 pip
drwxr-xr-x  2 root  wheel   512 18 avr.  07:54 pip-23.1.dist-info
drwxr-xr-x  5 root  wheel   512 18 avr.  08:12 pkg_resources
-rw-r--r--  1 root  wheel   119  2 avr.  03:13 README.txt
drwxr-xr-x  8 root  wheel  3072 18 avr.  08:12 setuptools
drwxr-xr-x  2 root  wheel   512 18 avr.  08:11 setuptools-63.1.0-py3.9.egg-info
drwxr-xr-x  2 root  wheel   512 18 avr.  07:54 setuptools-67.6.1.dist-info
drwxr-xr-x  2 root  wheel   512 18 avr.  08:12 zipp-3.4.0-py3.9.egg-info
-rw-r--r--  1 root  wheel  8089 25 oct.   2020 zipp.py

root# ls -l /usr/local/lib/python3.9/site-packages/importlib_metadata-6.0.0-py3.9.egg-info/
total 20
-rw-r--r--  1 root  wheel     1  2 avr.  03:17 dependency_links.txt
-rw-r--r--  1 root  wheel  3679  2 avr.  03:17 PKG-INFO
-rw-r--r--  1 root  wheel   505  2 avr.  03:17 requires.txt
-rw-r--r--  1 root  wheel  1340  2 avr.  03:17 SOURCES.txt

root# pip list
Package            Version
------------------ -------
importlib-metadata 6.0.0
pip                23.1
setuptools         63.1.0
zipp               3.4.0

root# pip list --outdated
Package            Version Latest Type
------------------ ------- ------ -----
importlib-metadata 6.0.0   6.4.1  wheel
setuptools         63.1.0  67.6.1 wheel
zipp               3.4.0   3.15.0 wheel

root# pip install -U importlib-metadata
Requirement already satisfied: importlib-metadata in /usr/local/lib/python3.9/site-packages (6.0.0)
Collecting importlib-metadata
  Downloading importlib_metadata-6.4.1-py3-none-any.whl (22 kB)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.9/site-packages (from importlib-metadata) (3.4.0)
Installing collected packages: importlib-metadata
  Attempting uninstall: importlib-metadata
    Found existing installation: importlib-metadata 6.0.0
    Uninstalling importlib-metadata-6.0.0:
      Successfully uninstalled importlib-metadata-6.0.0
Successfully installed importlib-metadata-6.4.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

root# ls -ll /usr/local/lib/python3.9/site-packages/
total 72
drwxr-xr-x  2 root  wheel   512 18 avr.  08:12 __pycache__
drwxr-xr-x  3 root  wheel   512 18 avr.  08:12 _distutils_hack
-rw-r--r--  1 root  wheel   151  2 avr.  03:15 distutils-precedence.pth
-rw-r--r--  1 root  wheel   151 18 avr.  07:54 distutils-precedence.pth.pkgsave
-rw-r--r--  1 root  wheel   185  2 avr.  03:15 easy-install.pth
-rw-r--r--  1 root  wheel   185  2 avr.  03:15 easy-install.pth.dist
drwxr-xr-x  3 root  wheel   512 18 avr.  08:14 importlib_metadata
drwxr-xr-x  2 root  wheel   512 18 avr.  08:14 importlib_metadata-6.4.1.dist-info          # <= here
drwxr-xr-x  5 root  wheel   512 18 avr.  07:54 pip
drwxr-xr-x  2 root  wheel   512 18 avr.  07:54 pip-23.1.dist-info
drwxr-xr-x  5 root  wheel   512 18 avr.  08:12 pkg_resources
-rw-r--r--  1 root  wheel   119  2 avr.  03:13 README.txt
drwxr-xr-x  8 root  wheel  3072 18 avr.  08:12 setuptools
drwxr-xr-x  2 root  wheel   512 18 avr.  08:11 setuptools-63.1.0-py3.9.egg-info
drwxr-xr-x  2 root  wheel   512 18 avr.  07:54 setuptools-67.6.1.dist-info
drwxr-xr-x  2 root  wheel   512 18 avr.  08:12 zipp-3.4.0-py3.9.egg-info
-rw-r--r--  1 root  wheel  8089 25 oct.   2020 zipp.py

root# ls -l /usr/local/lib/python3.9/site-packages/importlib_metadata-6.4.1.dist-info/
total 36
-rw-r--r--  1 root  wheel      4 18 avr.  08:14 INSTALLER
-rw-r--r--  1 root  wheel  11358 18 avr.  08:14 LICENSE
-rw-r--r--  1 root  wheel   4958 18 avr.  08:14 METADATA
-rw-r--r--  1 root  wheel   2051 18 avr.  08:14 RECORD
-rw-r--r--  1 root  wheel      0 18 avr.  08:14 REQUESTED
-rw-r--r--  1 root  wheel     19 18 avr.  08:14 top_level.txt
-rw-r--r--  1 root  wheel     92 18 avr.  08:14 WHEEL