locust icon indicating copy to clipboard operation
locust copied to clipboard

Build error with poetry build system

Open a18-kaushik opened this issue 1 year ago • 15 comments

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 avatar Jul 08 '24 06:07 a18-kaushik

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

cyberw avatar Jul 08 '24 07:07 cyberw

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

a18-kaushik avatar Jul 08 '24 08:07 a18-kaushik

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

cyberw avatar Jul 08 '24 09:07 cyberw

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

a18-kaushik avatar Jul 08 '24 09:07 a18-kaushik

@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 avatar Jul 08 '24 09:07 cyberw

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

cyberw avatar Jul 08 '24 09:07 cyberw

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

a18-kaushik avatar Jul 08 '24 10:07 a18-kaushik

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.

cyberw avatar Jul 08 '24 11:07 cyberw

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

a18-kaushik avatar Jul 08 '24 11:07 a18-kaushik

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 ...)

cyberw avatar Jul 08 '24 12:07 cyberw

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

a18-kaushik avatar Jul 08 '24 12:07 a18-kaushik

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

cyberw avatar Jul 08 '24 12:07 cyberw

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 🤔

mquinnfd avatar Jul 09 '24 08:07 mquinnfd

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.

cyberw avatar Jul 09 '24 20:07 cyberw

Pr for this is over here: https://github.com/locustio/locust/pull/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

mquinnfd avatar Jul 10 '24 15:07 mquinnfd

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[bot] avatar Sep 09 '24 02:09 github-actions[bot]

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!

github-actions[bot] avatar Sep 19 '24 02:09 github-actions[bot]