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 wheel #2389

Merged
merged 3 commits into from
Feb 10, 2025
Merged

Build wheel #2389

merged 3 commits into from
Feb 10, 2025

Conversation

niklasmohrin
Copy link
Member

@niklasmohrin niklasmohrin commented Feb 10, 2025

This is in preparation for #2328. The entire workflow is documented in the build-dist nix script, which can be run via nix run .#build-dist. In particular, the wheel intentionally contains the built JavaScript, CSS, and translations, so that these steps don't need to be run on production anymore. To test the process, I added a CI job that builds the wheel and another that installs it using a non-nix Python installation.

The entire workflow is documented in the `build-dist` nix script, which can be run via `nix run .#build-dist`.

In particular, the wheel intentionally contains the built JavaScript, CSS, and translations, so that these steps don't need to be run on production anymore.
@niklasmohrin niklasmohrin marked this pull request as ready for review February 10, 2025 21:19
@niklasmohrin
Copy link
Member Author

@richardebeling You previously had concerns that we would at some point forget to update the build configuration in pyproject.toml and thus miss some files in the wheel. Do you see a good way to add a more robust setup here to overcome this? I was thinking that we could possibly run the live server tests through the wheel at some point, because that needs the javascript etc., but it also seems strange

@richardebeling
Copy link
Member

I think for js we're fine with the *.js inclusion rule. Same for *.mo. Css should also be fine as long as we always build a evap.css monolith. I'm a bit more worried about dependencies a la bootstrap and font-awesome. I guess we'll just have to think about that, then -- but if we forget it wouldn't be the end of the world, downgrading versions should be much simpler with this. It's probably fine.

Copy link
Collaborator

@Kakadus Kakadus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is bootstrap missing or so.

  1. create a new venv python3.10 -n venv venv && source venv/bin/activate
  2. install evap wheel: pip install evap-0.0.0-py3-none-any.whl
  3. setup localsettings for redis and postgres
  4. python -m evap runserver 0.0.0.0:8000 leads to:
    image
    when opening the index page

everything else seems to be fine...

[2025-02-10 22:38:46,287] DEBUG: request is not refreshable
[2025-02-10 22:38:46,311] INFO: "GET / HTTP/1.1" 302 0
[2025-02-10 22:38:46,321] DEBUG: request is not refreshable
/home/jonas/development/evap/tmp/vevn/lib/python3.10/site-packages/django/core/cache/backends/redis.py:27: RuntimeWarning: Pickled model instance's Django version 5.1.3 does not match the current version 5.1.6.
return pickle.loads(data)
[2025-02-10 22:38:46,521] INFO: "GET /contributor/ HTTP/1.1" 200 170173
[2025-02-10 22:38:46,599] INFO: "GET /static/css/evap.css HTTP/1.1" 200 755
[2025-02-10 22:38:46,602] INFO: "GET /static/js/csrf-utils.js HTTP/1.1" 200 629
[2025-02-10 22:38:46,605] INFO: "GET /static/js/utils.js HTTP/1.1" 200 1462
[2025-02-10 22:38:46,608] INFO: "GET /static/js/base-template.js HTTP/1.1" 200 415
[2025-02-10 22:38:46,610] DEBUG: request is not refreshable
[2025-02-10 22:38:46,615] INFO: "GET /static/js/confirmation-modal.js HTTP/1.1" 200 3215
[2025-02-10 22:38:46,619] INFO: "GET /static/js/contact_modal.js HTTP/1.1" 200 2448
[2025-02-10 22:38:46,620] INFO: "GET /static/js/infobox.js HTTP/1.1" 200 1498
[2025-02-10 22:38:46,620] INFO: "GET /static/js/notebook.js HTTP/1.1" 200 2756
[2025-02-10 22:38:46,626] INFO: "GET /catalog.js HTTP/1.1" 200 3000
[2025-02-10 22:38:46,667] INFO: "GET /static/js/custom-success-form.js HTTP/1.1" 200 1161
[2025-02-10 22:38:46,671] INFO: "GET /static/js/translation.js HTTP/1.1" 200 11

@Kakadus
Copy link
Collaborator

Kakadus commented Feb 10, 2025

Ahh, I found the problem: I ran python -m evap sass at one time and it all went south. If you don't run it, everything is fine!

❯ python -m evap scss
Error: Can't find stylesheet to import.

1 │ @import "../bootstrap/scss/functions";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

venv/lib/python3.10/site-packages/evap/static/scss/evap.scss 1:9 root stylesheet
Traceback (most recent call last):
File "/home/jonas/.pyenv/versions/3.10.13/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/jonas/.pyenv/versions/3.10.13/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/jonas/development/evap/tmp/venv/lib/python3.10/site-packages/evap/main.py", line 18, in
sys.exit(main())
File "/home/jonas/development/evap/tmp/venv/lib/python3.10/site-packages/evap/main.py", line 14, in main
execute_from_command_line(sys.argv)
File "/home/jonas/development/evap/tmp/venv/lib/python3.10/site-packages/django/core/management/init.py", line 442, in execute_from_command_line
utility.execute()
File "/home/jonas/development/evap/tmp/venv/lib/python3.10/site-packages/django/core/management/init.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/jonas/development/evap/tmp/venv/lib/python3.10/site-packages/django/core/management/base.py", line 413, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/jonas/development/evap/tmp/venv/lib/python3.10/site-packages/django/core/management/base.py", line 459, in execute
output = self.handle(*args, **options)
File "/home/jonas/development/evap/tmp/venv/lib/python3.10/site-packages/evap/evaluation/management/commands/scss.py", line 37, in handle
subprocess.run(command, check=True) # nosec
File "/home/jonas/.pyenv/versions/3.10.13/lib/python3.10/subprocess.py", line 526, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['npx', 'sass', PosixPath('/home/jonas/development/evap/tmp/venv/lib/python3.10/site-packages/evap/static/scss/evap.scss'), PosixPath('/home/jonas/development/evap/tmp/venv/lib/python3.10/site-packages/evap/static/css/evap.css')]' returned non-zero exit status 65.

@niklasmohrin niklasmohrin merged commit aee0cda into e-valuation:main Feb 10, 2025
15 checks passed
@niklasmohrin niklasmohrin deleted the wheel branch February 10, 2025 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants