Remove stray egg-info directory automatically.
If a user or contributor ran `pip install -e .` on transformers < 3.0, pip created a transformers.egg-info directory next to the transformers directory at the root of the repository. In transformers 3.0, the source is in a `src` subdirectory. `pip install -e .` creates a transformers.egg-info directory there. However, pip will still pick transformers.egg-info from the previous location. This is a bug: https://github.com/pypa/pip/issues/5466 Users and contributors are likely to hit this problem because the documentation for transformers 3.0 relies heavily on extra_requires which didn't exist in earlier versions, so aren't defined in a stale transformers.egg-info directory. If such a directory exists, remove it. It's autogenerated, gitignored and not supposed to contain anything of value.
This commit is contained in:
19
setup.py
19
setup.py
@@ -34,9 +34,28 @@ To create the package for pypi.
|
||||
|
||||
"""
|
||||
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
|
||||
# Remove stale transformers.egg-info directory to avoid https://github.com/pypa/pip/issues/5466
|
||||
stale_egg_info = Path(__file__).parent / "transformers.egg-info"
|
||||
if stale_egg_info.exists():
|
||||
print(
|
||||
(
|
||||
"Warning: {} exists.\n\n"
|
||||
"If you recently updated transformers to 3.0 or later, this is expected,\n"
|
||||
"but it may prevent transformers from installing in editable mode.\n\n"
|
||||
"This directory is automatically generated by Python's packaging tools.\n"
|
||||
"I will remove it now.\n\n"
|
||||
"See https://github.com/pypa/pip/issues/5466 for details.\n"
|
||||
).format(stale_egg_info)
|
||||
)
|
||||
shutil.rmtree(stale_egg_info)
|
||||
|
||||
|
||||
extras = {}
|
||||
|
||||
extras["mecab"] = ["mecab-python3"]
|
||||
|
||||
Reference in New Issue
Block a user