Skip to content

Add bin folder to python targets, and adapt the regular python layout (save for the zip). #39

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ivorforce
Copy link
Contributor

@Ivorforce Ivorforce commented Oct 28, 2024

Addresses #19. We should probably document this (and / or make it simpler), but this is a good start.

This allows godot-python users to use python (and pip) out of the box:

PYTHONPATH=bin/macos-x86_64/python312.zip:bin/macos-x86_64/python312.zip/site-packages bin/macos-x86_64/python/bin/python3 -m pip install -t bin/macos-x86_64/python/lib/python3.12/site-packages <packages>

The python binary points to @executable_path/../lib/libpython3.12.dylib so it's already configured correctly with this new layout (i.e. python lib moved to python/lib).

The bin folder is .gdignore'd.

@Ivorforce Ivorforce force-pushed the python-bin branch 5 times, most recently from 956dd1a to aa90fdb Compare October 28, 2024 17:01
@maiself maiself added documentation Improvements or additions to documentation enhancement New feature or request build related to the build system export related to project export investigate needs further investigation labels Oct 29, 2024
@Ivorforce Ivorforce force-pushed the python-bin branch 2 times, most recently from 889af7f to d068625 Compare October 29, 2024 00:38
uses: actions/upload-artifact@v4
with:
name: godot-python-${{ matrix.platform }}-${{ matrix.arch }}
path: bin/**/*
path: godot-python-${{ matrix.platform }}-${{ matrix.arch }}.zip
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 was hoping providing a single path would make it upload the file as-is, but it's still zipping the zip. Need to find a better way.

@maiself
Copy link
Owner

maiself commented Feb 15, 2025

Questions:

  • Does adding the new python subdirectory break linking?
  • Have you tested on platforms aside from mac?
  • What are the consequences of running python in this environment?
  • Does this use a local python config or pull from the systems?
  • Will there be conflict with this config vs the projects isolated config?
  • Is this really the right approach?

@maiself
Copy link
Owner

maiself commented Feb 16, 2025

Linux build is broken with this:

ERROR: Can't open dynamic library: /home/mai/src/godot-python-extension/test/bin/linux-x86_64/libgodot-python.linux.x86_64.so.
Error: libpython3.12.so.1.0: cannot open shared object file: No such file or directory.

Probably due to moving libpython to a subdirectory:

readelf -d bin/linux-x86_64/libgodot-python.linux.x86_64.so
...
 0x0000000000000001 (NEEDED)             Shared library: [libpython3.12.so.1.0]
...
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN]
...

Not sure how I feel about setting all sorts of RPATHs on all platforms... Need to test Python extension modules, as well as Windows. Need to find a layout and dynamic linking config that will be simple and work reliably on all platforms.

Incorrect dynamic linking is blocking for any patch. Maybe a test could be made to run after the GitHub build actions.

… (save for the zip). Use the zip upload archive method in the github runner for macOS, too, to preserve permissions.
@Ivorforce
Copy link
Contributor Author

Ivorforce commented Feb 16, 2025

Does adding the new python subdirectory break linking?

No, at least not for me, why would it?

Have you tested on platforms aside from mac?

Nope, I don't have any other systems on hand.

What are the consequences of running python in this environment?

Nothing really. It has been working as expected so far.

Does this use a local python config or pull from the systems?

What do you mean by 'python config'? It's using the python executable that are part of the indygreg standalone builds.

Will there be conflict with this config vs the projects isolated config?

Hrm, I'm not sure I understand what you are asking here. Would you mind explaining?

Is this really the right approach?

I definitely think so. Using this approach, python can be used 'as expected', including pip and other functionality. I nice side effect is being able to use python to test things before interfacing with them from the Godot runtime itself.

Not sure how I feel about setting all sorts of RPATHs on all platforms...

python itself is using RPATHs for linking executable and library. I think it's the standard way to deal with this problem.

@maiself
Copy link
Owner

maiself commented Feb 16, 2025

Considering this blocked until #44 is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build related to the build system documentation Improvements or additions to documentation enhancement New feature or request export related to project export investigate needs further investigation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants