summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/config/Make.rules47
-rw-r--r--py/config/install_dir35
-rw-r--r--py/modules/IcePy/Init.cpp12
-rw-r--r--py/modules/IcePy/Slice.cpp58
-rw-r--r--py/modules/IcePy/Slice.h1
-rw-r--r--py/python/Ice.py8
6 files changed, 132 insertions, 29 deletions
diff --git a/py/config/Make.rules b/py/config/Make.rules
index b142a7ddc48..6b7e709bc2c 100644
--- a/py/config/Make.rules
+++ b/py/config/Make.rules
@@ -46,19 +46,20 @@ embedded_runpath ?= yes
#
# If multiple versions of Python are installed and you want a specific
-# version used for building the Ice extension, then set PYTHON_VERSION
-# to a value like "python2.5". Otherwise, the settings below use the
-# default Python interpreter found in your PATH.
+# version used for building the Ice extension, then set PYTHON to
+# the specific to the location of the python interpreter.
#
-PYTHON_VERSION ?= python$(shell python -c "import sys; import distutils.sysconfig as ds; sys.stdout.write(ds.get_python_version())")
+PYTHON ?= python
-PYTHON_BASE_VERSION ?= $(shell $(PYTHON_VERSION) -c "import sys; import distutils.sysconfig as ds; sys.stdout.write(ds.get_python_version())")
+PYTHON_VERSION ?= python$(shell $(PYTHON) -c "import sys; import distutils.sysconfig as ds; sys.stdout.write(ds.get_python_version())")
-PYTHON_INCLUDE_DIR ?= $(shell $(PYTHON_VERSION) -c "import sys; import distutils.sysconfig as ds; sys.stdout.write(ds.get_python_inc())")
+PYTHON_BASE_VERSION ?= $(shell $(PYTHON) -c "import sys; import distutils.sysconfig as ds; sys.stdout.write(ds.get_python_version())")
-PYTHON_LIB_DIR ?= $(shell $(PYTHON_VERSION) -c "import sys; import distutils.sysconfig as ds; sys.stdout.write(ds.get_config_var('LIBPL'))")
+PYTHON_INCLUDE_DIR ?= $(shell $(PYTHON) -c "import sys; import distutils.sysconfig as ds; sys.stdout.write(ds.get_python_inc())")
-PYTHON_LIB_SUFFIX ?= $(shell $(PYTHON_VERSION) -c "import sys; sys.stdout.write(sys.__dict__['abiflags'] if 'abiflags' in sys.__dict__ else '')")
+PYTHON_LIB_DIR ?= $(shell $(PYTHON) -c "import sys; import distutils.sysconfig as ds; sys.stdout.write(ds.get_config_var('LIBPL'))")
+
+PYTHON_LIB_SUFFIX ?= $(shell $(PYTHON) -c "import sys; sys.stdout.write(sys.__dict__['abiflags'] if 'abiflags' in sys.__dict__ else '')")
PYTHON_LIB_NAME ?= $(PYTHON_VERSION)$(PYTHON_LIB_SUFFIX)
@@ -91,7 +92,7 @@ else
include $(top_srcdir)/../config/Make.common.rules
endif
-ifneq ($(prefix),/usr)
+ifndef usr_dir_install
RPATH_DIR = $(prefix)/$(libsubdir)
endif
@@ -105,29 +106,17 @@ else
endif
libdir = $(top_srcdir)/python
-ifneq ($(prefix), /usr)
+
+ifndef usr_dir_install
install_pythondir = $(prefix)/python
install_libdir = $(prefix)/python
else
- ifeq ($(shell test -d $(prefix)/$(libsubdir)/$(PYTHON_VERSION)/dist-packages && echo 0),0)
- install_pythondir = $(prefix)/$(libsubdir)/$(PYTHON_VERSION)/dist-packages
- install_libdir = $(prefix)/$(libsubdir)/$(PYTHON_VERSION)/dist-packages
- endif
-
- ifeq ($(shell test -d $(prefix)/$(libsubdir)/$(PYTHON_VERSION)/site-packages && echo 0),0)
- install_pythondir = $(prefix)/$(libsubdir)/$(PYTHON_VERSION)/site-packages
- install_libdir = $(prefix)/$(libsubdir)/$(PYTHON_VERSION)/site-packages
- endif
-
- ifeq ($(shell test -d $(prefix)/lib/$(PYTHON_VERSION)/dist-packages && echo 0),0)
- install_pythondir = $(prefix)/lib/$(PYTHON_VERSION)/dist-packages
- install_libdir = $(prefix)/lib/$(PYTHON_VERSION)/dist-packages
- endif
-
- ifeq ($(shell test -d $(prefix)/lib/$(PYTHON_VERSION)/site-packages && echo 0),0)
- install_pythondir = $(prefix)/lib/$(PYTHON_VERSION)/site-packages
- install_libdir = $(prefix)/lib/$(PYTHON_VERSION)/site-packages
- endif
+ #
+ # The install_dir script says where python wants site-packages installed.
+ #
+
+ install_pythondir = $(shell $(PYTHON) $(top_srcdir)/config/install_dir)
+ install_libdir = $(install_pythondir)
endif
ifeq ($(UNAME),SunOS)
diff --git a/py/config/install_dir b/py/config/install_dir
new file mode 100644
index 00000000000..8bb2e0c62f5
--- /dev/null
+++ b/py/config/install_dir
@@ -0,0 +1,35 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+from setuptools.command.easy_install import easy_install
+class easy_install_default(easy_install):
+ """ class easy_install had problems with the fist parameter not being
+ an instance of Distribution, even though it was. This is due to
+ some import-related mess.
+ """
+
+ def __init__(self):
+ from distutils.dist import Distribution
+ dist = Distribution()
+ self.distribution = dist
+ self.initialize_options()
+ self._dry_run = None
+ self.verbose = dist.verbose
+ self.force = None
+ self.help = 0
+ self.finalized = 0
+
+e = easy_install_default()
+import distutils.errors
+try:
+ e.finalize_options()
+except distutils.errors.DistutilsError:
+ pass
+
+print e.install_dir
diff --git a/py/modules/IcePy/Init.cpp b/py/modules/IcePy/Init.cpp
index 96425f593e8..5d1541af69a 100644
--- a/py/modules/IcePy/Init.cpp
+++ b/py/modules/IcePy/Init.cpp
@@ -25,6 +25,7 @@
#include <Proxy.h>
#include <Slice.h>
#include <Types.h>
+#include <Ice/Initialize.h>
using namespace std;
using namespace IcePy;
@@ -87,6 +88,8 @@ static PyMethodDef methods[] =
PyDoc_STR(STRCAST("loadSlice(cmd) -> None")) },
{ STRCAST("cleanup"), reinterpret_cast<PyCFunction>(IcePy_cleanup), METH_NOARGS,
PyDoc_STR(STRCAST("internal function")) },
+ { STRCAST("compile"), reinterpret_cast<PyCFunction>(IcePy_compile), METH_VARARGS,
+ PyDoc_STR(STRCAST("internal function")) },
{ 0, 0 } /* sentinel */
};
@@ -115,6 +118,12 @@ PyDoc_STRVAR(moduleDoc, "The Internet Communications Engine.");
#endif
+extern "C"
+{
+Ice::Plugin* createIceSSL(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&);
+Ice::Plugin* createIceDiscovery(const Ice::CommunicatorPtr&, const string&, const Ice::StringSeq&);
+}
+
PyMODINIT_FUNC
#ifndef _WIN32 // On Windows, PyMODINIT_FUNC already defines dllexport
ICE_DECLSPEC_EXPORT
@@ -127,6 +136,9 @@ initIcePy(void)
{
PyObject* module;
+ Ice::registerPluginFactory("IceSSL", createIceSSL, false);
+ Ice::registerPluginFactory("IceDiscovery", createIceDiscovery, false);
+
//
// Notify Python that we are a multi-threaded extension.
//
diff --git a/py/modules/IcePy/Slice.cpp b/py/modules/IcePy/Slice.cpp
index 3d8862182fd..9adccc5e4c3 100644
--- a/py/modules/IcePy/Slice.cpp
+++ b/py/modules/IcePy/Slice.cpp
@@ -14,6 +14,7 @@
#include <Util.h>
#include <Slice/Preprocessor.h>
#include <Slice/PythonUtil.h>
+#include <Slice/Util.h>
#include <IceUtil/Options.h>
//
@@ -199,3 +200,60 @@ IcePy_loadSlice(PyObject* /*self*/, PyObject* args)
Py_INCREF(Py_None);
return Py_None;
}
+
+extern "C"
+PyObject*
+IcePy_compile(PyObject* /*self*/, PyObject* args)
+{
+ PyObject* list = 0;
+ if(!PyArg_ParseTuple(args, STRCAST("O!"), &PyList_Type, &list))
+ {
+ return 0;
+ }
+
+ vector<string> argSeq;
+ if(list)
+ {
+ if(!listToStringSeq(list, argSeq))
+ {
+ return 0;
+ }
+ }
+
+ char** argv = new char*[argSeq.size()];
+ for(size_t i = 0; i < argSeq.size(); ++i)
+ {
+ argv[i] = const_cast<char*>(argSeq[i].c_str());
+ }
+
+ int rc;
+ try
+ {
+ rc = Slice::Python::compile(static_cast<int>(argSeq.size()), argv);
+ }
+ catch(const std::exception& ex)
+ {
+ getErrorStream() << argv[0] << ": error:" << ex.what() << endl;
+ rc = EXIT_FAILURE;
+ }
+ catch(const std::string& msg)
+ {
+ getErrorStream() << argv[0] << ": error:" << msg << endl;
+ rc = EXIT_FAILURE;
+ }
+ catch(const char* msg)
+ {
+ getErrorStream() << argv[0] << ": error:" << msg << endl;
+ rc = EXIT_FAILURE;
+ }
+ catch(...)
+ {
+ getErrorStream() << argv[0] << ": error:" << "unknown exception" << endl;
+ rc = EXIT_FAILURE;
+ }
+
+ delete[] argv;
+
+ // PyInt_FromLong doesn't exist in python 3.
+ return PyLong_FromLong(rc);
+}
diff --git a/py/modules/IcePy/Slice.h b/py/modules/IcePy/Slice.h
index 5c4a2c18533..4d142906d66 100644
--- a/py/modules/IcePy/Slice.h
+++ b/py/modules/IcePy/Slice.h
@@ -13,5 +13,6 @@
#include <Config.h>
extern "C" PyObject* IcePy_loadSlice(PyObject*, PyObject*);
+extern "C" PyObject* IcePy_compile(PyObject*, PyObject*);
#endif
diff --git a/py/python/Ice.py b/py/python/Ice.py
index 7133fd5956f..ef8c253d829 100644
--- a/py/python/Ice.py
+++ b/py/python/Ice.py
@@ -294,6 +294,14 @@ def getSliceDir():
'''Convenience function for locating the directory containing the Slice files.'''
#
+ # Detect setup.py installation in site-packages. The slice
+ # files live along side Ice.py
+ #
+ dir = os.path.join(os.path.dirname(__file__), "slice")
+ if os.path.isdir(dir):
+ return dir
+
+ #
# Get the parent of the directory containing this file (Ice.py).
#
pyHome = os.path.join(os.path.dirname(__file__), "..")