Description
Hello, I have built a FastAPI web app with Jamspell as a training and learning how to code web apps. I want to dockerize it now, so I can run it in my MAC Air M1 and my Windows PC as well. As requirements for the image to build, I have this requirements.txt file:
swig==3.0.12
jamspell
fastapi
uvicorn
A virtual environment with this requirements.txt file works just fine, and installs both swig, jamspell and can run my web app. But when I try to build the docker image, with this dockerfile:
FROM python:3.11.1-slim-buster
WORKDIR /app
COPY corrector.py /app
COPY requirements.txt /app
RUN pip install -r requirements.txt
CMD ["uvicorn", "corrector:app", "--host", "0.0.0.0", "--port", "85"]
It throws an error while trying to install jamspell:
4 Building wheels for collected packages: jamspell
#9 2.965 Building wheel for jamspell (setup.py): started
#9 3.104 Building wheel for jamspell (setup.py): finished with status 'error'
#9 3.107 error: subprocess-exited-with-error
#9 3.107
#9 3.107 × python setup.py bdist_wheel did not run successfully.
#9 3.107 │ exit code: 1
#9 3.107 ╰─> [57 lines of output]
#9 3.107 /usr/local/lib/python3.11/site-packages/setuptools/dist.py:771: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
#9 3.107 warnings.warn(
#9 3.107 running bdist_wheel
#9 3.107 running build
#9 3.107 running build_ext
#9 3.107 building '_jamspell' extension
#9 3.107 Traceback (most recent call last):
#9 3.107 File "", line 2, in
#9 3.107 File "", line 34, in
#9 3.107 File "/tmp/pip-install-omd0mbcb/jamspell_47dc033ba0034d5f8eb2ab1db477be6b/setup.py", line 55, in
#9 3.107 setup(
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/init.py", line 87, in setup
#9 3.107 return distutils.core.setup(**attrs)
#9 3.107 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
#9 3.107 return run_commands(dist)
#9 3.107 ^^^^^^^^^^^^^^^^^^
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
#9 3.107 dist.run_commands()
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 968, in run_commands
#9 3.107 self.run_command(cmd)
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/dist.py", line 1217, in run_command
#9 3.107 super().run_command(command)
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
#9 3.107 cmd_obj.run()
#9 3.107 File "/usr/local/lib/python3.11/site-packages/wheel/bdist_wheel.py", line 325, in run
#9 3.107 self.run_command("build")
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
#9 3.107 self.distribution.run_command(command)
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/dist.py", line 1217, in run_command
#9 3.107 super().run_command(command)
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
#9 3.107 cmd_obj.run()
#9 3.107 File "/tmp/pip-install-omd0mbcb/jamspell_47dc033ba0034d5f8eb2ab1db477be6b/setup.py", line 37, in run
#9 3.107 self.run_command('build_ext')
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
#9 3.107 self.distribution.run_command(command)
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/dist.py", line 1217, in run_command
#9 3.107 super().run_command(command)
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
#9 3.107 cmd_obj.run()
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
#9 3.107 self.build_extensions()
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 466, in build_extensions
#9 3.107 self._build_extensions_serial()
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 492, in _build_extensions_serial
#9 3.107 self.build_extension(ext)
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 525, in build_extension
#9 3.107 sources = self.swig_sources(sources, ext)
#9 3.107 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#9 3.107 File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 623, in swig_sources
#9 3.107 swig = self.swig or self.find_swig()
#9 3.107 ^^^^^^^^^^^^^^^^
#9 3.107 File "/tmp/pip-install-omd0mbcb/jamspell_47dc033ba0034d5f8eb2ab1db477be6b/setup.py", line 49, in find_swig
#9 3.107 assert swigBinary is not None
#9 3.107 ^^^^^^^^^^^^^^^^^^^^^^
#9 3.107 AssertionError
#9 3.107 [end of output]
#9 3.107
#9 3.107 note: This error originates from a subprocess, and is likely not a problem with pip.
#9 3.107 ERROR: Failed building wheel for jamspell
#9 3.107 Running setup.py clean for jamspell
#9 3.215 Failed to build jamspell
#9 3.283 Installing collected packages: swig, jamspell, typing-extensions, sniffio, idna, h11, click, uvicorn, pydantic, anyio, starlette, fastapi
#9 3.386 Running setup.py install for jamspell: started
#9 3.822 Running setup.py install for jamspell: finished with status 'error'
#9 3.823 error: subprocess-exited-with-error
#9 3.823
#9 3.823 × Running setup.py install for jamspell did not run successfully.
#9 3.823 │ exit code: 1
#9 3.823 ╰─> [17 lines of output]
#9 3.823 /usr/local/lib/python3.11/site-packages/setuptools/dist.py:771: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
#9 3.823 warnings.warn(
#9 3.823 running install
#9 3.823 /usr/local/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
#9 3.823 warnings.warn(
#9 3.823 running build_ext
#9 3.823 building '_jamspell' extension
#9 3.823 swigging jamspell.i to jamspell_wrap.cpp
#9 3.823 /usr/local/bin/swig -python -c++ -o jamspell_wrap.cpp jamspell.i
#9 3.823 creating build
#9 3.823 creating build/temp.linux-aarch64-cpython-311
#9 3.823 creating build/temp.linux-aarch64-cpython-311/contrib
#9 3.823 creating build/temp.linux-aarch64-cpython-311/contrib/cityhash
#9 3.823 creating build/temp.linux-aarch64-cpython-311/contrib/phf
#9 3.823 creating build/temp.linux-aarch64-cpython-311/jamspell
#9 3.823 gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I. -Ijamspell -I/usr/local/include/python3.11 -c contrib/cityhash/city.cc -o build/temp.linux-aarch64-cpython-311/contrib/cityhash/city.o -std=c++11 -O2
#9 3.823 error: command 'gcc' failed: No such file or directory
#9 3.823 [end of output]
#9 3.823
#9 3.823 note: This error originates from a subprocess, and is likely not a problem with pip.
#9 3.824 error: legacy-install-failure
#9 3.824
#9 3.824 × Encountered error while trying to install package.
#9 3.824 ╰─> jamspell
Is there any known bug when trying to dockerize Jamspell? I saw this line of the log:
assert swigBinary is not None
That is similar as the Issue of installing Jamspell on Mac with pip3. But I fixed it on my virtualenv specifying swig version in the requirements.txt. Somehow, it does not work on the docker building.
Sorry if I am missing any major or obvious step trying to dockerize it, I am fairly new to Docker :D