Skip to content

Commit aee0cda

Browse files
authored
Build wheel (#2389)
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.
1 parent 5404511 commit aee0cda

File tree

4 files changed

+71
-3
lines changed

4 files changed

+71
-3
lines changed

.github/workflows/tests.yml

+31
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,37 @@ jobs:
3939
- name: Run tests
4040
run: python manage.py test --shuffle
4141

42+
build_wheel:
43+
name: Build wheel
44+
runs-on: ubuntu-22.04
45+
steps:
46+
- uses: actions/checkout@v4
47+
with:
48+
submodules: true
49+
- uses: DeterminateSystems/nix-installer-action@main
50+
- run: nix run .#build-dist
51+
- run: tar tvf dist/*.tar.gz
52+
- run: unzip -l dist/*.whl
53+
- uses: actions/upload-artifact@v4
54+
with:
55+
name: wheel
56+
path: dist/
57+
58+
install_wheel:
59+
name: Install wheel with system Python
60+
needs: build_wheel
61+
runs-on: ubuntu-22.04
62+
steps:
63+
- uses: actions/setup-python@v5
64+
with:
65+
python-version: '3.10'
66+
- uses: actions/download-artifact@v4
67+
with:
68+
name: wheel
69+
- run: pip install *.whl
70+
- name: Check that "evaluation" section appears in help string
71+
run: python -m evap --help | grep --fixed-strings "[evaluation]"
72+
4273
mypy:
4374
runs-on: ubuntu-22.04
4475

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ TAGS
1414

1515
# python files
1616
*.py[cod]
17+
dist/
1718

1819
# gettext binaries
1920
*.mo

flake.nix

+18
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,24 @@
9090
done
9191
'';
9292
};
93+
94+
build-dist = pkgs.writeShellApplication {
95+
name = "build-dist";
96+
runtimeInputs = with pkgs; [ nodejs gettext git ];
97+
text =
98+
let
99+
python-dev = self.devShells.${system}.evap-dev.passthru.venv;
100+
python-build = self.packages.${system}.python3.withPackages (ps: [ ps.build ]);
101+
in
102+
''
103+
set -x
104+
npm ci
105+
${python-dev}/bin/python ./manage.py compilemessages
106+
${python-dev}/bin/python ./manage.py scss --production
107+
${python-dev}/bin/python ./manage.py ts compile --fresh
108+
${python-build}/bin/python -m build
109+
'';
110+
};
93111
});
94112
};
95113
}

pyproject.toml

+21-3
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,31 @@ dev = [
3939
"typeguard~=4.4.0",
4040
]
4141

42+
[tool.uv]
43+
no-binary-package = [
44+
"psycopg-c",
45+
]
46+
4247
[build-system]
4348
requires = ["hatchling"]
4449
build-backend = "hatchling.build"
4550

46-
[tool.uv]
47-
no-binary-package = [
48-
"psycopg-c",
51+
[tool.hatch.build]
52+
skip-excluded-dirs = false # otherwise, the artifacts below will be skipped
53+
exclude = [
54+
"evap/static/bootstrap",
55+
"evap/static/font-awesome",
56+
]
57+
artifacts = [
58+
"evap/static/css/evap.css",
59+
"evap/static/css/evap.css.map",
60+
"evap/static/js/*.js",
61+
"evap/static/js/*.map",
62+
"evap/static/bootstrap/dist/js/bootstrap.bundle.min.js",
63+
"evap/static/bootstrap/dist/js/bootstrap.bundle.min.js.map",
64+
"evap/static/font-awesome/webfonts/",
65+
66+
"evap/locale/*.mo",
4967
]
5068

5169
##############################################

0 commit comments

Comments
 (0)