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

Implement getting binary path on OpenBSD #2869

Closed
wants to merge 3 commits into from

Conversation

SuperDisk
Copy link
Contributor

@SuperDisk SuperDisk commented May 18, 2024

What does this PR do?

This commit adds a mostly untested function to get the path to the running binary on OpenBSD.

https://stackoverflow.com/questions/31494901/how-to-get-the-executable-path-on-openbsd

Why was it initiated? Any relevant Issues?

I initiated the PR upon request from here: #662 (comment)

I'm sorry I can't really help out more, I just did this as a quick hack to get my own thing working so I'm sure it needs to be revised before merging.

PR Checklist

  • Correct base branch selected? Should be develop branch.
  • Enabled commit hook or executed ./bin/autoformat-nuitka-source.
  • All tests still pass. Check the Developer Manual about Running the Tests. There are GitHub
    Actions tests that cover the most important things however, and you are welcome to rely on those,
    but they might not cover enough.
  • Ideally new features or fixed regressions ought to be covered via new tests.
  • Ideally new or changed features have documentation updates.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine. If you would also like our AI-powered code review then let us know.

@kayhayen
Copy link
Member

So, I am able to force push into your repository there. I rebased to develop, and commented out with #if 0 what I think is a strip of the directory name that should make it wrong. Please compile with --standalone and report what happens. @SuperDisk

@kayhayen
Copy link
Member

Make sure do git pull --rebase on your branch btw

@SuperDisk
Copy link
Contributor Author

SuperDisk commented May 18, 2024

@kayhayen Is there a sample program I can compile to verify the output against what it's supposed to look like?

@kayhayen
Copy link
Member

tests/standalone/CtypesUsing.py

@SuperDisk
Copy link
Contributor Author

(building-nuitka-venv) nickfaro$ pwd
/home/npfaro/making-nuitka/Nuitka/CtypesUsing.dist
(building-nuitka-venv) nickfaro$ ./CtypesUsing.bin                                                             
(building-nuitka-venv) nickfaro$ 

It doesn't crash at least, is it supposed to do something?

@kayhayen
Copy link
Member

Oh yes, it is only tested on Windows and Linux really, use tests/standalone/LxmlUsing.py with lxml installed of course then. Not crashing is very good though. :)

@SuperDisk
Copy link
Contributor Author

Well I mean is there something that actually tests this binary-name-getting functionality?

@kayhayen
Copy link
Member

Standalone does have to use it at program launch I think, cannot work without it, I believe. But you can always just print(__file__) and compile that.

@kayhayen
Copy link
Member

Did you have a chance to try printing file ?

@SuperDisk
Copy link
Contributor Author

Looks like it works:

(building-nuitka-venv) nickfaro$ ./hi.bin
/home/npfaro/making-nuitka/hi.py

@kayhayen
Copy link
Member

Ok, I will give a final brush up then and merge it to factory. i will keep you posted, when you should try it.

@kayhayen
Copy link
Member

Can you try the current factory branch: You can try it out by going here: https://nuitka.net/doc/factory.html

@SuperDisk
Copy link
Contributor Author

I'm currently getting this:

(building-nuitka-venv) nickfaro$ more hi.py                                                                            
print(__file__)
(building-nuitka-venv) nickfaro$ rm hi.bin                                                                             
(building-nuitka-venv) nickfaro$ python3 -m nuitka hi.py
Nuitka-Options: Used command line options: hi.py
Nuitka-Options:WARNING: You did not specify to follow or include anything but main program. Check options and make sure
Nuitka-Options:WARNING: that is intended.
Nuitka-Options: Detected static libpython to exist, consider '--static-libpython=yes' for better performance, but errors
Nuitka-Options: may happen.
Nuitka: Starting Python compilation with Nuitka '2.3rc5' on Python '3.10' commercial grade 'not installed'.
Nuitka: Completed Python level compilation and optimization.
Nuitka: Generating source code for C backend compiler.
Nuitka: Running data composer tool for optimal constant value handling.
Nuitka: Running C compilation via Scons.
Nuitka-Scons: Backend C compiler: clang (clang 16.0.6).
In file included from static_src/CompiledFunctionType.c:3121:
In file included from /home/npfaro/making-nuitka/building-nuitka-venv/lib/python3.10/site-packages/Nuitka-2.3rc5-py3.10.egg/nuitka/build/static_src/CompiledCodeHelpers.c:56:
/home/npfaro/making-nuitka/building-nuitka-venv/lib/python3.10/site-packages/Nuitka-2.3rc5-py3.10.egg/nuitka/build/static_src/HelpersFilesystemPaths.c:80:17: error: use of undeclared identifier 'ok'
                ok = 1;                        
                ^                              
1 error generated.                             
Nuitka-Scons: Backend linking program with 7 files (no progress information available for this stage).
scons: *** [static_src/CompiledFunctionType.o] Error 1
FATAL: Failed unexpectedly in Scons C backend compilation.
Nuitka:WARNING:     Complex topic! More information can be found at
Nuitka:WARNING: https://nuitka.net/info/scons-backend-failure.html
Nuitka-Reports: Compilation crash report written to file 'nuitka-crash-report.xml'.

@kayhayen
Copy link
Member

Ok, please retry, my bad.

@SuperDisk
Copy link
Contributor Author

@kayhayen It's working for me :)

@kayhayen
Copy link
Member

Great, adding OpenBSD to the list of supported OSes. :)

@kayhayen kayhayen closed this May 24, 2024
@kayhayen kayhayen added enhancement An improvement rather than a bug factory For issues fixed in factory only excellent_report labels May 24, 2024
@kayhayen
Copy link
Member

This will be in the 2.3 release shortly

@kayhayen
Copy link
Member

def hasOnefileSupportedOS():
    return getOS() in ("Linux", "Windows", "Darwin", "FreeBSD")


def hasStandaloneSupportedOS():
    return getOS() in ("Linux", "Windows", "Darwin", "FreeBSD", "OpenBSD")

Can you check if onefile works for you if you extend the list, I wouldn't know why not.

@kayhayen kayhayen added the needs_example User input needed label May 24, 2024
@kayhayen kayhayen self-assigned this May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement rather than a bug excellent_report factory For issues fixed in factory only needs_example User input needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants