Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kba
Copy link
Member

@kba kba commented Jan 10, 2024

Since we switched to pyproject.toml, we also require setuptools>61. And it looks like setuptools, since at least 64 does not support pip install --editable the way it used to. In particular, it does not seem to be able to handle the folder structure ocrd_x/ocrd_x/__init__.py.

To reproduce:

$ pip install 'setuptools>=64'
$ make install-dev
$ python -c 'from ocrd_utils import getLogger'                                                                                                                                    
Traceback (most recent call last):                                                                                                                                                  
  File "<string>", line 1, in <module>                                                                                                                                              
ImportError: cannot import name 'getLogger' from 'ocrd_utils' (unknown location)

The problem is in setuptools package discovery:

File system entries in the current working directory whose names coincidentally match installed packages may take precedence in Python’s import system. Users are encouraged to avoid such scenarios [2].

The workaround is to use pip install -e --config-settings editable_mode=strict which this PR implements.

The proper solution is to either

a. switch away from setuptools
b. refactor the folder structure

Considering we've moved to pyproject.toml now and breaking the git history just to get --editable working without workarounds, I tend to a..

But first, let's fix with this workaround so make install-dev works again.

@kba kba requested review from MehmedGIT and bertsky January 10, 2024 16:53
@kba kba changed the title Fix --editable install for setuptools>=64, setuptools#3548 Fix --editable install for setuptools>=64, pypa/setuptools#3548 Jan 10, 2024
@kba kba merged commit 944d9e9 into master Jan 10, 2024
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

Successfully merging this pull request may close these issues.

3 participants