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

Fix the shebang in certain scripts #192

Merged
merged 14 commits into from
Oct 14, 2024
Merged

Conversation

hmaarrfk
Copy link
Contributor

@hmaarrfk hmaarrfk commented Sep 28, 2024

Closes: #191

Checklist

  • Used a personal fork of the feedstock to propose changes
  • Bumped the build number (if the version is unchanged)
  • Reset the build number to 0 (if the version changed)
  • Re-rendered with the latest conda-smithy (Use the phrase @conda-forge-admin, please rerender in a comment in this PR for automated rerendering)
  • Ensured the license file is being packaged.

Copy link
Contributor

github-actions bot commented Sep 28, 2024

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe/meta.yaml) and found it was in an excellent condition.

@pkgw pkgw changed the title Try to fix the shebank in certain scripts Try to fix the shebang in certain scripts Sep 29, 2024
recipe/meta.yaml Outdated
Comment on lines 222 to 224
- head -n 1 ${PREFIX}/bin/glib-mkenums | grep -E "(${PREFIX}|/usr/bin/env python)" # [unix]
- head -n 1 ${PREFIX}/bin/glib-genmarshal | grep -E "(${PREFIX}|/usr/bin/env python)" # [unix]
- head -n 1 ${PREFIX}/bin/gtester-report | grep -E "(${PREFIX}|/usr/bin/env python)" # [unix]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So i don't really understand why or how this became /usr/bin/env instead of the ${PREFIX}...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe it is a detail with how noarch python works?

Copy link
Member

@ehfd ehfd Oct 3, 2024

Choose a reason for hiding this comment

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

It's because it's supposed to point to the environment Python when installed instead of some strange prefix only used during build, but I don't know the internal mechanism Conda uses to replace it to /usr/bin/env python.

recipe/install.sh Outdated Show resolved Hide resolved
@ehfd
Copy link
Member

ehfd commented Oct 3, 2024

@hmaarrfk Any news? Downstream, the only solution is to pin, which is pretty dirty.

recipe/meta.yaml Outdated Show resolved Hide resolved
@hmaarrfk
Copy link
Contributor Author

hmaarrfk commented Oct 3, 2024

I think this is a step in the right direction.

@hmaarrfk
Copy link
Contributor Author

hmaarrfk commented Oct 3, 2024

but honestly, i don't really want want to maintain the "g" software stack too much, so I want some of the maintainers to chime in with quick review before merging.

recipe/meta.yaml Outdated
@@ -205,6 +216,12 @@ outputs:
- test -f ${PREFIX}/lib/libglib-2.0${SHLIB_EXT} # [unix]
- glib-compile-resources --help
- gobject-query --help
# I'm not sure why the PREFIX ends up becoming the /usr/bin/env python
Copy link
Member

Choose a reason for hiding this comment

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

Shebang's can't be longer than 80 lines, so conda fixes them for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah i see. Thanks!

In this case, is the test correct, or should it be made stricter? (i.e. only testing for /usr/bin/env python)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm ... did you check whether these tests fail if you don't apply the shebang fix? I am pretty sure that if the shebang line in the source file had $BUILD_PREFIX in it, the test would indeed fail, because Conda's prefix-rewriting logic wouldn't be activated at all.

If that's the case, then I think the test is fine as-is. I believe that in all of our build environments, the package test is run inside a directory that's got a sufficiently long absolute path that the /usr/bin/env replacement will always be active. But if you build this recipe outside of the conda-forge framework, the test prefix could conceivably be something like /c/conda-bld/glib-123556890/_test_env where the rewriting would not kick in.

Isuru's diagnosis is 100% correct, I believe, so it might be good to update the comment and add a link to this pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok lets test the tests. I think they worked in the past. but i forget.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well my tests fail to actually catch the error, but these replacements are necessary:

+ head -n 1 /home/conda/feedstock_root/build_artifacts/glib-split_1728918802549/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place/bin/glib-mkenums
+ grep -E '^
head -n 1 /home/conda/feedstock_root/build_artifacts/glib-split_1728918802549/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place/bin/glib-genmarshal | grep -E ^'
#!/home/conda/feedstock_root/build_artifacts/glib-split_1728918802549/_build_env/bin/python3.13
+ head -n 1 /home/conda/feedstock_root/build_artifacts/glib-split_1728918802549/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place/bin/gtester-report
++ pkg-config --cflags --libs glib-2.0

Copy link
Contributor

@pkgw pkgw Oct 14, 2024

Choose a reason for hiding this comment

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

Oooohhhhh that's tricky — it looks like the YAML parse is yielding surprising results for those lines. If they were passed through to the shell verbatim, I think they would work as you had them before. It might be worth encasing the whole lines in double quotes to make the YAML-level subtlety more apparent.

edit: Actually they wouldn't have worked before due to the missing exclamation points. But I think the \# is only necessary for the YAML parser, not the shell or regex parser.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn’t get the matching of the # to work. But matching it with anything helped test for the prefix.

Now let’s see if the “fix” works

recipe/install.sh Outdated Show resolved Hide resolved
recipe/install.sh Outdated Show resolved Hide resolved
@hmaarrfk hmaarrfk changed the title Try to fix the shebang in certain scripts Fix the shebang in certain scripts Oct 3, 2024
@ehfd
Copy link
Member

ehfd commented Oct 13, 2024

@hmaarrfk @isuruf Any reviews or finalizations?

Copy link
Contributor

@pkgw pkgw left a comment

Choose a reason for hiding this comment

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

A couple of small suggestions but I think this is pretty much ready.

# These files are the only difference when running with a different setting of -Dintrospection
if [[ "${CONDA_BUILD_CROSS_COMPILATION:-0}" == 1 ]]; then
cp -ap introspection/lib/girepository-1.0 $PREFIX/lib
cp -ap introspection/share/gir-1.0 $PREFIX/share
Copy link
Contributor

Choose a reason for hiding this comment

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

Some wonky indentation here.

recipe/meta.yaml Outdated
@@ -205,6 +216,12 @@ outputs:
- test -f ${PREFIX}/lib/libglib-2.0${SHLIB_EXT} # [unix]
- glib-compile-resources --help
- gobject-query --help
# I'm not sure why the PREFIX ends up becoming the /usr/bin/env python
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm ... did you check whether these tests fail if you don't apply the shebang fix? I am pretty sure that if the shebang line in the source file had $BUILD_PREFIX in it, the test would indeed fail, because Conda's prefix-rewriting logic wouldn't be activated at all.

If that's the case, then I think the test is fine as-is. I believe that in all of our build environments, the package test is run inside a directory that's got a sufficiently long absolute path that the /usr/bin/env replacement will always be active. But if you build this recipe outside of the conda-forge framework, the test prefix could conceivably be something like /c/conda-bld/glib-123556890/_test_env where the rewriting would not kick in.

Isuru's diagnosis is 100% correct, I believe, so it might be good to update the comment and add a link to this pull request.

recipe/meta.yaml Outdated Show resolved Hide resolved
@hmaarrfk
Copy link
Contributor Author

Well lmk if there is anything else. But also feel free to push cosmetic or functional changes

@pkgw pkgw merged commit 7875eb8 into conda-forge:main Oct 14, 2024
8 checks passed
@pkgw
Copy link
Contributor

pkgw commented Oct 14, 2024

Thanks for slogging through this one!

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.

Incorrect Shebang in glib-mkenums Script
4 participants