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

chore: add support for Python 3.13 [Linux and Windows] #2630

Merged
merged 2 commits into from
Dec 12, 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
4 changes: 2 additions & 2 deletions .github/workflows/build-wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
run: |
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
if [ "${{ github.event_name }}" == "pull_request" ]; then
./ci/build-wheel.sh "cp3{9,10,11,12}-manylinux*" --archs="x86_64"
./ci/build-wheel.sh "cp3{9,10,11,12,13}-manylinux*" --archs="x86_64"
else
./ci/build-wheel.sh --all
fi
Expand All @@ -77,7 +77,7 @@ jobs:
fi
else
if [ "${{ github.event_name }}" == "pull_request" ]; then
./ci/build-wheel.sh "cp3{9,10,11,12}-*" --archs="AMD64"
./ci/build-wheel.sh "cp3{9,10,11,12,13}-*" --archs="AMD64"
else
./ci/build-wheel.sh --all
fi
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-14]
python-version: ['3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
include:
- os: macos-13 # macos-13 is x86_64
python-version: '3.9'
Expand All @@ -62,6 +62,8 @@ jobs:
python-version: '3.9'
- os: macos-14
python-version: '3.10'
- os: macos-14
python-version: '3.13' # disabled for 7.3.0
defaults:
run:
shell: bash
Expand Down
20 changes: 15 additions & 5 deletions cx_Freeze/command/bdist_msi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
import os
import re
import shutil
import sys
import warnings
from typing import ClassVar

from packaging.version import Version
from setuptools import Command

from cx_Freeze._compat import IS_MINGW, IS_WINDOWS, PLATFORM
from cx_Freeze.exception import OptionError
from cx_Freeze.exception import OptionError, PlatformError

__all__ = ["bdist_msi"]

if IS_MINGW or IS_WINDOWS:
if (IS_MINGW or IS_WINDOWS) and sys.version_info[:2] < (3, 13):

@contextlib.contextmanager
def suppress_known_deprecation() -> contextlib.AbstractContextManager:
Expand Down Expand Up @@ -47,9 +48,9 @@ def suppress_known_deprecation() -> contextlib.AbstractContextManager:

from cx_Freeze.command._pydialog import PyDialog

# force the remove existing products action to happen first since Windows
# installer appears to be braindead and doesn't handle files shared between
# different "products" very well
# force the remove existing products action to happen first since
# Windows installer appears to be braindead and doesn't handle files
# shared between different "products" very well
install_execute_sequence = sequence.InstallExecuteSequence
for index, info in enumerate(install_execute_sequence):
if info[0] == "RemoveExistingProducts":
Expand Down Expand Up @@ -979,6 +980,15 @@ def initialize_options(self) -> None:
self.license_file = None

def finalize_options(self) -> None:
major = sys.version_info.major
minor = sys.version_info.minor
if (major, minor) >= (3, 13):
msg = (
f"bdist_msi is not supported on Python {major}.{minor} yet.\n"
" Please check a pinned issue at "
"https://github.com/marcelotduarte/cx_Freeze/issues"
)
raise PlatformError(msg)
self.set_undefined_options("bdist", ("skip_build", "skip_build"))

if self.bdist_dir is None:
Expand Down
10 changes: 9 additions & 1 deletion cx_Freeze/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
CALL_FUNCTION = opcode.opmap.get("CALL_FUNCTION")
CALL = opcode.opmap.get("CALL")
PRECALL = opcode.opmap.get("PRECALL")
PUSH_NULL = opcode.opmap.get("PUSH_NULL")

EXTENDED_ARG = opcode.opmap["EXTENDED_ARG"]
LOAD_CONST = opcode.opmap["LOAD_CONST"]
Expand Down Expand Up @@ -629,14 +630,21 @@ def _scan_code(
if opc == LOAD_NAME:
name = code.co_names[arg]
continue
if PUSH_NULL and opc == PUSH_NULL:
continue
if name and name == "__import__" and len(arguments) == 1:
# Try to identify a __import__ call
# Python 3.13 bytecode:
# 1 2 LOAD_NAME 0 (__import__)
# 4 PUSH_NULL
# 6 LOAD_CONST 0 ('pkgutil')
# 8 CALL 1
# Python 3.12 bytecode:
# 20 2 PUSH_NULL
# 4 LOAD_NAME 0 (__import__)
# 6 LOAD_CONST 0 ('pkgutil')
# 8 CALL 1
# Python 3.6 to 3.10 uses CALL_FUNCTION instead fo CALL
# Python 3.6 to 3.10 uses CALL_FUNCTION instead of CALL
# Python 3.11 uses PRECALL then CALL
if CALL_FUNCTION and (opc, arg) == (CALL_FUNCTION, 1):
import_call = 1
Expand Down
9 changes: 7 additions & 2 deletions doc/src/bdist_msi.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
bdist_msi
=========

This command is a standard command in Python 2.5 and higher which has been
modified by cx_Freeze to handle installing executables and their dependencies.
This command is implemented by cx_Freeze to handle installing executables and
their dependencies creating Windows installer packages.

.. warning::

This command is not supported in Python 3.13.

The following options were added to the standard set of options for the
command:

Expand Down
4 changes: 4 additions & 0 deletions doc/src/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ works on.
The current version of **cx_Freeze** is |version| and supports
Python 3.9 to 3.13.

.. warning::

cx_Freeze does not support Python 3.13 in macOS yet.

**cx_Freeze** is distributed under an open-source :ref:`PSF license <license>`.

Contents:
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Software Distribution",
Expand Down Expand Up @@ -167,8 +168,9 @@ build = "cp3*"
build-frontend = "build[uv]"
build-verbosity = 1
skip = [
"cp3{8,9}-{many,musl}linux_{aarch64,ppc64le}",
"cp3{8,9,10}-macosx_{universal2,arm64}",
"cp3{9,10,13}-musllinux_*",
"cp3{9,10,13}-manylinux_ppc64le",
"cp3{9,10,13}-macosx_{universal2,arm64}",
]

[tool.cibuildwheel.linux]
Expand Down
6 changes: 6 additions & 0 deletions tests/test_command_bdist_msi.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
if sys.platform != "win32":
pytest.skip(reason="Windows tests", allow_module_level=True)

if sys.version_info[:2] >= (3, 13):
pytest.skip(
reason="bdist_msi is not supported on Python 3.13 yet.",
allow_module_level=True,
)

DIST_ATTRS = {
"name": "foo",
"version": "0.0",
Expand Down
Loading