Skip to content

Use sysconfig for Python dll locations#21

Merged
jtanx merged 1 commit intojtanx:masterfrom
iorsh:py_sysconfig
May 24, 2024
Merged

Use sysconfig for Python dll locations#21
jtanx merged 1 commit intojtanx:masterfrom
iorsh:py_sysconfig

Conversation

@iorsh
Copy link
Copy Markdown
Contributor

@iorsh iorsh commented May 24, 2024

distutils is deprecated with removal planned for Python 3.12.

Replace distutils with a similar functionality from sysconfig to avoid CI failure.

This change is necessary to update CI to macos-12, which doesn't have Python 3.10.

Please review this PR together with the related fontforge/fontforge#5423

@iorsh
Copy link
Copy Markdown
Contributor Author

iorsh commented May 24, 2024

Appveyor is failing, I'll need to take a look.

@iorsh
Copy link
Copy Markdown
Contributor Author

iorsh commented May 24, 2024

All tests pass, @jtanx, @skef please review.

@jtanx jtanx merged commit 5ddd85f into jtanx:master May 24, 2024
@jtanx
Copy link
Copy Markdown
Owner

jtanx commented May 24, 2024

I just tried building this, this fails for me:

Copying the Python extension dlls...
cp: cannot stat '/home/_/ffbuild/target/mingw32//lib/python3.11-mingw_i686/site-packages/fontforge.pyd': No such file or directory
!!! Build failed at: Couldn't copy pyhook dlls

@jtanx
Copy link
Copy Markdown
Owner

jtanx commented May 24, 2024

Should this not be something more like

PY_DLLS_SRC_PATH=`/$MINGVER/bin/python.exe -c "import sysconfig as sc; print(sc.get_path('platlib', sc.get_preferred_scheme('prefix'), vars={'platbase': '.'}))"`

@iorsh
Copy link
Copy Markdown
Contributor Author

iorsh commented May 25, 2024

I just tried building this, this fails for me:

Copying the Python extension dlls...
cp: cannot stat '/home/_/ffbuild/target/mingw32//lib/python3.11-mingw_i686/site-packages/fontforge.pyd': No such file or directory
!!! Build failed at: Couldn't copy pyhook dlls

Did you build together with the changes in fontforge/fontforge#5423 ? They can't work separately. If you did, and it failed, please try fontforge@e16f32d with iorsh/fontforge@418a9fc and attach the entire building log. I'll check.

@iorsh
Copy link
Copy Markdown
Contributor Author

iorsh commented May 25, 2024

Should this not be something more like

PY_DLLS_SRC_PATH=`/$MINGVER/bin/python.exe -c "import sysconfig as sc; print(sc.get_path('platlib', sc.get_preferred_scheme('prefix'), vars={'platbase': '.'}))"`

Unfortunately 'prefix' key is inconsistent across platforms. On MacOS the preferred scheme for prefix is osx_framework_library, and its platlib entry looks like

'platlib': '/usr/local/{platlibdir}/python{py_version_short}/site-packages'

This forces absolute path (which is discouraged by CMake) and the variable names are different for each platform. You can check this at https://github.com/iorsh/fontforge/actions/runs/9223726161/ - see the "Run pyhook smoke test" entry for Mac and Linux

@jtanx
Copy link
Copy Markdown
Owner

jtanx commented May 25, 2024

Ok, I see that change, but it looks wrong imo. The default installation shouldn't be assuming a user install.

@iorsh
Copy link
Copy Markdown
Contributor Author

iorsh commented May 25, 2024

I'm a bit confused here about the build steps. As I understand, pyhook/CMakeLists.txt installs files in some intermediate location, and in this location sc.get_path() is used as a local subpath. The final copying occurs in ffbuild.sh:518 from that intermediate location to $RELEASE/lib/$PYVER/site-packages/, which I didn't touch.

Maybe I should keep the intermediate location with sc.get_preferred_scheme('user'), and add something like

PY_DLLS_TARGET_PATH=`/$MINGVER/bin/python.exe -c "import sysconfig as sc; print(sc.get_path('platlib', sc.get_preferred_scheme('prefix'), vars={'platbase': '.'}))"`
cp -f "$TARGET/$PY_DLLS_SRC_PATH/fontforge.pyd" "$RELEASE/$PY_DLLS_TARGET_PATH" || bail "Couldn't copy pyhook dlls"
cp -f "$TARGET/$PY_DLLS_SRC_PATH/psMat.pyd" "$RELEASE/$PY_DLLS_TARGET_PATH" || bail "Couldn't copy pyhook dlls"

Maybe I'm missing something here though.. What do you think?

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.

2 participants