-
Notifications
You must be signed in to change notification settings - Fork 563
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
Add support for build scss files on hatch build #1363
Conversation
I moved away from pure |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1363 +/- ##
=======================================
Coverage 79.75% 79.75%
=======================================
Files 114 114
Lines 4737 4737
Branches 637 637
=======================================
Hits 3778 3778
Misses 748 748
Partials 211 211 ☔ View full report in Codecov by Sentry. |
@benjaoming I'll need help figuring out how to add libsassc inside of the read the docs CI |
Awesome work! This will make it much easier to build releases without maintaining the CSS artifact in git. Maybe we can argue this way? "libsass" and "pysass" are build dependencies. So we need to define the build dependencies explicitly (not sure what is the "hatch way" of doing that) For now, I've added it as a docs dependency... but maybe there's a better way? |
Ah, this reminds me of when setup.py had a hack to specify that it needed some requirements to be installed BEFORE installing with |
I think the current error is something about the build environment being isolated from the environment that the documentation dependencies are installed into. So I guess that whole approach won't work 😖 |
Yeah, that's the thing! Our approach works for CircleCI since we can have packages installed on each matrix environment. And since this is not allowed I dont think it will work with the RTD CI environment. I dont think that marking this as a build dependency is a good idea, I really like the approach to have concerns separate and dont block Python development, just because a contributor doesn't have properly configured a SCSS installation. Do you know if there's a way to check if the RDT CI has an environment variable that we can read and conditionally run the command? |
Yes, you can define environment variables on RTD 👍 |
Agreed! |
@benjaoming this should be good to go :) |
@@ -1,5 +1,5 @@ | |||
[build-system] | |||
requires = ["hatchling"] | |||
requires = ["hatchling", "hatch-build-scripts"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! So I guess that it's not possible to list libsass here?
I've clicked "watching" on the hatch-build-scripts repo since it seems like it's a small project: https://github.com/rmorshea/hatch-build-scripts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good observation!!
Based on the PEP documentation, we can place it there (https://peps.python.org/pep-0518/) I could explore that just in case, the only thing I'm not OK is that using this solution will make the lib sass required for everything, since for each environment this is build on dev mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a bad idea. I don't have any strong opinions on this one, if the libsass dependency isn't really problematic and pysassc is fast to run, then it's okay for me. But we can easily just wait and see if the new setup causes any problems, it also seems fine as it is 👍
[[tool.hatch.build.hooks.build-scripts.scripts]] | ||
out_dir = "src/wiki/static/wiki/bootstrap/css/" | ||
commands = [ | ||
"[[ -z $READTHEDOCS_VIRTUALENV_PATH ]] && pysassc --style compressed src/wiki/static/wiki/bootstrap/scss/wiki/wiki-bootstrap.scss src/wiki/static/wiki/bootstrap/css/wiki-bootstrap.min.css || true", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great solution 👍
Initial work for:
SCSS changes:
Output:
![image](https://private-user-images.githubusercontent.com/2553459/332544608-136ba616-c56e-452a-94c8-0917f19c2dcd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk2MDYzNzQsIm5iZiI6MTcxOTYwNjA3NCwicGF0aCI6Ii8yNTUzNDU5LzMzMjU0NDYwOC0xMzZiYTYxNi1jNTZlLTQ1MmEtOTRjOC0wOTE3ZjE5YzJkY2QucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYyOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MjhUMjAyMTE0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MDMyYmVkZmZhNGY0Mjk5Yjk4MDhkZTQ2YzJmYTRlMzI5ZWVhODA5YWVkNjFmYjE0M2UzNjM2NWQyNDJkYzFiMSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.xUl_0RKYppazsuMBjhWdQyWXo_kcZ_nyVk8o9xOLCyg)