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

Update Windows build to Python 3.12 #327

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pys.each { py ->
parallel(tasks)
parallel modern: {
stage('Modern Windows binary') {
windowsBuild('3.11', 'dosage.exe')
windowsBuild('3.12', 'dosage.exe')
}
},
legacy: {
Expand Down
30 changes: 16 additions & 14 deletions scripts/dosage.spec
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
# SPDX-License-Identifier: MIT
# Copyright (C) 2017-2020 Tobias Gruetzmacher
# SPDX-FileCopyrightText: © 2017 Tobias Gruetzmacher

import re
from importlib import metadata

# Idea from
# https://github.com/pyinstaller/pyinstaller/wiki/Recipe-Setuptools-Entry-Point,
# but with importlib
def Entrypoint(group, name, **kwargs):
import re
try:
from importlib.metadata import entry_points
except ImportError:
from importlib_metadata import entry_points

def entrypoint(group, name, **kwargs):
# get the entry point
eps = entry_points()[group]
ep = next(ep for ep in eps if ep.name == name)
module, attr = re.split(r'\s*:\s*', ep.value, 1)
eps = metadata.entry_points()
if 'select' in dir(eps):
# modern
ep = eps.select(group=group)[name]
else:
# legacy (pre-3.10)
ep = next(ep for ep in eps[group] if ep.name == name)
module, attr = re.split(r'\s*:\s*', ep.value, maxsplit=1)

# script name must not be a valid module name to avoid name clashes on import
script_path = os.path.join(workpath, name + '-script.py')
print("creating script for entry point", group, name)
with open(script_path, 'w') as fh:
with open(script_path, mode='w', encoding='utf-8') as fh:
print("import sys", file=fh)
print("import", module, file=fh)
print("sys.exit(%s.%s())" % (module, attr), file=fh)
print(f"sys.exit({module}.{attr}())", file=fh)

return Analysis(
[script_path] + kwargs.get('scripts', []),
**kwargs
)


a = Entrypoint('console_scripts', 'dosage')
a = entrypoint('console_scripts', 'dosage')

a.binaries = [x for x in a.binaries if not x[1].lower().startswith(r'c:\windows')]

Expand Down
Loading