Skip to content

Commit

Permalink
chore: add support for pyproject.toml (tool.cxfreeze) (#2244)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelotduarte committed Feb 7, 2024
1 parent dd7518f commit 2b7f36e
Show file tree
Hide file tree
Showing 12 changed files with 310 additions and 457 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ all: install

.PHONY: pre-commit
pre-commit: install
@SKIP=pylint pre-commit run $(PRE_COMMIT_OPTIONS) || true
@(SKIP=pylint pre-commit run $(PRE_COMMIT_OPTIONS) || true) | more
@pre-commit gc

.PHONY: pre-commit-all
pre-commit-all: install
@pre-commit run $(PRE_COMMIT_OPTIONS) || true
@(pre-commit run $(PRE_COMMIT_OPTIONS) || true) | more
@pre-commit gc

.PHONY: pylint
pylint:
@if ! which pylint; then pip install --upgrade pylint; fi
@pre-commit run pylint $(PRE_COMMIT_OPTIONS)
@(pre-commit run pylint $(PRE_COMMIT_OPTIONS) || true) | more

.PHONY: clean
clean:
Expand Down
4 changes: 2 additions & 2 deletions cx_Freeze/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
__version__ = "6.16.0-dev12"


def setup(**attrs): # noqa: D103
def setup(**attrs) -> setuptools.Distribution: # noqa: D103
cmdclass = attrs.setdefault("cmdclass", {})
if sys.platform == "win32":
cmdclass.setdefault("bdist_msi", bdist_msi)
Expand All @@ -67,7 +67,7 @@ def setup(**attrs): # noqa: D103
cmdclass.setdefault("install", install)
cmdclass.setdefault("install_exe", install_exe)
attrs.setdefault("executables", [])
setuptools.setup(**attrs)
return setuptools.setup(**attrs)


setup.__doc__ = setuptools.setup.__doc__
Expand Down
29 changes: 29 additions & 0 deletions cx_Freeze/_pyproject.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Internal module."""

from __future__ import annotations

from pathlib import Path

try:
from tomllib import loads as toml_loads
except ImportError:
try:
from setuptools.extern.tomli import loads as toml_loads
except ImportError:
from tomli import loads as toml_loads


def get_pyproject_tool_data() -> dict:
pyproject_toml = Path("pyproject.toml")
if not pyproject_toml.exists():
return {}
data = toml_loads(pyproject_toml.read_bytes().decode())
tool_data = data.get("tool", {}).get("cxfreeze", {})
executables = tool_data.pop("executables", [])
options = {}
for cmd, data in tool_data.items():
for option, value in data.items():
options.setdefault(cmd, {})
options[cmd].setdefault(option, ("tool.cxfreeze", value))
options["executables"] = executables
return options

0 comments on commit 2b7f36e

Please sign in to comment.