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

Test under python 3.12 #1167

Merged
merged 3 commits into from
Nov 2, 2023
Merged

Conversation

dairiki
Copy link
Contributor

@dairiki dairiki commented Sep 19, 2023

Python 3.12rc3 — the final release candidate — is out.

@dairiki dairiki changed the title Test undef python 3.12 Test under python 3.12 Sep 19, 2023
@dairiki dairiki force-pushed the feat.test-under-python3.12 branch 8 times, most recently from 508e3d6 to a0b8ad9 Compare September 20, 2023 00:44
@dairiki
Copy link
Contributor Author

dairiki commented Sep 20, 2023

See python/cpython#109590 for an explanation of the failure under python 3.12 on Windows.

This is happening during the package build stage, here

lektor/build_frontend.py

Lines 68 to 77 in efd15bc

npm = shutil.which("npm")
if npm is None:
app.abort("npm is not available. can not build frontend")
frontend = Path(root, FRONTEND)
if not frontend.is_dir():
app.abort("frontend source is missing. can not build frontend")
app.display_info("npm install")
subprocess.run((npm, "install"), cwd=frontend, check=True)

where shutil.which in python 3.12 finds a bash script for npm rather than the cmd string npm.cmd. (Windows doesn't know about bash scripts.)

Note that this (I think) only affects the package build process. In shouldn't affect users who install from PyPI.

I'm not sure what the best fix is. I guess wait to see what happens on python/cpython#109590 before worrying too much.

@dairiki dairiki force-pushed the feat.test-under-python3.12 branch 7 times, most recently from dde9a0c to 699ff5a Compare November 1, 2023 18:56
This works around a bug in python 3.12.0's `shutil.which` when running
on Windows.

See python/cpython#109590
@dairiki dairiki marked this pull request as ready for review November 1, 2023 19:49
@dairiki
Copy link
Contributor Author

dairiki commented Nov 1, 2023

See python/cpython#109590 for an explanation of the failure under python 3.12 on Windows.

So python/cpython#109590 was fixed in python/cpython#109995, however, that fix did not make it into python 3.12.0 ☹️ (It is, I think, scheduled for inclusion in 3.12.1.)

So here I've made things work by changing build_frontend.py to run npm using the shell=True argument to subprocess.run (instead of using shutil.which to resolve an absolute path to npm, which is broken on Windows in python 3.12.0 by python/cpython#109590).

The first workaround I tried, running npm without an absolute path, e.g. subprocess.run(("npm", "-v")) does not seem to work on Windows (⇒ FileNotFoundError for undetermined reasons).

@dairiki dairiki merged commit ffa0f49 into lektor:master Nov 2, 2023
16 checks passed
@dairiki dairiki deleted the feat.test-under-python3.12 branch November 2, 2023 19:29
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.

None yet

1 participant