diff --git a/Cython/Build/Dependencies.py b/Cython/Build/Dependencies.py index 5800e0e649cb02bb0ac76ffb2ebd7a4dc97c64b0..45144937292cd8c900e90533db0e6a480dcc3b70 100644 --- a/Cython/Build/Dependencies.py +++ b/Cython/Build/Dependencies.py @@ -216,12 +216,13 @@ class DistutilsInfo(object): self.values[key] = value elif type is transitive_list: if key in self.values: - all = self.values[key] + # Change a *copy* of the list (Trac #845) + all = self.values[key][:] for v in value: if v not in all: all.append(v) - else: - self.values[key] = value + value = all + self.values[key] = value return self def subs(self, aliases): @@ -250,9 +251,8 @@ class DistutilsInfo(object): for key, value in self.values.items(): type = distutils_settings[key] if type in [list, transitive_list]: - getattr(extension, key).extend(value) - else: - setattr(extension, key, value) + value = getattr(extension, key) + list(value) + setattr(extension, key, value) @cython.locals(start=long, q=long, single_q=long, double_q=long, hash_mark=long, end=long, k=long, counter=long, quote_len=long) diff --git a/tests/compile/distutils_libraries_T845.srctree b/tests/compile/distutils_libraries_T845.srctree new file mode 100644 index 0000000000000000000000000000000000000000..69c85492c705608bfb478ccf1c81889c5e334c5e --- /dev/null +++ b/tests/compile/distutils_libraries_T845.srctree @@ -0,0 +1,33 @@ +PYTHON setup.py build_ext --inplace + +######## setup.py ######## + +from Cython.Build import cythonize +from Cython.Distutils.extension import Extension + +ext_modules = [ + Extension("a", ["a.pyx"]), + Extension("x", ["x.pyx"]), + Extension("y", ["y.pyx"]), +] + +ext_modules = cythonize(ext_modules) + +assert ext_modules[1].libraries == ["lib_x"] +assert ext_modules[2].libraries == ["lib_y"] + +######## libx.pxd ######## +# distutils: libraries = lib_x + +######## liby.pxd ######## +# distutils: libraries = lib_y + +######## a.pyx ######## +cimport libx +cimport liby + +######## x.pyx ######## +cimport libx + +######## y.pyx ######## +cimport liby