Search code examples
pythonpython-2.7distutilssetup.py

Error: setup script specifies an absolute path: .gitignore


On Ubuntu 16.04.4, I suspect some recent update of some Python system package of having broken my Python 2.7 configuration. Whatever package I try to install or reinstall with a basic sudo python setup.py install it always fails because of gitignore:

running install
running bdist_egg
running egg_info
[...]
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py

error: Error: setup script specifies an absolute path:

    /home/me/some_repo/.gitignore

setup() arguments must *always* be /-separated paths relative to the
setup.py directory, *never* absolute paths.

Lately I found a temporary workaround by manually cleaning the /usr/local/lib/python2.7/dist-packages/some_package directory manually before installing some_package. However tonight I'm facing the same issue on another repository and it keeps failing whatever I clean up. I also tried cleaning all compiled folders .egg-info/ build/ dist/ without success.

Notes: The setup script does not actually specify an absolute path to gitignore. An example of failing repo is https://github.com/philchristensen/python-artnet/blob/master/setup.py This repo has a setuptools_git entry which might lead to a clue, but other packages without this git entry point also fail because of the gitignore while a couple of months ago I never faced such issue with the same repos. Deleting the gitignore causes the setup to fail because of another non-py local file.

Any clue?


Solution

  • It looks like some other package that I had previously installed broke my system-wide Python.

    Here's how I fixed in order to install package xyz:

    • Browsed /usr/local/lib/python2.7/dist-packages in search for occurences of "gitignore"
    • Deleted folders of all matching occurences (including setuptools_git itself that matches "gitignore")
    • pip install setuptools_git
    • In package xyz, rm -rf dist/ build/ *.egg-info/
    • Reinstall package xyz, which now succeeds to install
    • Use virtual envs as a lesson