0

I have a python project that is installed via setup.py. I usually install it as editable install:

py -3 -m pip install -e <path_to_my_project>

before I added pyproject.toml, execution of such an instruction:

import pkg_resources
pkg_resources.get_distribution('my-project')`

returned:

my-project 0.0.0 (<path_to_my_project>)

After adding pyproject.toml (empty), the execution of this instruction looks like this:

my-project 0.0.0 (c:\users\<user>\appdata\local\programs\python\python310-32\lib\site-packages)

What should be added to pyproject.toml to have backward compatibility?

My setup.py looks as followS:

from setuptools import setup, find_packages

setup(
    name='my-project',
    packages=find_packages(where='src'),
    package_dir={"": "src"},
)

I tried https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/#fallback-behaviour

piotrek204
  • 21
  • 2
  • Is your pip up to date? Maybe you are using a pip that does not have support for "editable" installations with `pyproject.toml` ([PEP 660](https://peps.python.org/pep-0660/)). I believe it was added in ["_pip v21.3_" released on 2021-10-11](https://pip.pypa.io/en/stable/news/#v21-3). – sinoroc Dec 13 '22 at 17:35
  • yes, pip is upgraded – piotrek204 Dec 13 '22 at 18:41
  • But is the project installed as editable or not? What is the actual problem? – sinoroc Dec 13 '22 at 18:51
  • When empy `pyproject.toml` is added to the project and the project is installed as editable (`py -3 -m pip install -e .`), then `pkg_resources.get_distribution` returns the path to the site packages instead of . – piotrek204 Dec 13 '22 at 18:57
  • Maybe a bug... Maybe you could ask here: https://github.com/pypa/setuptools/issues -- Or you could try with `importlib.metadata` instead of `pkg_resources`. – sinoroc Dec 14 '22 at 10:00

0 Answers0