Build error with poetry build system
Prerequisites
- [X] I am using the latest version of Locust
- [X] I am reporting a bug, not asking a question
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
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
Are you actually on 2.16.1 or are you on latest master?
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
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
i see, thank you for this documentation..it seems i was trying with older one will try this and see if it works!
@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)
@andrewbaldwin44 package.json has version 2.16.1 hard coded, which is weird. Can we make it use the same versioning as locust somehow?
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
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
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.
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
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 ...)
i'm now able to build my local code successfully, thank you for the support!
No worries, thanks for reporting this! Keeping this ticket open for Matthew to take a look :)
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
makefrom the prebuild steps (callyarndirectly)- We'll need to re-wrap the "you don't have yarn installed" scenario inside the prebuild script if we avoid
make
- We'll need to re-wrap the "you don't have yarn installed" scenario inside the prebuild script if we avoid
- 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
pipfor this project unfortunately 🤔
- I don't imagine that there's much we can do about someone running
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.
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
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.
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!