annotate oct-py-init.cc @ 412:db29823a8919

Drop initialization of NumPy C API, no longer used * oct-py-init.cc: Remove call to NumPy _import_array and related #includes. * arrayobjectdefs.h: Delete. * Makefile.am (PYTAVE_HEADER_FILES): Remove arrayobjectdefs.h from the list.
author Mike Miller <mtmiller@octave.org>
date Wed, 03 May 2017 16:37:51 -0700
parents 95c6ad0be828
children 7864849e84c2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
405
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
1 /*
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
2
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
3 Copyright (C) 2017 Mike Miller
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
4
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
5 This file is part of Pytave.
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
6
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
7 Pytave is free software; you can redistribute it and/or modify it
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
10 option) any later version.
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
11
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
12 Pytave is distributed in the hope that it will be useful, but WITHOUT
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
15 for more details.
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
16
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
18 along with Pytave; see the file COPYING. If not, see
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
20
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
21 */
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
22
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
23 #if defined (HAVE_CONFIG_H)
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
24 # include <config.h>
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
25 #endif
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
26
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
27 #include <Python.h>
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
28
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
29 #include "oct-py-init.h"
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
30
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
31 namespace pytave
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
32 {
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
33
407
78448e4de20a Ensure that sys.argv has a value (fixes issue #83)
Mike Miller <mtmiller@octave.org>
parents: 405
diff changeset
34 #if PY_VERSION_HEX >= 0x03000000
78448e4de20a Ensure that sys.argv has a value (fixes issue #83)
Mike Miller <mtmiller@octave.org>
parents: 405
diff changeset
35 wchar_t *sys_argv[] { L"", nullptr };
78448e4de20a Ensure that sys.argv has a value (fixes issue #83)
Mike Miller <mtmiller@octave.org>
parents: 405
diff changeset
36 #else
78448e4de20a Ensure that sys.argv has a value (fixes issue #83)
Mike Miller <mtmiller@octave.org>
parents: 405
diff changeset
37 char *sys_argv[] { "", nullptr };
78448e4de20a Ensure that sys.argv has a value (fixes issue #83)
Mike Miller <mtmiller@octave.org>
parents: 405
diff changeset
38 #endif
78448e4de20a Ensure that sys.argv has a value (fixes issue #83)
Mike Miller <mtmiller@octave.org>
parents: 405
diff changeset
39
405
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
40 void
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
41 py_init ()
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
42 {
407
78448e4de20a Ensure that sys.argv has a value (fixes issue #83)
Mike Miller <mtmiller@octave.org>
parents: 405
diff changeset
43 bool is_initialized = Py_IsInitialized ();
78448e4de20a Ensure that sys.argv has a value (fixes issue #83)
Mike Miller <mtmiller@octave.org>
parents: 405
diff changeset
44
405
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
45 Py_Initialize ();
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
46
407
78448e4de20a Ensure that sys.argv has a value (fixes issue #83)
Mike Miller <mtmiller@octave.org>
parents: 405
diff changeset
47 if (! is_initialized)
78448e4de20a Ensure that sys.argv has a value (fixes issue #83)
Mike Miller <mtmiller@octave.org>
parents: 405
diff changeset
48 PySys_SetArgvEx (1, sys_argv, 0);
405
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
49 }
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
50
478d83448b0b Refactor Python initialization into a common function
Mike Miller <mtmiller@octave.org>
parents:
diff changeset
51 }