From 7a865821d951bad882fd46cbbbd8ea7dfb8e4b9b Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Mon, 23 Dec 2019 20:06:39 +0100 Subject: [PATCH] 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. --- setup.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/setup.py b/setup.py index 205035507d..558a38ea8b 100644 --- a/setup.py +++ b/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"]