diff --git a/.gitignore b/.gitignore index 4705c97..e8c81dd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /ghevar_3.0.2-beta.2.tar.gz /moose-0e12e41.tar.gz /moose-3.1.3.tar.gz +/moose-core-3.1.4.tar.gz diff --git a/0001-Avoid-open-coded-strdup-that-cause-compilation-failu.patch b/0001-Avoid-open-coded-strdup-that-cause-compilation-failu.patch new file mode 100644 index 0000000..0315707 --- /dev/null +++ b/0001-Avoid-open-coded-strdup-that-cause-compilation-failu.patch @@ -0,0 +1,38 @@ +From d30711511cc8ee21c49700c6593a8a18e3164126 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 14 Aug 2018 14:58:00 +0200 +Subject: [PATCH] Avoid open-coded strdup that cause compilation failure with + new gcc + +/builddir/build/BUILD/moose-3.1.3/moose-core/pymoose/moosemodule.cpp:2724:32: error: invalid conversion from 'const char*' to 'char*' [-fpermissive] + strncpy(vec[currIndex].name, +--- + moose-core/pymoose/moosemodule.cpp | 13 ++++--------- + 1 file changed, 4 insertions(+), 9 deletions(-) + +diff --git a/moose-core/pymoose/moosemodule.cpp b/moose-core/pymoose/moosemodule.cpp +index 62a9ea2eb8..7d002abe8e 100644 +--- a/pymoose/moosemodule.cpp ++++ b/pymoose/moosemodule.cpp +@@ -2720,17 +2720,12 @@ int defineDestFinfos(const Cinfo * cinfo) + PyGetSetDef destFieldGetSet; + vec.push_back(destFieldGetSet); + +- vec[currIndex].name = (char*)calloc(name.size() + 1, sizeof(char)); +- strncpy(vec[currIndex].name, +- const_cast(name.c_str()), +- name.size()); +- ++ vec[currIndex].name = strdup(name.c_str()); + vec[currIndex].doc = (char*) "Destination field"; + vec[currIndex].get = (getter)moose_ObjId_get_destField_attr; +- PyObject * args = PyTuple_New(1); +- if (args == NULL) +- { +- cerr << "moosemodule.cpp: defineDestFinfos: Failed to allocate tuple" << endl; ++ PyObject *args = PyTuple_New(1); ++ if (!args || !vec[currIndex].name) { ++ cerr << "moosemodule.cpp: defineDestFinfos: allocation failed\n"; + return 0; + } + PyTuple_SetItem(args, 0, PyString_FromString(name.c_str())); diff --git a/0002-Avoid-open-coded-strdup-that-causes-a-warning.patch b/0002-Avoid-open-coded-strdup-that-causes-a-warning.patch new file mode 100644 index 0000000..007292b --- /dev/null +++ b/0002-Avoid-open-coded-strdup-that-causes-a-warning.patch @@ -0,0 +1,40 @@ +From 7bff444a2b06a4a2ef5eb05f9206d0672f73053a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 14 Aug 2018 15:57:54 +0200 +Subject: [PATCH] Avoid open-coded strdup that causes a warning + +/home/zbyszek/python/moose/moose-core/pymoose/mfield.cpp: In function 'int moose_Field_init(_Field*, PyObject*, PyObject*)': +/home/zbyszek/python/moose/moose-core/pymoose/mfield.cpp:122:12: warning: 'char* strncpy(char*, const char*, size_t)' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation] + strncpy(name, fieldName, size); + ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ +/home/zbyszek/python/moose/moose-core/pymoose/mfield.cpp:120:25: note: length computed here + size_t size = strlen(fieldName); + ~~~~~~^~~~~~~~~~~ + +Add error handling while at it. +--- + moose-core/pymoose/mfield.cpp | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/moose-core/pymoose/mfield.cpp b/moose-core/pymoose/mfield.cpp +index dd452890f2..e16837c741 100644 +--- a/pymoose/mfield.cpp ++++ b/pymoose/mfield.cpp +@@ -116,11 +116,12 @@ int moose_Field_init(_Field * self, PyObject * args, PyObject * kwargs) + } + self->owner = ((_ObjId*)owner); + Py_INCREF(self->owner); +- ObjId tmp = ((_ObjId*)owner)->oid_; +- size_t size = strlen(fieldName); +- char * name = (char*)calloc(size+1, sizeof(char)); +- strncpy(name, fieldName, size); +- self->name = name; ++ self->name = strdup(fieldName); ++ if (!self->name) { ++ PyErr_NoMemory(); ++ return -1; ++ } ++ + // In earlier version I tried to deallocate the existing + // self->name if it is not NULL. But it turns out that it + // causes a SIGABRT. In any case it should not be an issue as diff --git a/0003-Use-sys.executable-to-execute-test.-It-breaks-on-pyt.patch b/0003-Use-sys.executable-to-execute-test.-It-breaks-on-pyt.patch new file mode 100644 index 0000000..36fd1d6 --- /dev/null +++ b/0003-Use-sys.executable-to-execute-test.-It-breaks-on-pyt.patch @@ -0,0 +1,32 @@ +From 46b7e96a9bd8070b12738dd6a710974c5593e334 Mon Sep 17 00:00:00 2001 +From: Dilawar Singh +Date: Tue, 27 Mar 2018 10:45:48 +0530 +Subject: [PATCH] Use sys.executable to execute test. It breaks on python3. + +--- + python/moose/moose_test.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/python/moose/moose_test.py b/python/moose/moose_test.py +index e5f908bcfd..d295f53b8d 100644 +--- a/python/moose/moose_test.py ++++ b/python/moose/moose_test.py +@@ -86,6 +86,9 @@ class Command(object): + self.process.terminate() + thread.join() + ++ if self.process.stderr is not None: ++ _logger.warn( '%s' % self.process.stderr.read() ) ++ + return self.process.returncode + + def init_test_dir( ): +@@ -115,7 +118,7 @@ def run_test( index, testfile, timeout, **kwargs): + """ + global test_status_ + global total_ +- pyExec = os.environ.get( 'PYTHON_EXECUTABLE', '/usr/bin/python' ) ++ pyExec = os.environ.get( 'PYTHON_EXECUTABLE', sys.executable ) + cmd = Command( [ pyExec, testfile ] ) + + ti = time.time( ) diff --git a/0004-Do-not-try-to-access-position-1-in-string.patch b/0004-Do-not-try-to-access-position-1-in-string.patch new file mode 100644 index 0000000..e8d9049 --- /dev/null +++ b/0004-Do-not-try-to-access-position-1-in-string.patch @@ -0,0 +1,38 @@ +From dc8dd21a4786a7e1e25c8a58fd2a6a3e330b6a6d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Tue, 14 Aug 2018 17:59:09 +0200 +Subject: [PATCH] Do not try to access position -1 in string + +This ain't python ;( +--- + utility/strutil.cpp | 10 +++------- + 1 file changed, 3 insertions(+), 7 deletions(-) + +diff --git a/utility/strutil.cpp b/utility/strutil.cpp +index 643e3baf99..da2819d13f 100644 +--- a/utility/strutil.cpp ++++ b/utility/strutil.cpp +@@ -72,20 +72,16 @@ std::string fix(const std::string userPath, const string& delimiters) + string trimmedPath = trim(userPath, delimiters); + + string fixedPath; ++ char prev = 0; + + // In this loop, we check if there are more than one '/' together. If yes, + // then accept only first one and reject other. + for(unsigned int i = 0; i < trimmedPath.size(); ++i) + { + const char c = trimmedPath[i]; +- if('/' == c) +- { +- if('/' != fixedPath[fixedPath.size()-1]) +- fixedPath.push_back(c); +- } +- else ++ if(c != '/' || c != prev) + fixedPath.push_back(c); +- ++ prev = c; + } + return fixedPath; + } diff --git a/moose.spec b/moose.spec index e28015e..8205a57 100644 --- a/moose.spec +++ b/moose.spec @@ -1,25 +1,30 @@ -%global with_python3 1 - #global commit 0e12e41b52deb8ea746bc760cddd6e100ca5cfd8 #global shortcommit %%(c=%{commit}; echo ${c:0:7}) Name: moose -Version: 3.1.3 +Version: 3.1.4 %global codename chamcham Release: 1 Summary: Multiscale Neuroscience and Systems Biology Simulator License: GPLv3 URL: http://moose.ncbs.res.in/ %if %{defined commit} -Source0: https://github.com/BhallaLab/moose/archive/%{commit}.tar.gz#/%{name}-%{shortcommit}.tar.gz +Source0: https://github.com/BhallaLab/moose-core/archive/%{commit}.tar.gz#/moose-core-%{shortcommit}.tar.gz %else -Source0: https://github.com/BhallaLab/moose/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz +Source0: https://github.com/BhallaLab/moose-core/archive/v%{version}.tar.gz#/moose-core-%{version}.tar.gz %endif +# https://github.com/BhallaLab/moose-core/pull/282 +Patch0001: 0001-Avoid-open-coded-strdup-that-cause-compilation-failu.patch +Patch0002: 0002-Avoid-open-coded-strdup-that-causes-a-warning.patch +Patch0003: 0003-Use-sys.executable-to-execute-test.-It-breaks-on-pyt.patch +Patch0004: 0004-Do-not-try-to-access-position-1-in-string.patch + BuildRequires: gcc-c++ BuildRequires: make BuildRequires: cmake BuildRequires: rsync +BuildRequires: tar BuildRequires: readline-devel BuildRequires: ncurses-devel BuildRequires: zlib-devel @@ -35,10 +40,8 @@ BuildRequires: checksec BuildRequires: procps-ng BuildRequires: openssl -%if 0%{?with_python3} BuildRequires: python3-devel BuildRequires: python3-numpy -%endif %description MOOSE is the base and numerical core for large, detailed simulations @@ -66,12 +69,9 @@ Requires: python2-lxml %description -n python2-%{name} This package contains the %{summary}. -%if 0%{?with_python3} %package -n python3-%{name} Summary: %{summary} %{?python_provide:%python_provide python3-moose} -# Those two modules are part of moose... -Provides: python3-rdesigneur = %{version}-%{release} Requires: python3-numpy Requires: python3-matplotlib @@ -80,65 +80,72 @@ Requires: python3-lxml %description -n python3-%{name} This package contains the %{summary}. -%endif %prep -%autosetup -p1 +%autosetup -p1 -n moose-core-%{version} + +%global py_setup setup.cmake.py %build cmake_opts=( - -DWITH_CURSES:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_SKIP_RPATH:BOOL=ON - -DCMAKE_C_FLAGS="%optflags -fpermissive" - -DCMAKE_CXX_FLAGS="%optflags -fpermissive" + -DCMAKE_C_FLAGS="%optflags" + -DCMAKE_CXX_FLAGS="%optflags" -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS -Wl,--build-id" -DCMAKE_MODULE_LINKER_FLAGS="$LDFLAGS -Wl,--build-id" -DVERSION_MOOSE=%{version} + -DCMAKE_BUILD_TYPE="Release|RelWithDebugInfo" -DCMAKE_INSTALL_DO_STRIP=0 ) mkdir -p build2 pushd build2 -CXXFLAGS="%optflags -fpermissive" \ +CXXFLAGS="%optflags" \ %cmake .. "${cmake_opts[@]}" \ -DPYTHON_EXECUTABLE=%{__python2} %make_build VERBOSE=1 -cd __moose-core_build/python +cd python %py2_build popd -%if 0%{?with_python3} mkdir -p build3 pushd build3 +CXXFLAGS="%optflags" \ %cmake .. "${cmake_opts[@]}" \ -DPYTHON_EXECUTABLE=%{__python3} %make_build VERBOSE=1 -cd __moose-core_build/python +cd python %py3_build popd -%endif %install -install -D build3/__moose-core_build/moose.bin %{buildroot}%{_bindir}/moose +install -D build3/moose.bin %{buildroot}%{_bindir}/moose -pushd build2/__moose-core_build/python +pushd build2/python %py2_install \--install-lib=%{python2_sitearch} # this is necessary for the dependency generator to work chmod +x %{buildroot}%{python2_sitearch}/moose/_moose.so popd -%if 0%{?with_python3} -pushd build3/__moose-core_build/python +pushd build3/python %py3_install \--install-lib=%{python3_sitearch} # this is necessary for the dependency generator to work chmod +x %{buildroot}%{python3_sitearch}/moose/_moose*.so popd -%endif %check checksec --file %{buildroot}%{_bindir}/moose +pushd build2 +ctest --output-on-failure -V +popd + +pushd build3 +# test_streamer fails randomly when quitting moose every once in a while. +ctest --output-on-failure -V -E test_streamer +popd + PYTHONPATH=%{buildroot}%{python2_sitearch} %{__python2} -c \ 'import moose; element = moose.Neutral("/yyy"); print(element.path)' @@ -149,26 +156,29 @@ PYTHONPATH=%{buildroot}%{python3_sitearch} %{__python3} -c \ %files %{_bindir}/moose -%license moose-core/LICENSE +%license LICENSE %doc README.md %files -n python2-%{name} -%{python2_sitearch}/rdesigneur %{python2_sitearch}/moose -%{python2_sitearch}/moose-*egg-info -%license moose-core/LICENSE +%{python2_sitearch}/rdesigneur +%{python2_sitearch}/pymoose-*egg-info +%license LICENSE %doc README.md -%if 0%{?with_python3} %files -n python3-%{name} -%{python3_sitearch}/rdesigneur %{python3_sitearch}/moose -%{python3_sitearch}/moose-*egg-info -%license moose-core/LICENSE +%{python3_sitearch}/rdesigneur +%{python3_sitearch}/pymoose-*egg-info +%license LICENSE %doc README.md -%endif %changelog +* Tue Aug 14 2018 Zbigniew Jędrzejewski-Szmek - 3.1.4-1 +- Switch source back to use "moose-core" instead of "moose" +- Update to latest version +- Actually run the tests and look at the output + * Tue Aug 7 2018 Zbigniew Jędrzejewski-Szmek - 3.1.3-1 - Update to latest version, fix packaging (#1604882) - Libmubml seems to be gone diff --git a/sources b/sources index 86449c9..b3f32b6 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (moose-3.1.3.tar.gz) = 05d580490f64e3d84e540a0d6dda488e99b080ccbbd8b6ead996c53edc92df1bb2306e06b35fecefee8160dfd7ba370d89ab576488a43d582aa9269af6cbbdd7 +SHA512 (moose-core-3.1.4.tar.gz) = 7b98d8bbc89e3ddf26753cf307b5b5ed32946055452c7cec02d7fef3294bb0d70e94f2e31b9631acb44e31cae9873cbdce190339328993966c3453674caa86d0