Skip to content

Commit

Permalink
Merge branch 'hotfix/0.6.15.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhayen committed Jun 4, 2021
2 parents 3c3c347 + 24ab86e commit 68aa2e6
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 7 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
@@ -1,3 +1,9 @@
nuitka (0.6.15.2+ds-1) experimental; urgency=medium

* New upstream hotfix release.

-- Kay Hayen <kay.hayen@gmail.com> Thu, 03 Jun 2021 11:41:07 +0200

nuitka (0.6.15.1+ds-1) experimental; urgency=medium

* New upstream hotfix release.
Expand Down
11 changes: 8 additions & 3 deletions nuitka/Tracing.py
Expand Up @@ -199,6 +199,10 @@ def warning(self, message, style="red"):
self.my_print(message, style=style, file=sys.stderr)

def sysexit(self, message, exit_code=1):
from nuitka.Progress import closeProgressBar

closeProgressBar()

self.my_print("FATAL: %s" % message, style="red", file=sys.stderr)

sys.exit(exit_code)
Expand Down Expand Up @@ -230,10 +234,11 @@ def __init__(self, name, quiet=False, base_style=None, file_handle=None):
def my_print(self, message, **kwargs):
message = message + "\n"

file_handle = self.file_handle or sys.stdout
if "file" not in kwargs:
kwargs["file"] = self.file_handle or sys.stdout

file_handle.write(message)
file_handle.flush()
my_print(message, **kwargs)
kwargs["file"].flush()

def setFileHandle(self, file_handle):
self.file_handle = file_handle
Expand Down
2 changes: 1 addition & 1 deletion nuitka/Version.py
Expand Up @@ -20,7 +20,7 @@
"""

version_string = """\
Nuitka V0.6.15.1
Nuitka V0.6.15.2
Copyright (C) 2021 Kay Hayen."""


Expand Down
22 changes: 22 additions & 0 deletions nuitka/build/static_src/HelpersDeepcopy.c
Expand Up @@ -25,6 +25,14 @@
#include "nuitka/prelude.h"
#endif

#if PYTHON_VERSION >= 0x390
typedef struct {
PyObject_HEAD PyObject *origin;
PyObject *args;
PyObject *parameters;
} GenericAliasObject;
#endif

PyObject *DEEP_COPY(PyObject *value) {
if (PyDict_Check(value)) {
#if PYTHON_VERSION < 0x330
Expand Down Expand Up @@ -152,6 +160,20 @@ PyObject *DEEP_COPY(PyObject *value) {
} else if (PyByteArray_Check(value)) {
// TODO: Could make an exception for zero size.
return PyByteArray_FromObject(value);
#if PYTHON_VERSION >= 0x390
} else if (Py_TYPE(value) == &Py_GenericAliasType) {
GenericAliasObject *generic_alias = (GenericAliasObject *)value;

PyObject *args = DEEP_COPY(generic_alias->args);
PyObject *origin = DEEP_COPY(generic_alias->origin);

if (generic_alias->args == args && generic_alias->origin == origin) {
Py_INCREF(value);
return value;
} else {
return Py_GenericAlias(origin, args);
}
#endif
} else {
PyErr_Format(PyExc_TypeError, "DEEP_COPY does not implement: %s", value->ob_type->tp_name);

Expand Down
3 changes: 2 additions & 1 deletion nuitka/freezer/Standalone.py
Expand Up @@ -56,6 +56,7 @@
from nuitka.utils.Execution import getNullInput, withEnvironmentPathAdded
from nuitka.utils.FileOperations import (
areSamePaths,
copyFileWithPermissions,
copyTree,
getDirectoryRealPath,
getFileContentByLine,
Expand Down Expand Up @@ -1372,7 +1373,7 @@ def _handleDataFile(dist_dir, tracer, included_datafile):
) as output:
output.write(content)
else:
shutil.copy2(source_desc, target_filename)
copyFileWithPermissions(source_desc, target_filename)


def copyDataFiles(dist_dir):
Expand Down
3 changes: 3 additions & 0 deletions nuitka/optimizations/Optimization.py
Expand Up @@ -26,6 +26,7 @@
import inspect

from nuitka import ModuleRegistry, Options, Variables
from nuitka.Errors import NuitkaForbiddenImportEncounter
from nuitka.importing import ImportCache
from nuitka.plugins.Plugins import Plugins
from nuitka.Progress import (
Expand Down Expand Up @@ -115,6 +116,8 @@ def optimizeCompiledPythonModule(module):
# print("Compute module")
with withChangeIndicationsTo(signalChange):
scopes_were_incomplete = module.computeModule()
except NuitkaForbiddenImportEncounter as e:
optimization_logger.sysexit("Error, forbidden import '%s' encountered." % e)
except BaseException:
general.info("Interrupted while working on '%s'." % module)
raise
Expand Down
17 changes: 16 additions & 1 deletion nuitka/plugins/standard/AntiBloat.py
Expand Up @@ -42,8 +42,20 @@ def __init__(self, setuptools_mode, custom_choices):
self.handled_modules["setuptools"] = setuptools_mode

for custom_choice in custom_choices:
if ":" not in custom_choice:
self.sysexit(
"Error, malformed value '%s' for '--noinclude-custom-mode' used."
% custom_choice
)

module_name, mode = custom_choice.rsplit(":", 1)

if mode not in ("error", "warning", "nofollow", "allow"):
self.sysexit(
"Error, illegal mode given '%s' in '--noinclude-custom-mode=%s'"
% (mode, custom_choice)
)

self.handled_modules[ModuleName(module_name)] = mode

@classmethod
Expand All @@ -67,15 +79,18 @@ def addPluginCommandLineOptions(cls, group):
help="""\
What to do if a specific import is encountered. Format is module name,
which can and should be a top level package and then one choice, "error",
"warning", "nofollow".""",
"warning", "nofollow", e.g. PyQt5:error.""",
)

def onModuleEncounter(self, module_filename, module_name, module_kind):
for handled_module_name, mode in self.handled_modules.items():
if module_name.hasNamespace(handled_module_name):
# Make sure the compilation abrts.
if mode == "error":
raise NuitkaForbiddenImportEncounter(module_name)

# Either issue a warning, or pretend the module doesn't exist for standalone or
# at least will not be included.
if mode == "warning":
self.warning("Forbidden import of '%s' encountered." % module_name)
elif mode == "nofollow":
Expand Down
3 changes: 2 additions & 1 deletion nuitka/plugins/standard/PkgResourcesPlugin.py
Expand Up @@ -35,7 +35,7 @@ class NuitkaPluginResources(NuitkaPluginBase):
def __init__(self):
try:
import pkg_resources
except ImportError:
except (ImportError, RuntimeError):
self.pkg_resources = None
else:
self.pkg_resources = pkg_resources
Expand All @@ -49,6 +49,7 @@ def __init__(self):

try:
from importlib import metadata

self.metadata = metadata
except ImportError:
pass
Expand Down
19 changes: 19 additions & 0 deletions nuitka/utils/FileOperations.py
Expand Up @@ -24,6 +24,7 @@

from __future__ import print_function

import errno
import glob
import os
import shutil
Expand Down Expand Up @@ -517,6 +518,24 @@ def copyTree(source_path, dest_path):
return copy_tree(source_path, dest_path)


def copyFileWithPermissions(source_path, dest_path):
"""Improved version of shutil.copy2.
File systems might not allow to transfer extended attributes, which we then ignore
and only copy permissions.
"""

try:
shutil.copy2(source_path, dest_path)
except PermissionError as e:
if e.errno != errno.EACCES:
raise

source_mode = os.stat(source_path).st_mode
shutil.copy(source_path, dest_path)
os.chmod(dest_path, source_mode)


def getWindowsDrive(path):
"""Windows drive for a given path."""

Expand Down

0 comments on commit 68aa2e6

Please sign in to comment.