Skip to content

Fix ssg get invalid jinja macros dir exception when using as third party library #13761

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

Merged

Conversation

AlexXuan233
Copy link
Contributor

Description:

  • Fix ssg preload_macros function get invalid jinja macros dir exception when using as third party library.

Rationale:

  • When ssg using as a third party library, if you still use JINJA_MACROS_DIRECTORY constant to get jinja macros dir, it will get directory end with site-packages/shared/macros.

  • Fixes CPLYTM-916

Review Hints:

  • Using ssg inside content is all fine.
  • Using ssg as a third party python library, and when involve preload_macros function, will raise an exception. You can test with the following code
from ssg.profiles import get_profiles_from_products

profiles = get_profiles_from_products("content_root_dir", ["rhel10"])

print(profiles)

It will raise an exception without this PR, FileNotFoundError: [Errno 2] No such file or directory: '/home/fedora/.cache/pypoetry/virtualenvs/complyscribe-5ohETF1N-py3.12/lib/python3.12/site-packages/shared/macros'

@AlexXuan233
Copy link
Contributor Author

Failed checks should not related to this PR, because i noticed other recent PR also have same failed checks.

@AlexXuan233 AlexXuan233 force-pushed the fix-find-macros-dir-error branch from d71a5de to 7bab67f Compare August 7, 2025 07:15
@marcusburghardt marcusburghardt self-assigned this Aug 7, 2025
@marcusburghardt marcusburghardt added this to the 0.1.78 milestone Aug 7, 2025
Copy link
Member

@marcusburghardt marcusburghardt left a comment

Choose a reason for hiding this comment

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

LGTM. I have tested this internally and using ssg externally.

There is just a nit about the commits style guide: https://github.com/ComplianceAsCode/content/blob/master/docs/manual/developer/04_style_guide.md#commit-messages I don't think this blocks the PR but it would be great to have the commit aligned to the project style guides.

@marcusburghardt
Copy link
Member

@jan-cerny , would you like to also take a look?

When using ssg as a third party library, if you still use
JINJA_MACROS_DIRECTORY constant to get jinja macros dir,
it will get directory end with site-packages/shared/macros.
@AlexXuan233 AlexXuan233 force-pushed the fix-find-macros-dir-error branch from 7bab67f to 54749e9 Compare August 7, 2025 10:44
@AlexXuan233
Copy link
Contributor Author

LGTM. I have tested this internally and using ssg externally.

There is just a nit about the commits style guide: https://github.com/ComplianceAsCode/content/blob/master/docs/manual/developer/04_style_guide.md#commit-messages I don't think this blocks the PR but it would be great to have the commit aligned to the project style guides.

Hi, Marcus. I updated the commit message, thanks for your review.

Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

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

Looks good to me. I don't see any problem.

@jan-cerny jan-cerny merged commit 3a149cf into ComplianceAsCode:master Aug 7, 2025
127 of 128 checks passed
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.

3 participants