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

Use hatchling to build distribution #1112

Merged
merged 7 commits into from Mar 9, 2023

Conversation

dairiki
Copy link
Contributor

@dairiki dairiki commented Mar 1, 2023

I've extracted just the packaging bits out of #1082 and updated them here.

Issue(s) Resolved

Fixes #1081

Related Issues / Links

Supercedes #1082

Description of Changes

  • Wrote at least one-line docstrings (for any new functions)
  • Added unit test(s) covering the changes (if testable)

Changes include:

  • Use hatchling as our PEP 517 build engine
  • Move package metadata from setup.cfg to pyproject.toml (PEP 621)
  • Implement a hatch build-hook that builds our front-end JS and CSS as part of the PEP 517 build process
  • Move the publish CI job from the publish.yml workflow into our ci.yml workflow.

Hatchling's support of build hooks allows us to integrate the building of our front-end JS and CSS into the PEP 517 build process. Among other things, this makes it possible to install a working version of Lektor directly from git. E.g.

python -m venv _venv
_venv/bin/pip install git+https://github.com/dairiki/lektor.git@refactor.hatchling-build
_venv/bin/lektor server

will work (assuming the user has a working installation of Node/npm).

Moving the publish job to the main CI workflow allows for two improvements:

  • Publishing won't happen if any of the CI tests fail
  • Every run of the main workflow builds the package, thus testing that that works

@dairiki dairiki merged commit 0ba8a9c into lektor:master Mar 9, 2023
@dairiki dairiki deleted the refactor.hatchling-build branch March 9, 2023 02:52
dairiki added a commit to dairiki/lektor that referenced this pull request Sep 11, 2023
* refactor(packaging): use hatchling to build package

This includes a custom build hook to build our frontend js & css

* refactor(ci): use pypa/gh-action-pypi-publish action

* refactor(ci): move publish job to the ci workflow

This accomplishes two things:

- Ensures that tests pass before publishing
- On each workflow run, tests that the packaging works

* test(ci): upload built wheel and sdist for examination

* refactor(packaging): delete build-dist testenv from tox config

* refactor(packaging): remove dist and upload targets from Makefile

* docs(README): update the development instructions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Build] Missing frontend assets when building from the source
1 participant