3

Using the following snippet found here in Python 3.8 to get the distributions installed in my Docker environment.

from importlib import metadata
dists = metadata.distributions()
for dist in dists:
    name = dist.metadata["Name"]
    version = dist.version
    license = dist.metadata["License"]
    print(f'found distribution {name}=={version}')

If i install my package in editable mode, i.e.

RUN pip install -e /src/my-project/python/my-project

it doesn't show up in metadata.distributions().

Without the -e it does. Any suggestions?

Edit: Also worth noting that the package is still importable, even though it's not in metadata.distributions().

ADDITIONAL INFO:

Dockerfile:

FROM ...
LABEL mantainer="..."

# copy this project and install
COPY . /src/my-project
RUN pip install -e /src/my-project/python/my-project 
# also tried: RUN python -m pip install -e ...

Directory Structure:

my-project
├── Dockerfile
├── python
   ├── my-project
      ├── setup.py
      ├── my_project
         ├── __init__.py

setup.py:

from setuptools import setup, find_packages

setup(
    name='my-project',
    version=__version__,
    packages=find_packages(exclude=[]),
    install_requires=[...]
)
Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
spapadop
  • 51
  • 5

0 Answers0