Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Build error with poetry build system #2794

Closed
2 tasks done
a18-kaushik opened this issue Jul 8, 2024 · 17 comments
Closed
2 tasks done

Build error with poetry build system #2794

a18-kaushik opened this issue Jul 8, 2024 · 17 comments
Labels
bug stale Issue had no activity. Might still be worth fixing, but dont expect someone else to fix it

Comments

@a18-kaushik
Copy link

Prerequisites

Description

Building editable for locust (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building editable for locust (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [38 lines of output]
Building front end...
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\Akshit\locust\pre_build.py", line 14, in
build()
File "C:\Users\Administrator\Desktop\Akshit\locust\pre_build.py", line 10, in build
subprocess.run(["make", "frontend_build"])
File "C:\Python312\Lib\subprocess.py", line 548, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\subprocess.py", line 1026, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Python312\Lib\subprocess.py", line 1538, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified
Traceback (most recent call last):
File "C:\Python312\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 353, in
main()
File "C:\Python312\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 273, in build_editable
return hook(wheel_directory, config_settings, metadata_directory)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Temp\2\pip-build-env-3jvfpl2m\overlay\Lib\site-packages\poetry\core\masonry\api.py", line 82, in build_editable
return WheelBuilder.make_in(
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Administrator\AppData\Local\Temp\2\pip-build-env-3jvfpl2m\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 88, in make_in
wb.build(target_dir=directory)
File "C:\Users\Administrator\AppData\Local\Temp\2\pip-build-env-3jvfpl2m\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 117, in build
self._build(zip_file)
File "C:\Users\Administrator\AppData\Local\Temp\2\pip-build-env-3jvfpl2m\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 172, in _build
self._run_build_script(self._package.build_script)
File "C:\Users\Administrator\AppData\Local\Temp\2\pip-build-env-3jvfpl2m\overlay\Lib\site-packages\poetry\core\masonry\builders\wheel.py", line 262, in _run_build_script
subprocess.check_call([self.executable.as_posix(), build_script])
File "C:\Python312\Lib\subprocess.py", line 413, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['C:/Python312/python.exe', 'pre_build.py']' returned non-zero exit status 1.
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building editable for locust
Failed to build locust
ERROR: Could not build wheels for locust, which is required to install pyproject.toml-based projects

Command line

pip install -e locust/

Locustfile contents

Using example locustfile

Python version

3.12.3

Locust version

2.16.1

Operating system

Windows 11

@a18-kaushik a18-kaushik added the bug label Jul 8, 2024
@cyberw
Copy link
Collaborator

cyberw commented Jul 8, 2024

Are you actually on 2.16.1 or are you on latest master?

@a18-kaushik
Copy link
Author

Are you actually on 2.16.1 or are you on latest master?

i downloaded the master repository and tried building from there but the package.json file indicate locust version as 2.16.1 over there

@cyberw
Copy link
Collaborator

cyberw commented Jul 8, 2024

The installation procedure changed just a couple days ago (not yet part of a release), you're going to need to use Poetry now: https://docs.locust.io/en/latest/developing-locust.html#developing-locust

@a18-kaushik
Copy link
Author

i see, thank you for this documentation..it seems i was trying with older one
will try this and see if it works!

@cyberw
Copy link
Collaborator

cyberw commented Jul 8, 2024

@mquinnfd Is there a way we could give people a more sensible error message? For me (on macos, with poetry installed but not active), "pip install -e ." actually works (but doesnt generate the UI I guess)

@cyberw
Copy link
Collaborator

cyberw commented Jul 8, 2024

@andrewbaldwin44 package.json has version 2.16.1 hard coded, which is weird. Can we make it use the same versioning as locust somehow?

@a18-kaushik
Copy link
Author

executed the following commands in order, still didn't work

  • pip3 install poetry (installed successfully)
  • python -m poetry self add "poetry-dynamic-versioning[plugin]" (installed successfully)
  • python -m poetry install --with dev (error)

error:
Installing the current project: locust (2.29.1.dev39)Preparing build environment with build-system requirements poetry-core>=1.0.0, poetry-dynamic-versioning>=1.0.0,<2.0.0
Building front end...
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\Akshit\locust\pre_build.py", line 14, in
build()
File "C:\Users\Administrator\Desktop\Akshit\locust\pre_build.py", line 10, in build
subprocess.run(["make", "frontend_build"])
File "C:\Python312\Lib\subprocess.py", line 548, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\subprocess.py", line 1026, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Python312\Lib\subprocess.py", line 1538, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified

Command ['C:\Users\ADMINI~1\AppData\Local\Temp\2\tmpx4ifi4zk\.venv\Scripts\python.exe', 'C:\Users\Administrator\Desktop\Akshit\locust\pre_build.py'] errored with the following return code 1

@cyberw
Copy link
Collaborator

cyberw commented Jul 8, 2024

I think the problem is that you are missing make (https://community.chocolatey.org/packages/make if your using chocolatey)

@mquinnfd perhaps pre_build.py needs to call yarn directly, so we don't depend on make as well?

You'll probably need to install yarn as well, npm install -g yarn but once you have make it should tell you that in a more clear error message.

@a18-kaushik
Copy link
Author

it works after installing make! but now locust is not available as an executable command on commandline

logs for successful install:
Installing the current project: locust (2.29.1.dev39)Preparing build environment with build-system requirements poetry-core>=1.0.0, poetry-dynamic-versioning>=1.0.0,<2.0.0
Building front end...
yarn run v1.22.22
$ cd locust/webui && yarn install
[1/5] Validating package.json...
[2/5] Resolving packages...
success Already up-to-date.
Done in 0.55s.
yarn run v1.22.22
$ cd locust/webui && yarn build
$ vite build
vite v4.5.1 building for production...
✓ 1861 modules transformed.
dist/auth.html 0.52 kB │ gzip: 0.32 kB
dist/index.html 0.53 kB │ gzip: 0.32 kB
dist/assets/index-d21171ad.js 1,647.10 kB │ gzip: 538.40 kB
✓ built in 14.79s
Done in 15.68s.
Installing the current project: locust (2.29.1.dev39)

commandline error:
C:\Users\Administrator\Desktop\Akshit\locust>locust
'locust' is not recognized as an internal or external command,
operable program or batch file.

NOTE: previously it was making the executable in C:\Python312\Scripts folder

@cyberw
Copy link
Collaborator

cyberw commented Jul 8, 2024

With Poetry, you automatically install into a virtual env, so you need to activate it (poetry shell while standing in the directory) or use poetry to launch the command (poetry run locust ...)

@a18-kaushik
Copy link
Author

i'm now able to build my local code successfully, thank you for the support!

@cyberw
Copy link
Collaborator

cyberw commented Jul 8, 2024

No worries, thanks for reporting this! Keeping this ticket open for Matthew to take a look :)

@mquinnfd
Copy link
Contributor

mquinnfd commented Jul 9, 2024

Yeah poetry does work with pip -e ... etc. which is nice, but yes for us it obviously skips the main reason to use it, the prebuild phase for the front end.

I suppose the point of having it wrapped with make is to avoid this (people running X command which half-works), I'm not sure what the options are for trying to get the build to spit out a warning on a pip install or something but I'll have a look at potential solutions.

@cyberw I'll take an action to:

  • Omit make from the prebuild steps (call yarn directly)
    • We'll need to re-wrap the "you don't have yarn installed" scenario inside the prebuild script if we avoid make
  • Investigate "what happens on a raw pip install" in terms of warnings or failures
    • I don't imagine that there's much we can do about someone running pip for this project unfortunately 🤔

@cyberw
Copy link
Collaborator

cyberw commented Jul 9, 2024

Your suggested solution (call yarn directly) sounds fine or at least better than adding an extra dependency (make).

Another option might be (if possible) to just fail if someone uses pip . to install and inform them about what they should actually do :) But I think the first solution is preferable.

@mquinnfd
Copy link
Contributor

Pr for this is over here: #2801

I can't think of a way to fail a pip build specifically, pip is just going to want to build the pyproject.toml spec so there's nothing... poetry-specific in that process, might be something super creative buried in the pip docs but not sure

Copy link

github-actions bot commented Sep 9, 2024

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the stale Issue had no activity. Might still be worth fixing, but dont expect someone else to fix it label Sep 9, 2024
Copy link

This issue was closed because it has been stalled for 10 days with no activity. This does not necessarily mean that the issue is bad, but it most likely means that nobody is willing to take the time to fix it. If you have found Locust useful, then consider contributing a fix yourself!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug stale Issue had no activity. Might still be worth fixing, but dont expect someone else to fix it
Projects
None yet
Development

No branches or pull requests

3 participants