I inherited a docker containerized setup. Previous engineers maintaining it are long gone. When I try to build the image, it is complaining during installation of one of the packages specified in requirements.txt
requirements.txt contents:
setuptools==40.6.3
pip==1.5.4
paramiko==2.4.2
scp==0.13.0
timeout_decorator==0.4.1
requests==2.21.0
pylint==1.9.4
jsonschema==2.6.0
six==1.11.0
dnslib==0.9.10
SQLAlchemy==1.3.5
psycopg2==2.8.3
future==0.17.1
tenacity
Error seen during installation:
Collecting lazy-object-proxy (from astroid<2.0,>=1.6->pylint==1.9.4->-r requirements.txt (line 7))
Downloading https://files.pythonhosted.org/packages/6f/3e/7c80e8536b9d5eb66e784fff4c359adf9e55b37460fd6928192256ba71f2/lazy-object-proxy-1.7.0.tar.gz (42kB)
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-JMyxNe/lazy-object-proxy/setup.py", line 146, in <module>
distclass=BinaryDistribution,
File "/usr/lib/python2.7/dist-packages/setuptools/__init__.py", line 128, in setup
_install_setup_requires(attrs)
File "/usr/lib/python2.7/dist-packages/setuptools/__init__.py", line 123, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 513, in fetch_build_eggs
replace_conflicting=True,
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 774, in resolve
replace_conflicting=replace_conflicting
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1057, in best_match
return self.obtain(req, installer)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1069, in obtain
return installer(requirement)
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 580, in fetch_build_egg
return cmd.easy_install(req)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 698, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 724, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 909, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1177, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1163, in run_setup
run_setup(setup_script, args)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 253, in run_setup
raise
File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "/usr/lib/python2.7/contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 166, in save_modules
saved_exc.resume()
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 141, in resume
six.reraise(type, exc, self._tb)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 154, in save_modules
yield saved
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 195, in setup_context
yield
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 250, in run_setup
_execfile(setup_script, ns)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 44, in _execfile
code = compile(script, filename, 'exec')
File "/tmp/easy_install-bKS9kl/setuptools_scm-7.0.5/setup.py", line 20
def scm_version() -> str:
^
SyntaxError: invalid syntax
----------------------------------------
[91mCommand "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-JMyxNe/lazy-object-proxy/
I am confused where exactly to fix this issue. I know that it is using python 2.7 which is not supported but bringing entire project to python 3 is not ideal at this time. I believed the packages and their versions below should work with python 2.7 as it has been all this time until I deleted the image. How can I fix this issue?
CodePudding user response:
TL;DR: Try adding setuptools-stm=5.0.2
to requirements.txt
.
At least some of the project is attempting to use Python 3.
File "/tmp/easy_install-bKS9kl/setuptools_scm-7.0.5/setup.py", line 20
def scm_version() -> str:
This line, def scm_version() -> str:
is using type hinting introduced in Python 3.5.
It looks like this is coming from setuptools-scm
. 7.0.5 is the latest version.
I think this is happening as pylint
is being installed, based on the info on the first line of your traceback, as an automatic dependency installation. You could try pinning setuptools-stm=5.0.2
as a requirement, since that is the last version that supports Python 2.
It might work. If it does, there's no guarantee that something else won't be broken. You may need to pin other requirements (like tenacity
, which has no pinned version).
That's my best suggestion!