Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Build fails with error ModuleNotFoundError: No module named 'setuptools' #491

Closed
mcorvo opened this issue Oct 9, 2024 · 11 comments · Fixed by #492
Closed

Build fails with error ModuleNotFoundError: No module named 'setuptools' #491

mcorvo opened this issue Oct 9, 2024 · 11 comments · Fixed by #492

Comments

@mcorvo
Copy link

mcorvo commented Oct 9, 2024

Hi all,

I'm facing the following build issue: when trying to run a "docker build ." or even a simple "make build/make docker-run" I always end up with this error:

9.310   BUILD  Building production package
9.509
9.509 > client@0.1.0 build
9.509 > react-scripts build
9.509
..........
11.60 Creating an optimized production build...
11.81 Browserslist: caniuse-lite is outdated. Please run:
11.81   npx update-browserslist-db@latest
70.50   npm install -g serve
70.50   serve -s build
.........
70.63 Traceback (most recent call last):
70.63   File "/build/setup.py", line 3, in <module>
70.63     from setuptools import setup
70.63 ModuleNotFoundError: No module named 'setuptools'
70.63 make: *** [Makefile:144: build] Error 1

I also tried to force the installation of setuptools in the corresponding section of the Makefile:

.PHONY: build
build: i18n
        @printf "  \033[38;5;154mBUILD\033[0m  \033[38;5;176mBuilding production package\033[0m\n"
        @rm -rf newdle/client/build build
        @source ${VENV}/bin/activate && cd newdle/client && npm run build
        @${PIP} install -q -U pip setuptools             <---------------------------------
        @python setup.py bdist_wheel -q

but with no results. It looks like the Python venv hasn't got the setuptools module, which in theory has been already installed here:

${VENV}:
        @printf "\033[38;5;154mSETUP\033[0m  \033[38;5;105mCreating virtualenv\033[0m\n"
        @${PYTHON} -m venv --prompt newdle .venv
        @source ${VENV}/bin/activate
        @${PIP} install -q -U pip setuptools     <-----------------------------

Could someone please help me solve this issue? I'd like to upgrade my production instance with the latest flask-multipass, but I'm stuck with the build process.

Thanks in advance for your support.

Regards,

Marco

@tomasr8
Copy link
Member

tomasr8 commented Oct 9, 2024

Thanks for the report! That's a bit strange, though this PR which replaces setuptools with hatchling will take care of that :)

@tomasr8 tomasr8 linked a pull request Oct 9, 2024 that will close this issue
@ThiefMaster
Copy link
Member

Please don't use it in prod yet though, I'm fixing some GitHub actions stuff in the same PR, and added a dummy DB revision for this which you of course would not want to apply on your newdle instance.

However, for testing it's fine, or you can just use the first commit in that PR.

@ThiefMaster
Copy link
Member

The PR should be fine now. Please let me know if it works for you and I'll merge it.

@manwegit
Copy link

manwegit commented Oct 9, 2024

I slightly changed the Makefile to start with venv
from: @python setup.py bdist_wheel -q
to: @source ${VENV}/bin/activate && python setup.py bdist_wheel -q

And I was just about to report the problem. I did not test the PR yet.

diff --git a/Makefile b/Makefile
index 3f563b5..abf81b7 100644
--- a/Makefile
+++ b/Makefile
@@ -141,7 +141,7 @@ build: i18n
        @printf "  \033[38;5;154mBUILD\033[0m  \033[38;5;176mBuilding production package\033[0m\n"
        @rm -rf newdle/client/build build
        @source ${VENV}/bin/activate && cd newdle/client && npm run build
-       @python setup.py bdist_wheel -q
+       @source ${VENV}/bin/activate && python setup.py bdist_wheel -q
 
 
 .PHONY: docker

@mcorvo
Copy link
Author

mcorvo commented Oct 10, 2024

Dear Tomas,

I tried to build Newdle using your PR and I found another small issue. When using Python 3.12 the build steps should be:

@@ -143,7 +143,8 @@ build: i18n
        @printf "  \033[38;5;154mBUILD\033[0m  \033[38;5;176mBuilding production package\033[0m\n"
        @rm -rf newdle/client/build build
        @source ${VENV}/bin/activate && cd newdle/client && npm run build
-       @python setup.py bdist_wheel -q
+       @python -m pip install build uv
+       @python -m build --installer uv -o dist

otherwise python would complain that build and uv packages are not installed. With this small fix, the build runs smoothly.

HTH.

Regards,

Marco

@ThiefMaster
Copy link
Member

Did you run make first? uv and build are part of the dev dependencies so they should already be present...

@manwegit
Copy link

Hi

I triead your pull ##492 request and it fails with the same problem as original Makefile. I'm running docker builds with: docker compose build
The problem is that VENV is not active in the build: i18n target when running multiple commands.

.../git_external/newdle (MASTER)$ git diff
diff --git a/Makefile b/Makefile
index c6948af..5faff8a 100644
--- a/Makefile
+++ b/Makefile
@@ -141,7 +141,7 @@ build: i18n
        @printf "  \033[38;5;154mBUILD\033[0m  \033[38;5;176mBuilding production package\033[0m\n"
        @rm -rf newdle/client/build build
        @source ${VENV}/bin/activate && cd newdle/client && npm run build
-       @python -m build --installer uv -o dist
+       @source ${VENV}/bin/activate && python -m build --installer uv -o dist
 
 
 .PHONY: docker

Adding "@source ${VENV}/bin/activate && " imports VENV variables and then python will allow you to build it just fine.
Running the build manually one most likely enters the VENV and does not notice this problem.

@mcorvo
Copy link
Author

mcorvo commented Oct 10, 2024

Yes, the log of my build shows:

=> [builder 2/6] ADD . /build/
=> [builder 3/6] WORKDIR /build
=> [builder 4/6] RUN ./install_node.sh
=> [builder 5/6] RUN HUSKY_SKIP_INSTALL=1 make
=> [builder 6/6] RUN make build

@manwegit
Copy link

Error when VENV is not sourced (docker building)

 => [stage-1 4/9] RUN pip install uwsgi                                                                                                                6.2s
 => [builder 5/6] RUN HUSKY_SKIP_INSTALL=1 make                                                                                                       46.5s
 => ERROR [builder 6/6] RUN make build                                                                                                                24.1s 
------                                                                                                                                                      
 > [builder 6/6] RUN make build:                                                                                                                            
0.350 I18N  Extracting strings                                                                                                                              
0.436                                                                                                                                                       
0.436 > client@0.1.0 extract                                                                                                                                
0.436 > rm -f src/locales/en/messages.* && lingui extract --clean 

...

24.05 /usr/local/bin/python: No module named build
24.06 make: *** [Makefile:144: build] Error 1
------
Dockerfile:10
--------------------
   8 |     
   9 |     RUN HUSKY_SKIP_INSTALL=1 make
  10 | >>> RUN make build
  11 |     
  12 |     
--------------------
error: failed to solve: process "/bin/sh -c make build" did not complete successfully: exit code: 2
FATA[0076] no image was built                           
FATA[0076] error while building image newdle-newdle: exit status 1 

@ThiefMaster
Copy link
Member

ThiefMaster commented Oct 10, 2024

Ah, totally forgot that make build is also used in the dockerfile...

@ThiefMaster
Copy link
Member

Should be fixed in the PR branch now

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants