[ { "hash": "b089b4cf276662441ec7a91c2ba34534cdec2723", "msg": "added a long int constructor for py::object. This was needed in the\nfreetype library.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-11-07T08:11:44+00:00", "author_timezone": 0, "committer_date": "2002-11-07T08:11:44+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "f0e0be1bb878be9661564c85dc437146f0e6df05" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 1, "insertions": 21, "lines": 22, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "weave/scxx/object.h", "new_path": "weave/scxx/object.h", "filename": "object.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -85,6 +85,9 @@ public:\n object(int val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n+ object(unsigned int val) { \n+ _obj = _own = PyLong_FromUnsignedLong(val); \n+ }; \n object(long val) { \n _obj = _own = PyInt_FromLong((int)val); \n }; \n@@ -562,6 +565,8 @@ public:\n \n //-------------------------------------------------------------------------\n // string representations\n+ //\n+ // !! Should these return std::string instead?\n //-------------------------------------------------------------------------\n object repr() const { \n object result = PyObject_Repr(_obj);\n@@ -775,7 +780,15 @@ public:\n // iter methods\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n- \n+ \n+ //-------------------------------------------------------------------------\n+ // iostream operators\n+ //-------------------------------------------------------------------------\n+ friend std::ostream& operator <<(std::ostream& os, py::object& obj);\n+ //-------------------------------------------------------------------------\n+ // refcount utilities \n+ //-------------------------------------------------------------------------\n+ \n PyObject* disown() {\n _own = 0;\n return _obj;\n@@ -786,6 +799,12 @@ public:\n }\n };\n \n+std::ostream& operator <<(std::ostream& os, py::object& obj)\n+{\n+ os << (std::string)obj.repr();\n+ return os;\n+}\n+\n //---------------------------------------------------------------------------\n // keyed_ref\n //\n@@ -835,4 +854,5 @@ public:\n };\n } // namespace\n \n+\n #endif // !defined(OBJECT_H_INCLUDED_)\n", "added_lines": 21, "deleted_lines": 1, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n#include \n\n// for debugging\n#include \n\nnamespace py {\n\nvoid fail(PyObject*, const char* msg);\n\n//---------------------------------------------------------------------------\n// py::object -- A simple C++ interface to Python objects.\n//\n// This is the basic type from which all others are derived from. It is \n// also quite useful on its own. The class is very light weight as far as\n// data contents, carrying around only two python pointers.\n//---------------------------------------------------------------------------\n \nclass object \n{\nprotected:\n\n //-------------------------------------------------------------------------\n // _obj is the underlying pointer to the real python object.\n //-------------------------------------------------------------------------\n PyObject* _obj;\n\n //-------------------------------------------------------------------------\n // grab_ref (rename to grab_ref)\n //\n // incref new owner, decref old owner, and adjust to new owner\n //-------------------------------------------------------------------------\n void grab_ref(PyObject* newObj) {\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n };\n\n //-------------------------------------------------------------------------\n // lose_ref (rename to lose_ref)\n //\n // decrease reference count without destroying the object.\n //-------------------------------------------------------------------------\n static PyObject* lose_ref(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n //-------------------------------------------------------------------------\n // _own is set to _obj if we \"own\" a reference to _obj, else zero\n //-------------------------------------------------------------------------\n PyObject* _own; \n\npublic:\n //-------------------------------------------------------------------------\n // forward declaration of reference obj returned when [] used as an lvalue.\n //-------------------------------------------------------------------------\n class keyed_ref; \n\n object()\n : _obj (0), _own (0) { };\n object(const object& other)\n : _obj (0), _own (0) { grab_ref(other); };\n object(PyObject* obj)\n : _obj (0), _own (0) { grab_ref(obj); };\n\n //-------------------------------------------------------------------------\n // Numeric constructors\n //-------------------------------------------------------------------------\n object(bool val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(int val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(unsigned int val) { \n _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n object(long val) { \n _obj = _own = PyInt_FromLong((int)val); \n }; \n object(unsigned long val) { \n _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n object(double val) {\n _obj = _own = PyFloat_FromDouble(val); \n };\n object(const std::complex& val) { \n _obj = _own = PyComplex_FromDoubles(val.real(),val.imag()); \n };\n \n //-------------------------------------------------------------------------\n // string constructors\n //-------------------------------------------------------------------------\n object(const char* val) {\n _obj = _own = PyString_FromString((char*) val); \n };\n object(const std::string& val) : _obj (0), _own (0) { \n _obj = _own = PyString_FromString((char*)val.c_str()); \n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~object() { \n Py_XDECREF(_own); \n };\n \n //-------------------------------------------------------------------------\n // casting operators\n //-------------------------------------------------------------------------\n operator PyObject* () const {\n return _obj;\n };\n \n operator int () const {\n if (!PyInt_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to integer\");\n return PyInt_AsLong(_obj);\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to float\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n operator std::complex () const {\n if (!PyComplex_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to complex\");\n return std::complex(PyComplex_RealAsDouble(_obj),\n PyComplex_ImagAsDouble(_obj));\n }; \n operator std::string () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n operator char* () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to char*\");\n return PyString_AsString(_obj);\n }; \n \n //-------------------------------------------------------------------------\n // equal operator\n //-------------------------------------------------------------------------\n object& operator=(const object& other) {\n grab_ref(other);\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // printing\n //\n // This needs to become more sophisticated and handle objects that \n // implement the file protocol.\n //-------------------------------------------------------------------------\n void print(FILE* f, int flags=0) const {\n int res = PyObject_Print(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n void print(object f, int flags=0) const {\n int res = PyFile_WriteObject(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // hasattr -- test if object has specified attribute\n //------------------------------------------------------------------------- \n int hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n int hasattr(const std::string& nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm.c_str()) == 1;\n };\n int hasattr(object& nm) const {\n return PyObject_HasAttr(_obj, nm) == 1;\n };\n \n\n //-------------------------------------------------------------------------\n // attr -- retreive attribute/method from object\n //-------------------------------------------------------------------------\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n };\n\n object attr(const std::string& nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n }; \n \n //-------------------------------------------------------------------------\n // setting attributes\n //\n // There is a combinatorial explosion here of function combinations.\n // perhaps there is a casting fix someone can suggest.\n //-------------------------------------------------------------------------\n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// int //////////////\n void set_attr(const char* nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// unsigned long //////////////\n void set_attr(const char* nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// double //////////////\n void set_attr(const char* nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// complex //////////////\n void set_attr(const char* nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// char* //////////////\n void set_attr(const char* nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// std::string //////////////\n void set_attr(const char* nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // del attributes/methods from object\n //-------------------------------------------------------------------------\n void del(const char* nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm);\n if (result == -1)\n throw 1;\n };\n void del(const std::string& nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm.c_str());\n if (result == -1)\n throw 1;\n };\n void del(const object& nm) {\n int result = PyObject_DelAttr(_obj, nm);\n if (result ==-1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // comparison\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n }; \n int cmp(int other) const {\n object _other = object(other);\n return cmp(_other);\n }; \n int cmp(unsigned long other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(double other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(const std::complex& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n int cmp(const char* other) const {\n object _other = object((char*)other);\n return cmp(_other);\n };\n \n int cmp(const std::string& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator == (int other) const {\n return cmp(other) == 0;\n };\n bool operator == (unsigned long other) const {\n return cmp(other) == 0;\n };\n bool operator == (double other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::complex& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::string& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const char* other) const {\n return cmp(other) == 0;\n };\n\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator != (int other) const {\n return cmp(other) != 0;\n };\n bool operator != (unsigned long other) const {\n return cmp(other) != 0;\n };\n bool operator != (double other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::complex& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::string& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const char* other) const {\n return cmp(other) != 0;\n };\n \n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator < (int other) const {\n return cmp(other) < 0;\n };\n bool operator < (unsigned long other) const {\n return cmp(other) < 0;\n };\n bool operator < (double other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::complex& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::string& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const char* other) const {\n return cmp(other) < 0;\n };\n \n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator > (int other) const {\n return cmp(other) > 0;\n };\n bool operator > (unsigned long other) const {\n return cmp(other) > 0;\n };\n bool operator > (double other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::complex& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::string& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const char* other) const {\n return cmp(other) > 0;\n };\n\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (int other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (unsigned long other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (double other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::complex& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::string& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const char* other) const {\n return cmp(other) >= 0;\n };\n \n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (int other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (unsigned long other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (double other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::complex& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::string& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const char* other) const {\n return cmp(other) <= 0;\n };\n\n //-------------------------------------------------------------------------\n // string representations\n //\n // !! Should these return std::string instead?\n //-------------------------------------------------------------------------\n object repr() const { \n object result = PyObject_Repr(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n object str() const {\n object result = PyObject_Str(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n\n // !! Not Tested \n object unicode() const {\n object result = PyObject_Unicode(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n //-------------------------------------------------------------------------\n // calling methods on object\n //\n // Note: I changed args_tup from a tuple& to a object& so that it could\n // be inlined instead of implemented i weave_imp.cpp. This \n // provides less automatic type checking, but is potentially faster.\n //-------------------------------------------------------------------------\n object object::mcall(const char* nm) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup, object& kw_dict) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,kw_dict);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n\n object mcall(const std::string& nm) {\n return mcall(nm.c_str());\n }\n object mcall(const std::string& nm, object& args_tup) {\n return mcall(nm.c_str(),args_tup);\n }\n object mcall(const std::string& nm, object& args_tup, object& kw_dict) {\n return mcall(nm.c_str(),args_tup,kw_dict);\n }\n\n //-------------------------------------------------------------------------\n // calling callable objects\n //\n // Note: see not on mcall()\n //-------------------------------------------------------------------------\n object object::call() const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup, object& kw_dict) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, kw_dict);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n\n //-------------------------------------------------------------------------\n // check if object is callable\n //-------------------------------------------------------------------------\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n\n //-------------------------------------------------------------------------\n // retreive the objects hash value\n //-------------------------------------------------------------------------\n int hash() const {\n int result = PyObject_Hash(_obj);\n if (result == -1 && PyErr_Occurred())\n throw 1;\n return result; \n };\n \n //-------------------------------------------------------------------------\n // test whether object is true\n //-------------------------------------------------------------------------\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n \n /*\n * //-------------------------------------------------------------------------\n // test whether object is not true\n //-------------------------------------------------------------------------\n#if defined(__GNUC__) && __GNUC__ < 3\n bool not() const {\n#else\n bool operator not() const {\n#endif\n return PyObject_Not(_obj) == 1;\n };\n */\n\n //-------------------------------------------------------------------------\n // return the variable type for the object\n //-------------------------------------------------------------------------\n object type() const {\n PyObject* result = PyObject_Type(_obj);\n if (!result)\n throw 1;\n return lose_ref(result);\n };\n\n object is_int() const {\n return PyInt_Check(_obj) == 1;\n };\n\n object is_float() const {\n return PyFloat_Check(_obj) == 1;\n };\n\n object is_complex() const {\n return PyComplex_Check(_obj) == 1;\n };\n \n object is_list() const {\n return PyList_Check(_obj) == 1;\n };\n \n object is_tuple() const {\n return PyDict_Check(_obj) == 1;\n };\n \n object is_dict() const {\n return PyDict_Check(_obj) == 1;\n };\n \n object is_string() const {\n return PyString_Check(_obj) == 1;\n };\n \n //-------------------------------------------------------------------------\n // size, len, and length are all synonyms.\n // \n // length() is useful because it allows the same code to work with STL \n // strings as works with py::objects.\n //-------------------------------------------------------------------------\n int size() const {\n int result = PyObject_Size(_obj);\n if (result == -1)\n throw 1;\n return result;\n };\n int len() const {\n return size();\n };\n int length() const {\n return size();\n };\n\n //-------------------------------------------------------------------------\n // set_item \n //\n // To prevent a combonatorial explosion, only objects are allowed for keys.\n // Users are encouraged to use the [] interface for setting values.\n //------------------------------------------------------------------------- \n virtual void set_item(const object& key, const object& val) {\n int rslt = PyObject_SetItem(_obj, key, val);\n if (rslt==-1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // operator[] \n //-------------------------------------------------------------------------\n // !! defined in weave_imp.cpp\n // !! I'd like to refactor things so that they can be defined here.\n keyed_ref operator [] (object& key);\n keyed_ref operator [] (const char* key);\n keyed_ref operator [] (const std::string& key);\n keyed_ref operator [] (int key);\n keyed_ref operator [] (double key);\n keyed_ref operator [] (const std::complex& key);\n \n //-------------------------------------------------------------------------\n // iter methods\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n \n //-------------------------------------------------------------------------\n // iostream operators\n //-------------------------------------------------------------------------\n friend std::ostream& operator <<(std::ostream& os, py::object& obj);\n //-------------------------------------------------------------------------\n // refcount utilities \n //-------------------------------------------------------------------------\n \n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n \n int refcount() {\n return _obj->ob_refcnt;\n }\n};\n\nstd::ostream& operator <<(std::ostream& os, py::object& obj)\n{\n os << (std::string)obj.repr();\n return os;\n}\n\n//---------------------------------------------------------------------------\n// keyed_ref\n//\n// Provides a reference value when operator[] returns an lvalue. The \n// reference has to keep track of its parent object and its key in the parent\n// object so that it can insert a new value into the parent at the \n// appropriate place when a new value is assigned to the keyed_ref object.\n//\n// The keyed_ref class is also used by the py::dict class derived from \n// py::object\n// !! Note: Need to check ref counting on key and parent here.\n//---------------------------------------------------------------------------\nclass object::keyed_ref : public object\n{\n object& _parent;\n object _key;\npublic:\n keyed_ref(object obj, object& parent, object& key)\n : object(obj), _parent(parent), _key(key) {}; \n virtual ~keyed_ref() {};\n\n keyed_ref& operator=(const object& other) {\n grab_ref(other);\n _parent.set_item(_key, other);\n return *this;\n }\n keyed_ref& operator=(int other) {\n object _other = object(other);\n return operator=(_other);\n } \n keyed_ref& operator=(double other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::complex& other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const char* other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::string& other) {\n object _other = object(other);\n return operator=(_other);\n }\n};\n} // namespace\n\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n#include \n\n// for debugging\n#include \n\nnamespace py {\n\nvoid fail(PyObject*, const char* msg);\n\n//---------------------------------------------------------------------------\n// py::object -- A simple C++ interface to Python objects.\n//\n// This is the basic type from which all others are derived from. It is \n// also quite useful on its own. The class is very light weight as far as\n// data contents, carrying around only two python pointers.\n//---------------------------------------------------------------------------\n \nclass object \n{\nprotected:\n\n //-------------------------------------------------------------------------\n // _obj is the underlying pointer to the real python object.\n //-------------------------------------------------------------------------\n PyObject* _obj;\n\n //-------------------------------------------------------------------------\n // grab_ref (rename to grab_ref)\n //\n // incref new owner, decref old owner, and adjust to new owner\n //-------------------------------------------------------------------------\n void grab_ref(PyObject* newObj) {\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n };\n\n //-------------------------------------------------------------------------\n // lose_ref (rename to lose_ref)\n //\n // decrease reference count without destroying the object.\n //-------------------------------------------------------------------------\n static PyObject* lose_ref(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n //-------------------------------------------------------------------------\n // _own is set to _obj if we \"own\" a reference to _obj, else zero\n //-------------------------------------------------------------------------\n PyObject* _own; \n\npublic:\n //-------------------------------------------------------------------------\n // forward declaration of reference obj returned when [] used as an lvalue.\n //-------------------------------------------------------------------------\n class keyed_ref; \n\n object()\n : _obj (0), _own (0) { };\n object(const object& other)\n : _obj (0), _own (0) { grab_ref(other); };\n object(PyObject* obj)\n : _obj (0), _own (0) { grab_ref(obj); };\n\n //-------------------------------------------------------------------------\n // Numeric constructors\n //-------------------------------------------------------------------------\n object(bool val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(int val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(long val) { \n _obj = _own = PyInt_FromLong((int)val); \n }; \n object(unsigned long val) { \n _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n object(double val) {\n _obj = _own = PyFloat_FromDouble(val); \n };\n object(const std::complex& val) { \n _obj = _own = PyComplex_FromDoubles(val.real(),val.imag()); \n };\n \n //-------------------------------------------------------------------------\n // string constructors\n //-------------------------------------------------------------------------\n object(const char* val) {\n _obj = _own = PyString_FromString((char*) val); \n };\n object(const std::string& val) : _obj (0), _own (0) { \n _obj = _own = PyString_FromString((char*)val.c_str()); \n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~object() { \n Py_XDECREF(_own); \n };\n \n //-------------------------------------------------------------------------\n // casting operators\n //-------------------------------------------------------------------------\n operator PyObject* () const {\n return _obj;\n };\n \n operator int () const {\n if (!PyInt_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to integer\");\n return PyInt_AsLong(_obj);\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to float\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n operator std::complex () const {\n if (!PyComplex_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to complex\");\n return std::complex(PyComplex_RealAsDouble(_obj),\n PyComplex_ImagAsDouble(_obj));\n }; \n operator std::string () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n operator char* () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to char*\");\n return PyString_AsString(_obj);\n }; \n \n //-------------------------------------------------------------------------\n // equal operator\n //-------------------------------------------------------------------------\n object& operator=(const object& other) {\n grab_ref(other);\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // printing\n //\n // This needs to become more sophisticated and handle objects that \n // implement the file protocol.\n //-------------------------------------------------------------------------\n void print(FILE* f, int flags=0) const {\n int res = PyObject_Print(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n void print(object f, int flags=0) const {\n int res = PyFile_WriteObject(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // hasattr -- test if object has specified attribute\n //------------------------------------------------------------------------- \n int hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n int hasattr(const std::string& nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm.c_str()) == 1;\n };\n int hasattr(object& nm) const {\n return PyObject_HasAttr(_obj, nm) == 1;\n };\n \n\n //-------------------------------------------------------------------------\n // attr -- retreive attribute/method from object\n //-------------------------------------------------------------------------\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n };\n\n object attr(const std::string& nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n }; \n \n //-------------------------------------------------------------------------\n // setting attributes\n //\n // There is a combinatorial explosion here of function combinations.\n // perhaps there is a casting fix someone can suggest.\n //-------------------------------------------------------------------------\n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// int //////////////\n void set_attr(const char* nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// unsigned long //////////////\n void set_attr(const char* nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// double //////////////\n void set_attr(const char* nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// complex //////////////\n void set_attr(const char* nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// char* //////////////\n void set_attr(const char* nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// std::string //////////////\n void set_attr(const char* nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // del attributes/methods from object\n //-------------------------------------------------------------------------\n void del(const char* nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm);\n if (result == -1)\n throw 1;\n };\n void del(const std::string& nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm.c_str());\n if (result == -1)\n throw 1;\n };\n void del(const object& nm) {\n int result = PyObject_DelAttr(_obj, nm);\n if (result ==-1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // comparison\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n }; \n int cmp(int other) const {\n object _other = object(other);\n return cmp(_other);\n }; \n int cmp(unsigned long other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(double other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(const std::complex& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n int cmp(const char* other) const {\n object _other = object((char*)other);\n return cmp(_other);\n };\n \n int cmp(const std::string& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator == (int other) const {\n return cmp(other) == 0;\n };\n bool operator == (unsigned long other) const {\n return cmp(other) == 0;\n };\n bool operator == (double other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::complex& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::string& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const char* other) const {\n return cmp(other) == 0;\n };\n\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator != (int other) const {\n return cmp(other) != 0;\n };\n bool operator != (unsigned long other) const {\n return cmp(other) != 0;\n };\n bool operator != (double other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::complex& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::string& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const char* other) const {\n return cmp(other) != 0;\n };\n \n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator < (int other) const {\n return cmp(other) < 0;\n };\n bool operator < (unsigned long other) const {\n return cmp(other) < 0;\n };\n bool operator < (double other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::complex& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::string& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const char* other) const {\n return cmp(other) < 0;\n };\n \n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator > (int other) const {\n return cmp(other) > 0;\n };\n bool operator > (unsigned long other) const {\n return cmp(other) > 0;\n };\n bool operator > (double other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::complex& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::string& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const char* other) const {\n return cmp(other) > 0;\n };\n\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (int other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (unsigned long other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (double other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::complex& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::string& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const char* other) const {\n return cmp(other) >= 0;\n };\n \n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (int other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (unsigned long other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (double other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::complex& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::string& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const char* other) const {\n return cmp(other) <= 0;\n };\n\n //-------------------------------------------------------------------------\n // string representations\n //-------------------------------------------------------------------------\n object repr() const { \n object result = PyObject_Repr(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n object str() const {\n object result = PyObject_Str(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n\n // !! Not Tested \n object unicode() const {\n object result = PyObject_Unicode(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n //-------------------------------------------------------------------------\n // calling methods on object\n //\n // Note: I changed args_tup from a tuple& to a object& so that it could\n // be inlined instead of implemented i weave_imp.cpp. This \n // provides less automatic type checking, but is potentially faster.\n //-------------------------------------------------------------------------\n object object::mcall(const char* nm) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup, object& kw_dict) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,kw_dict);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n\n object mcall(const std::string& nm) {\n return mcall(nm.c_str());\n }\n object mcall(const std::string& nm, object& args_tup) {\n return mcall(nm.c_str(),args_tup);\n }\n object mcall(const std::string& nm, object& args_tup, object& kw_dict) {\n return mcall(nm.c_str(),args_tup,kw_dict);\n }\n\n //-------------------------------------------------------------------------\n // calling callable objects\n //\n // Note: see not on mcall()\n //-------------------------------------------------------------------------\n object object::call() const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup, object& kw_dict) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, kw_dict);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n\n //-------------------------------------------------------------------------\n // check if object is callable\n //-------------------------------------------------------------------------\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n\n //-------------------------------------------------------------------------\n // retreive the objects hash value\n //-------------------------------------------------------------------------\n int hash() const {\n int result = PyObject_Hash(_obj);\n if (result == -1 && PyErr_Occurred())\n throw 1;\n return result; \n };\n \n //-------------------------------------------------------------------------\n // test whether object is true\n //-------------------------------------------------------------------------\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n \n /*\n * //-------------------------------------------------------------------------\n // test whether object is not true\n //-------------------------------------------------------------------------\n#if defined(__GNUC__) && __GNUC__ < 3\n bool not() const {\n#else\n bool operator not() const {\n#endif\n return PyObject_Not(_obj) == 1;\n };\n */\n\n //-------------------------------------------------------------------------\n // return the variable type for the object\n //-------------------------------------------------------------------------\n object type() const {\n PyObject* result = PyObject_Type(_obj);\n if (!result)\n throw 1;\n return lose_ref(result);\n };\n\n object is_int() const {\n return PyInt_Check(_obj) == 1;\n };\n\n object is_float() const {\n return PyFloat_Check(_obj) == 1;\n };\n\n object is_complex() const {\n return PyComplex_Check(_obj) == 1;\n };\n \n object is_list() const {\n return PyList_Check(_obj) == 1;\n };\n \n object is_tuple() const {\n return PyDict_Check(_obj) == 1;\n };\n \n object is_dict() const {\n return PyDict_Check(_obj) == 1;\n };\n \n object is_string() const {\n return PyString_Check(_obj) == 1;\n };\n \n //-------------------------------------------------------------------------\n // size, len, and length are all synonyms.\n // \n // length() is useful because it allows the same code to work with STL \n // strings as works with py::objects.\n //-------------------------------------------------------------------------\n int size() const {\n int result = PyObject_Size(_obj);\n if (result == -1)\n throw 1;\n return result;\n };\n int len() const {\n return size();\n };\n int length() const {\n return size();\n };\n\n //-------------------------------------------------------------------------\n // set_item \n //\n // To prevent a combonatorial explosion, only objects are allowed for keys.\n // Users are encouraged to use the [] interface for setting values.\n //------------------------------------------------------------------------- \n virtual void set_item(const object& key, const object& val) {\n int rslt = PyObject_SetItem(_obj, key, val);\n if (rslt==-1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // operator[] \n //-------------------------------------------------------------------------\n // !! defined in weave_imp.cpp\n // !! I'd like to refactor things so that they can be defined here.\n keyed_ref operator [] (object& key);\n keyed_ref operator [] (const char* key);\n keyed_ref operator [] (const std::string& key);\n keyed_ref operator [] (int key);\n keyed_ref operator [] (double key);\n keyed_ref operator [] (const std::complex& key);\n \n //-------------------------------------------------------------------------\n // iter methods\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n \n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n \n int refcount() {\n return _obj->ob_refcnt;\n }\n};\n\n//---------------------------------------------------------------------------\n// keyed_ref\n//\n// Provides a reference value when operator[] returns an lvalue. The \n// reference has to keep track of its parent object and its key in the parent\n// object so that it can insert a new value into the parent at the \n// appropriate place when a new value is assigned to the keyed_ref object.\n//\n// The keyed_ref class is also used by the py::dict class derived from \n// py::object\n// !! Note: Need to check ref counting on key and parent here.\n//---------------------------------------------------------------------------\nclass object::keyed_ref : public object\n{\n object& _parent;\n object _key;\npublic:\n keyed_ref(object obj, object& parent, object& key)\n : object(obj), _parent(parent), _key(key) {}; \n virtual ~keyed_ref() {};\n\n keyed_ref& operator=(const object& other) {\n grab_ref(other);\n _parent.set_item(_key, other);\n return *this;\n }\n keyed_ref& operator=(int other) {\n object _other = object(other);\n return operator=(_other);\n } \n keyed_ref& operator=(double other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::complex& other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const char* other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::string& other) {\n object _other = object(other);\n return operator=(_other);\n }\n};\n} // namespace\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "methods": [ { "name": "py::object::grab_ref", "long_name": "py::object::grab_ref( PyObject * newObj)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "newObj" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::lose_ref", "long_name": "py::object::lose_ref( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 57, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 74, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( bool val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 85, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 88, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 91, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 94, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( double val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: complex & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std" ], "start_line": 100, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const char * val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "val" ], "start_line": 107, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: string & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 117, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 128, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 133, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 138, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator std :: complex < double >", "long_name": "py::object::operator std :: complex < double >() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [], "start_line": 143, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator char *", "long_name": "py::object::operator char *() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 163, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "f", "flags" ], "start_line": 174, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( object f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "f", "flags" ], "start_line": 180, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 192, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "nm" ], "start_line": 195, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 210, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 214, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 227, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "std", "val" ], "start_line": 233, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 239, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 246, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 253, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 260, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 51, "parameters": [ "nm", "val" ], "start_line": 268, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "std", "val" ], "start_line": 275, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "nm", "val" ], "start_line": 282, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 290, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 297, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 304, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "nm", "std" ], "start_line": 312, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "std", "std" ], "start_line": 319, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 53, "parameters": [ "nm", "std" ], "start_line": 326, "end_line": 331, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 52, "parameters": [ "nm", "val" ], "start_line": 334, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [ "std", "val" ], "start_line": 341, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [ "nm", "val" ], "start_line": 348, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 54, "parameters": [ "nm", "std" ], "start_line": 356, "end_line": 361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 60, "parameters": [ "std", "std" ], "start_line": 363, "end_line": 368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "std" ], "start_line": 370, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "nm" ], "start_line": 380, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const std :: string & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "std" ], "start_line": 385, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "nm" ], "start_line": 390, "end_line": 394, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 400, "end_line": 406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( int other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 407, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( unsigned long other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 411, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( double other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 415, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: complex & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 419, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const char * other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 424, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: string & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 429, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 434, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 437, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 440, "end_line": 442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 443, "end_line": 445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 446, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 449, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 452, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 456, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 459, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 462, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 465, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 468, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 471, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 474, "end_line": 476, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 478, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 481, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 484, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 487, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 490, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 493, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 496, "end_line": 498, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 500, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 503, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 509, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 512, "end_line": 514, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 518, "end_line": 520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 522, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 525, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 528, "end_line": 530, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 531, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 534, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 537, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 540, "end_line": 542, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 547, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 550, "end_line": 552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 553, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 556, "end_line": 558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 559, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 562, "end_line": 564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 571, "end_line": 577, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::str", "long_name": "py::object::str() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 579, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::unicode", "long_name": "py::object::unicode() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 588, "end_line": 594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 49, "parameters": [ "nm" ], "start_line": 603, "end_line": 609, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "nm", "args_tup" ], "start_line": 611, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 57, "parameters": [ "nm", "args_tup", "kw_dict" ], "start_line": 619, "end_line": 625, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 627, "end_line": 629, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "std", "args_tup" ], "start_line": 630, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std", "args_tup", "kw_dict" ], "start_line": 633, "end_line": 635, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [], "start_line": 642, "end_line": 647, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "args_tup" ], "start_line": 648, "end_line": 653, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup , object & kw_dict) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "args_tup", "kw_dict" ], "start_line": 654, "end_line": 659, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 664, "end_line": 666, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [], "start_line": 671, "end_line": 676, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 681, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 701, "end_line": 706, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_int", "long_name": "py::object::is_int() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 708, "end_line": 710, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_float", "long_name": "py::object::is_float() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 712, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_complex", "long_name": "py::object::is_complex() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 716, "end_line": 718, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_list", "long_name": "py::object::is_list() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 720, "end_line": 722, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_tuple", "long_name": "py::object::is_tuple() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 724, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_dict", "long_name": "py::object::is_dict() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 728, "end_line": 730, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_string", "long_name": "py::object::is_string() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 732, "end_line": 734, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::size", "long_name": "py::object::size() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 742, "end_line": 747, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::len", "long_name": "py::object::len() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 748, "end_line": 750, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::length", "long_name": "py::object::length() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 751, "end_line": 753, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_item", "long_name": "py::object::set_item( const object & key , const object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "key", "val" ], "start_line": 761, "end_line": 765, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 792, "end_line": 795, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::refcount", "long_name": "py::object::refcount()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 797, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::operator < <", "long_name": "py::operator < <( std :: ostream & os , py :: object & obj)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "std", "py" ], "start_line": 802, "end_line": 806, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "py::object::keyed_ref::keyed_ref", "long_name": "py::object::keyed_ref::keyed_ref( object obj , object & parent , object & key)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 30, "parameters": [ "obj", "parent", "key" ], "start_line": 825, "end_line": 826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::~keyed_ref", "long_name": "py::object::keyed_ref::~keyed_ref()", "filename": "object.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 827, "end_line": 827, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const object & other)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 829, "end_line": 833, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( int other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 834, "end_line": 837, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( double other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 838, "end_line": 841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: complex & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 842, "end_line": 845, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const char * other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "other" ], "start_line": 846, "end_line": 849, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: string & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "std" ], "start_line": 850, "end_line": 853, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::object::grab_ref", "long_name": "py::object::grab_ref( PyObject * newObj)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "newObj" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::lose_ref", "long_name": "py::object::lose_ref( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 57, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 74, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( bool val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 85, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 88, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 91, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( double val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 94, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: complex & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const char * val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "val" ], "start_line": 104, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: string & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 107, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 114, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 125, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 130, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 135, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator std :: complex < double >", "long_name": "py::object::operator std :: complex < double >() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [], "start_line": 140, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 146, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator char *", "long_name": "py::object::operator char *() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 151, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 160, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "f", "flags" ], "start_line": 171, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( object f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "f", "flags" ], "start_line": 177, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 186, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "nm" ], "start_line": 192, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 200, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 207, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 211, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 224, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "std", "val" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 236, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 243, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 250, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 257, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 51, "parameters": [ "nm", "val" ], "start_line": 265, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "std", "val" ], "start_line": 272, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "nm", "val" ], "start_line": 279, "end_line": 284, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 287, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 294, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 301, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "nm", "std" ], "start_line": 309, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "std", "std" ], "start_line": 316, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 53, "parameters": [ "nm", "std" ], "start_line": 323, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 52, "parameters": [ "nm", "val" ], "start_line": 331, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [ "std", "val" ], "start_line": 338, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [ "nm", "val" ], "start_line": 345, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 54, "parameters": [ "nm", "std" ], "start_line": 353, "end_line": 358, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 60, "parameters": [ "std", "std" ], "start_line": 360, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "std" ], "start_line": 367, "end_line": 372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "nm" ], "start_line": 377, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const std :: string & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "std" ], "start_line": 382, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "nm" ], "start_line": 387, "end_line": 391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 397, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( int other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 404, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( unsigned long other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 408, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( double other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 412, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: complex & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 416, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const char * other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 421, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: string & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 426, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 431, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 434, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 437, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 440, "end_line": 442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 443, "end_line": 445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 446, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 449, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 453, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 456, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 459, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 462, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 465, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 468, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 471, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 475, "end_line": 477, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 478, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 481, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 484, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 487, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 490, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 493, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 497, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 500, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 503, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 509, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 512, "end_line": 514, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 519, "end_line": 521, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 522, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 525, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 528, "end_line": 530, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 531, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 534, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 537, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 541, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 547, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 550, "end_line": 552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 553, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 556, "end_line": 558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 559, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 566, "end_line": 572, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::str", "long_name": "py::object::str() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 574, "end_line": 580, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::unicode", "long_name": "py::object::unicode() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 583, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 49, "parameters": [ "nm" ], "start_line": 598, "end_line": 604, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "nm", "args_tup" ], "start_line": 606, "end_line": 612, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 57, "parameters": [ "nm", "args_tup", "kw_dict" ], "start_line": 614, "end_line": 620, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 622, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "std", "args_tup" ], "start_line": 625, "end_line": 627, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std", "args_tup", "kw_dict" ], "start_line": 628, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [], "start_line": 637, "end_line": 642, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "args_tup" ], "start_line": 643, "end_line": 648, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup , object & kw_dict) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "args_tup", "kw_dict" ], "start_line": 649, "end_line": 654, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 659, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [], "start_line": 666, "end_line": 671, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 676, "end_line": 678, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 696, "end_line": 701, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_int", "long_name": "py::object::is_int() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 703, "end_line": 705, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_float", "long_name": "py::object::is_float() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 707, "end_line": 709, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_complex", "long_name": "py::object::is_complex() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 711, "end_line": 713, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_list", "long_name": "py::object::is_list() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 715, "end_line": 717, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_tuple", "long_name": "py::object::is_tuple() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 719, "end_line": 721, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_dict", "long_name": "py::object::is_dict() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 723, "end_line": 725, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_string", "long_name": "py::object::is_string() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 727, "end_line": 729, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::size", "long_name": "py::object::size() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 737, "end_line": 742, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::len", "long_name": "py::object::len() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 743, "end_line": 745, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::length", "long_name": "py::object::length() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 746, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_item", "long_name": "py::object::set_item( const object & key , const object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "key", "val" ], "start_line": 756, "end_line": 760, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 779, "end_line": 782, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::refcount", "long_name": "py::object::refcount()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 784, "end_line": 786, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::keyed_ref", "long_name": "py::object::keyed_ref::keyed_ref( object obj , object & parent , object & key)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 30, "parameters": [ "obj", "parent", "key" ], "start_line": 806, "end_line": 807, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::~keyed_ref", "long_name": "py::object::keyed_ref::~keyed_ref()", "filename": "object.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 808, "end_line": 808, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const object & other)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 810, "end_line": 814, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( int other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 815, "end_line": 818, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( double other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 819, "end_line": 822, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: complex & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 823, "end_line": 826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const char * other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "other" ], "start_line": 827, "end_line": 830, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: string & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "std" ], "start_line": 831, "end_line": 834, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::operator < <", "long_name": "py::operator < <( std :: ostream & os , py :: object & obj)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "std", "py" ], "start_line": 802, "end_line": 806, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 88, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 } ], "nloc": 605, "complexity": 192, "token_count": 4380, "diff_parsed": { "added": [ " object(unsigned int val) {", " _obj = _own = PyLong_FromUnsignedLong(val);", " };", " //", " // !! Should these return std::string instead?", "", " //-------------------------------------------------------------------------", " // iostream operators", " //-------------------------------------------------------------------------", " friend std::ostream& operator <<(std::ostream& os, py::object& obj);", " //-------------------------------------------------------------------------", " // refcount utilities", " //-------------------------------------------------------------------------", "", "std::ostream& operator <<(std::ostream& os, py::object& obj)", "{", " os << (std::string)obj.repr();", " return os;", "}", "", "" ], "deleted": [ "" ] } } ] }, { "hash": "21478aa10e8667d392a09d58b26d29a40e5f29c5", "msg": "moved operator<< to weave_imp.cpp to prevent multiple definition issue.\n\nrepr() and str() now return std::string instead of py::object values", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-11-07T08:49:57+00:00", "author_timezone": 0, "committer_date": "2002-11-07T08:49:57+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "b089b4cf276662441ec7a91c2ba34534cdec2723" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 12, "insertions": 10, "lines": 22, "files": 2, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "weave/scxx/object.h", "new_path": "weave/scxx/object.h", "filename": "object.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -566,22 +566,19 @@ public:\n //-------------------------------------------------------------------------\n // string representations\n //\n- // !! Should these return std::string instead?\n //-------------------------------------------------------------------------\n- object repr() const { \n+ std::string repr() const { \n object result = PyObject_Repr(_obj);\n if (!(PyObject*)result)\n throw 1;\n- lose_ref(result); \n- return result;\n+ return std::string(PyString_AsString(result));\n };\n \n- object str() const {\n+ std::string str() const {\n object result = PyObject_Str(_obj);\n if (!(PyObject*)result)\n throw 1;\n- lose_ref(result); \n- return result;\n+ return std::string(PyString_AsString(result));\n };\n \n // !! Not Tested \n@@ -799,11 +796,6 @@ public:\n }\n };\n \n-std::ostream& operator <<(std::ostream& os, py::object& obj)\n-{\n- os << (std::string)obj.repr();\n- return os;\n-}\n \n //---------------------------------------------------------------------------\n // keyed_ref\n", "added_lines": 4, "deleted_lines": 12, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n#include \n\n// for debugging\n#include \n\nnamespace py {\n\nvoid fail(PyObject*, const char* msg);\n\n//---------------------------------------------------------------------------\n// py::object -- A simple C++ interface to Python objects.\n//\n// This is the basic type from which all others are derived from. It is \n// also quite useful on its own. The class is very light weight as far as\n// data contents, carrying around only two python pointers.\n//---------------------------------------------------------------------------\n \nclass object \n{\nprotected:\n\n //-------------------------------------------------------------------------\n // _obj is the underlying pointer to the real python object.\n //-------------------------------------------------------------------------\n PyObject* _obj;\n\n //-------------------------------------------------------------------------\n // grab_ref (rename to grab_ref)\n //\n // incref new owner, decref old owner, and adjust to new owner\n //-------------------------------------------------------------------------\n void grab_ref(PyObject* newObj) {\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n };\n\n //-------------------------------------------------------------------------\n // lose_ref (rename to lose_ref)\n //\n // decrease reference count without destroying the object.\n //-------------------------------------------------------------------------\n static PyObject* lose_ref(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n //-------------------------------------------------------------------------\n // _own is set to _obj if we \"own\" a reference to _obj, else zero\n //-------------------------------------------------------------------------\n PyObject* _own; \n\npublic:\n //-------------------------------------------------------------------------\n // forward declaration of reference obj returned when [] used as an lvalue.\n //-------------------------------------------------------------------------\n class keyed_ref; \n\n object()\n : _obj (0), _own (0) { };\n object(const object& other)\n : _obj (0), _own (0) { grab_ref(other); };\n object(PyObject* obj)\n : _obj (0), _own (0) { grab_ref(obj); };\n\n //-------------------------------------------------------------------------\n // Numeric constructors\n //-------------------------------------------------------------------------\n object(bool val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(int val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(unsigned int val) { \n _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n object(long val) { \n _obj = _own = PyInt_FromLong((int)val); \n }; \n object(unsigned long val) { \n _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n object(double val) {\n _obj = _own = PyFloat_FromDouble(val); \n };\n object(const std::complex& val) { \n _obj = _own = PyComplex_FromDoubles(val.real(),val.imag()); \n };\n \n //-------------------------------------------------------------------------\n // string constructors\n //-------------------------------------------------------------------------\n object(const char* val) {\n _obj = _own = PyString_FromString((char*) val); \n };\n object(const std::string& val) : _obj (0), _own (0) { \n _obj = _own = PyString_FromString((char*)val.c_str()); \n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~object() { \n Py_XDECREF(_own); \n };\n \n //-------------------------------------------------------------------------\n // casting operators\n //-------------------------------------------------------------------------\n operator PyObject* () const {\n return _obj;\n };\n \n operator int () const {\n if (!PyInt_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to integer\");\n return PyInt_AsLong(_obj);\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to float\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n operator std::complex () const {\n if (!PyComplex_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to complex\");\n return std::complex(PyComplex_RealAsDouble(_obj),\n PyComplex_ImagAsDouble(_obj));\n }; \n operator std::string () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n operator char* () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to char*\");\n return PyString_AsString(_obj);\n }; \n \n //-------------------------------------------------------------------------\n // equal operator\n //-------------------------------------------------------------------------\n object& operator=(const object& other) {\n grab_ref(other);\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // printing\n //\n // This needs to become more sophisticated and handle objects that \n // implement the file protocol.\n //-------------------------------------------------------------------------\n void print(FILE* f, int flags=0) const {\n int res = PyObject_Print(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n void print(object f, int flags=0) const {\n int res = PyFile_WriteObject(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // hasattr -- test if object has specified attribute\n //------------------------------------------------------------------------- \n int hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n int hasattr(const std::string& nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm.c_str()) == 1;\n };\n int hasattr(object& nm) const {\n return PyObject_HasAttr(_obj, nm) == 1;\n };\n \n\n //-------------------------------------------------------------------------\n // attr -- retreive attribute/method from object\n //-------------------------------------------------------------------------\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n };\n\n object attr(const std::string& nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n }; \n \n //-------------------------------------------------------------------------\n // setting attributes\n //\n // There is a combinatorial explosion here of function combinations.\n // perhaps there is a casting fix someone can suggest.\n //-------------------------------------------------------------------------\n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// int //////////////\n void set_attr(const char* nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// unsigned long //////////////\n void set_attr(const char* nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// double //////////////\n void set_attr(const char* nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// complex //////////////\n void set_attr(const char* nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// char* //////////////\n void set_attr(const char* nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// std::string //////////////\n void set_attr(const char* nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // del attributes/methods from object\n //-------------------------------------------------------------------------\n void del(const char* nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm);\n if (result == -1)\n throw 1;\n };\n void del(const std::string& nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm.c_str());\n if (result == -1)\n throw 1;\n };\n void del(const object& nm) {\n int result = PyObject_DelAttr(_obj, nm);\n if (result ==-1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // comparison\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n }; \n int cmp(int other) const {\n object _other = object(other);\n return cmp(_other);\n }; \n int cmp(unsigned long other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(double other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(const std::complex& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n int cmp(const char* other) const {\n object _other = object((char*)other);\n return cmp(_other);\n };\n \n int cmp(const std::string& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator == (int other) const {\n return cmp(other) == 0;\n };\n bool operator == (unsigned long other) const {\n return cmp(other) == 0;\n };\n bool operator == (double other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::complex& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::string& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const char* other) const {\n return cmp(other) == 0;\n };\n\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator != (int other) const {\n return cmp(other) != 0;\n };\n bool operator != (unsigned long other) const {\n return cmp(other) != 0;\n };\n bool operator != (double other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::complex& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::string& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const char* other) const {\n return cmp(other) != 0;\n };\n \n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator < (int other) const {\n return cmp(other) < 0;\n };\n bool operator < (unsigned long other) const {\n return cmp(other) < 0;\n };\n bool operator < (double other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::complex& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::string& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const char* other) const {\n return cmp(other) < 0;\n };\n \n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator > (int other) const {\n return cmp(other) > 0;\n };\n bool operator > (unsigned long other) const {\n return cmp(other) > 0;\n };\n bool operator > (double other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::complex& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::string& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const char* other) const {\n return cmp(other) > 0;\n };\n\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (int other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (unsigned long other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (double other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::complex& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::string& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const char* other) const {\n return cmp(other) >= 0;\n };\n \n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (int other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (unsigned long other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (double other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::complex& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::string& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const char* other) const {\n return cmp(other) <= 0;\n };\n\n //-------------------------------------------------------------------------\n // string representations\n //\n //-------------------------------------------------------------------------\n std::string repr() const { \n object result = PyObject_Repr(_obj);\n if (!(PyObject*)result)\n throw 1;\n return std::string(PyString_AsString(result));\n };\n \n std::string str() const {\n object result = PyObject_Str(_obj);\n if (!(PyObject*)result)\n throw 1;\n return std::string(PyString_AsString(result));\n };\n\n // !! Not Tested \n object unicode() const {\n object result = PyObject_Unicode(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n //-------------------------------------------------------------------------\n // calling methods on object\n //\n // Note: I changed args_tup from a tuple& to a object& so that it could\n // be inlined instead of implemented i weave_imp.cpp. This \n // provides less automatic type checking, but is potentially faster.\n //-------------------------------------------------------------------------\n object object::mcall(const char* nm) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup, object& kw_dict) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,kw_dict);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n\n object mcall(const std::string& nm) {\n return mcall(nm.c_str());\n }\n object mcall(const std::string& nm, object& args_tup) {\n return mcall(nm.c_str(),args_tup);\n }\n object mcall(const std::string& nm, object& args_tup, object& kw_dict) {\n return mcall(nm.c_str(),args_tup,kw_dict);\n }\n\n //-------------------------------------------------------------------------\n // calling callable objects\n //\n // Note: see not on mcall()\n //-------------------------------------------------------------------------\n object object::call() const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup, object& kw_dict) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, kw_dict);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n\n //-------------------------------------------------------------------------\n // check if object is callable\n //-------------------------------------------------------------------------\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n\n //-------------------------------------------------------------------------\n // retreive the objects hash value\n //-------------------------------------------------------------------------\n int hash() const {\n int result = PyObject_Hash(_obj);\n if (result == -1 && PyErr_Occurred())\n throw 1;\n return result; \n };\n \n //-------------------------------------------------------------------------\n // test whether object is true\n //-------------------------------------------------------------------------\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n \n /*\n * //-------------------------------------------------------------------------\n // test whether object is not true\n //-------------------------------------------------------------------------\n#if defined(__GNUC__) && __GNUC__ < 3\n bool not() const {\n#else\n bool operator not() const {\n#endif\n return PyObject_Not(_obj) == 1;\n };\n */\n\n //-------------------------------------------------------------------------\n // return the variable type for the object\n //-------------------------------------------------------------------------\n object type() const {\n PyObject* result = PyObject_Type(_obj);\n if (!result)\n throw 1;\n return lose_ref(result);\n };\n\n object is_int() const {\n return PyInt_Check(_obj) == 1;\n };\n\n object is_float() const {\n return PyFloat_Check(_obj) == 1;\n };\n\n object is_complex() const {\n return PyComplex_Check(_obj) == 1;\n };\n \n object is_list() const {\n return PyList_Check(_obj) == 1;\n };\n \n object is_tuple() const {\n return PyDict_Check(_obj) == 1;\n };\n \n object is_dict() const {\n return PyDict_Check(_obj) == 1;\n };\n \n object is_string() const {\n return PyString_Check(_obj) == 1;\n };\n \n //-------------------------------------------------------------------------\n // size, len, and length are all synonyms.\n // \n // length() is useful because it allows the same code to work with STL \n // strings as works with py::objects.\n //-------------------------------------------------------------------------\n int size() const {\n int result = PyObject_Size(_obj);\n if (result == -1)\n throw 1;\n return result;\n };\n int len() const {\n return size();\n };\n int length() const {\n return size();\n };\n\n //-------------------------------------------------------------------------\n // set_item \n //\n // To prevent a combonatorial explosion, only objects are allowed for keys.\n // Users are encouraged to use the [] interface for setting values.\n //------------------------------------------------------------------------- \n virtual void set_item(const object& key, const object& val) {\n int rslt = PyObject_SetItem(_obj, key, val);\n if (rslt==-1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // operator[] \n //-------------------------------------------------------------------------\n // !! defined in weave_imp.cpp\n // !! I'd like to refactor things so that they can be defined here.\n keyed_ref operator [] (object& key);\n keyed_ref operator [] (const char* key);\n keyed_ref operator [] (const std::string& key);\n keyed_ref operator [] (int key);\n keyed_ref operator [] (double key);\n keyed_ref operator [] (const std::complex& key);\n \n //-------------------------------------------------------------------------\n // iter methods\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n \n //-------------------------------------------------------------------------\n // iostream operators\n //-------------------------------------------------------------------------\n friend std::ostream& operator <<(std::ostream& os, py::object& obj);\n //-------------------------------------------------------------------------\n // refcount utilities \n //-------------------------------------------------------------------------\n \n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n \n int refcount() {\n return _obj->ob_refcnt;\n }\n};\n\n\n//---------------------------------------------------------------------------\n// keyed_ref\n//\n// Provides a reference value when operator[] returns an lvalue. The \n// reference has to keep track of its parent object and its key in the parent\n// object so that it can insert a new value into the parent at the \n// appropriate place when a new value is assigned to the keyed_ref object.\n//\n// The keyed_ref class is also used by the py::dict class derived from \n// py::object\n// !! Note: Need to check ref counting on key and parent here.\n//---------------------------------------------------------------------------\nclass object::keyed_ref : public object\n{\n object& _parent;\n object _key;\npublic:\n keyed_ref(object obj, object& parent, object& key)\n : object(obj), _parent(parent), _key(key) {}; \n virtual ~keyed_ref() {};\n\n keyed_ref& operator=(const object& other) {\n grab_ref(other);\n _parent.set_item(_key, other);\n return *this;\n }\n keyed_ref& operator=(int other) {\n object _other = object(other);\n return operator=(_other);\n } \n keyed_ref& operator=(double other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::complex& other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const char* other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::string& other) {\n object _other = object(other);\n return operator=(_other);\n }\n};\n} // namespace\n\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n#include \n\n// for debugging\n#include \n\nnamespace py {\n\nvoid fail(PyObject*, const char* msg);\n\n//---------------------------------------------------------------------------\n// py::object -- A simple C++ interface to Python objects.\n//\n// This is the basic type from which all others are derived from. It is \n// also quite useful on its own. The class is very light weight as far as\n// data contents, carrying around only two python pointers.\n//---------------------------------------------------------------------------\n \nclass object \n{\nprotected:\n\n //-------------------------------------------------------------------------\n // _obj is the underlying pointer to the real python object.\n //-------------------------------------------------------------------------\n PyObject* _obj;\n\n //-------------------------------------------------------------------------\n // grab_ref (rename to grab_ref)\n //\n // incref new owner, decref old owner, and adjust to new owner\n //-------------------------------------------------------------------------\n void grab_ref(PyObject* newObj) {\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n };\n\n //-------------------------------------------------------------------------\n // lose_ref (rename to lose_ref)\n //\n // decrease reference count without destroying the object.\n //-------------------------------------------------------------------------\n static PyObject* lose_ref(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n //-------------------------------------------------------------------------\n // _own is set to _obj if we \"own\" a reference to _obj, else zero\n //-------------------------------------------------------------------------\n PyObject* _own; \n\npublic:\n //-------------------------------------------------------------------------\n // forward declaration of reference obj returned when [] used as an lvalue.\n //-------------------------------------------------------------------------\n class keyed_ref; \n\n object()\n : _obj (0), _own (0) { };\n object(const object& other)\n : _obj (0), _own (0) { grab_ref(other); };\n object(PyObject* obj)\n : _obj (0), _own (0) { grab_ref(obj); };\n\n //-------------------------------------------------------------------------\n // Numeric constructors\n //-------------------------------------------------------------------------\n object(bool val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(int val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(unsigned int val) { \n _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n object(long val) { \n _obj = _own = PyInt_FromLong((int)val); \n }; \n object(unsigned long val) { \n _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n object(double val) {\n _obj = _own = PyFloat_FromDouble(val); \n };\n object(const std::complex& val) { \n _obj = _own = PyComplex_FromDoubles(val.real(),val.imag()); \n };\n \n //-------------------------------------------------------------------------\n // string constructors\n //-------------------------------------------------------------------------\n object(const char* val) {\n _obj = _own = PyString_FromString((char*) val); \n };\n object(const std::string& val) : _obj (0), _own (0) { \n _obj = _own = PyString_FromString((char*)val.c_str()); \n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~object() { \n Py_XDECREF(_own); \n };\n \n //-------------------------------------------------------------------------\n // casting operators\n //-------------------------------------------------------------------------\n operator PyObject* () const {\n return _obj;\n };\n \n operator int () const {\n if (!PyInt_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to integer\");\n return PyInt_AsLong(_obj);\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to float\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n operator std::complex () const {\n if (!PyComplex_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to complex\");\n return std::complex(PyComplex_RealAsDouble(_obj),\n PyComplex_ImagAsDouble(_obj));\n }; \n operator std::string () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n operator char* () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to char*\");\n return PyString_AsString(_obj);\n }; \n \n //-------------------------------------------------------------------------\n // equal operator\n //-------------------------------------------------------------------------\n object& operator=(const object& other) {\n grab_ref(other);\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // printing\n //\n // This needs to become more sophisticated and handle objects that \n // implement the file protocol.\n //-------------------------------------------------------------------------\n void print(FILE* f, int flags=0) const {\n int res = PyObject_Print(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n void print(object f, int flags=0) const {\n int res = PyFile_WriteObject(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // hasattr -- test if object has specified attribute\n //------------------------------------------------------------------------- \n int hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n int hasattr(const std::string& nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm.c_str()) == 1;\n };\n int hasattr(object& nm) const {\n return PyObject_HasAttr(_obj, nm) == 1;\n };\n \n\n //-------------------------------------------------------------------------\n // attr -- retreive attribute/method from object\n //-------------------------------------------------------------------------\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n };\n\n object attr(const std::string& nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n }; \n \n //-------------------------------------------------------------------------\n // setting attributes\n //\n // There is a combinatorial explosion here of function combinations.\n // perhaps there is a casting fix someone can suggest.\n //-------------------------------------------------------------------------\n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// int //////////////\n void set_attr(const char* nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// unsigned long //////////////\n void set_attr(const char* nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// double //////////////\n void set_attr(const char* nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// complex //////////////\n void set_attr(const char* nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// char* //////////////\n void set_attr(const char* nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// std::string //////////////\n void set_attr(const char* nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // del attributes/methods from object\n //-------------------------------------------------------------------------\n void del(const char* nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm);\n if (result == -1)\n throw 1;\n };\n void del(const std::string& nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm.c_str());\n if (result == -1)\n throw 1;\n };\n void del(const object& nm) {\n int result = PyObject_DelAttr(_obj, nm);\n if (result ==-1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // comparison\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n }; \n int cmp(int other) const {\n object _other = object(other);\n return cmp(_other);\n }; \n int cmp(unsigned long other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(double other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(const std::complex& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n int cmp(const char* other) const {\n object _other = object((char*)other);\n return cmp(_other);\n };\n \n int cmp(const std::string& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator == (int other) const {\n return cmp(other) == 0;\n };\n bool operator == (unsigned long other) const {\n return cmp(other) == 0;\n };\n bool operator == (double other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::complex& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::string& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const char* other) const {\n return cmp(other) == 0;\n };\n\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator != (int other) const {\n return cmp(other) != 0;\n };\n bool operator != (unsigned long other) const {\n return cmp(other) != 0;\n };\n bool operator != (double other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::complex& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::string& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const char* other) const {\n return cmp(other) != 0;\n };\n \n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator < (int other) const {\n return cmp(other) < 0;\n };\n bool operator < (unsigned long other) const {\n return cmp(other) < 0;\n };\n bool operator < (double other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::complex& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::string& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const char* other) const {\n return cmp(other) < 0;\n };\n \n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator > (int other) const {\n return cmp(other) > 0;\n };\n bool operator > (unsigned long other) const {\n return cmp(other) > 0;\n };\n bool operator > (double other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::complex& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::string& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const char* other) const {\n return cmp(other) > 0;\n };\n\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (int other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (unsigned long other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (double other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::complex& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::string& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const char* other) const {\n return cmp(other) >= 0;\n };\n \n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (int other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (unsigned long other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (double other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::complex& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::string& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const char* other) const {\n return cmp(other) <= 0;\n };\n\n //-------------------------------------------------------------------------\n // string representations\n //\n // !! Should these return std::string instead?\n //-------------------------------------------------------------------------\n object repr() const { \n object result = PyObject_Repr(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n object str() const {\n object result = PyObject_Str(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n\n // !! Not Tested \n object unicode() const {\n object result = PyObject_Unicode(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n //-------------------------------------------------------------------------\n // calling methods on object\n //\n // Note: I changed args_tup from a tuple& to a object& so that it could\n // be inlined instead of implemented i weave_imp.cpp. This \n // provides less automatic type checking, but is potentially faster.\n //-------------------------------------------------------------------------\n object object::mcall(const char* nm) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup, object& kw_dict) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,kw_dict);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n\n object mcall(const std::string& nm) {\n return mcall(nm.c_str());\n }\n object mcall(const std::string& nm, object& args_tup) {\n return mcall(nm.c_str(),args_tup);\n }\n object mcall(const std::string& nm, object& args_tup, object& kw_dict) {\n return mcall(nm.c_str(),args_tup,kw_dict);\n }\n\n //-------------------------------------------------------------------------\n // calling callable objects\n //\n // Note: see not on mcall()\n //-------------------------------------------------------------------------\n object object::call() const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup, object& kw_dict) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, kw_dict);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n\n //-------------------------------------------------------------------------\n // check if object is callable\n //-------------------------------------------------------------------------\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n\n //-------------------------------------------------------------------------\n // retreive the objects hash value\n //-------------------------------------------------------------------------\n int hash() const {\n int result = PyObject_Hash(_obj);\n if (result == -1 && PyErr_Occurred())\n throw 1;\n return result; \n };\n \n //-------------------------------------------------------------------------\n // test whether object is true\n //-------------------------------------------------------------------------\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n \n /*\n * //-------------------------------------------------------------------------\n // test whether object is not true\n //-------------------------------------------------------------------------\n#if defined(__GNUC__) && __GNUC__ < 3\n bool not() const {\n#else\n bool operator not() const {\n#endif\n return PyObject_Not(_obj) == 1;\n };\n */\n\n //-------------------------------------------------------------------------\n // return the variable type for the object\n //-------------------------------------------------------------------------\n object type() const {\n PyObject* result = PyObject_Type(_obj);\n if (!result)\n throw 1;\n return lose_ref(result);\n };\n\n object is_int() const {\n return PyInt_Check(_obj) == 1;\n };\n\n object is_float() const {\n return PyFloat_Check(_obj) == 1;\n };\n\n object is_complex() const {\n return PyComplex_Check(_obj) == 1;\n };\n \n object is_list() const {\n return PyList_Check(_obj) == 1;\n };\n \n object is_tuple() const {\n return PyDict_Check(_obj) == 1;\n };\n \n object is_dict() const {\n return PyDict_Check(_obj) == 1;\n };\n \n object is_string() const {\n return PyString_Check(_obj) == 1;\n };\n \n //-------------------------------------------------------------------------\n // size, len, and length are all synonyms.\n // \n // length() is useful because it allows the same code to work with STL \n // strings as works with py::objects.\n //-------------------------------------------------------------------------\n int size() const {\n int result = PyObject_Size(_obj);\n if (result == -1)\n throw 1;\n return result;\n };\n int len() const {\n return size();\n };\n int length() const {\n return size();\n };\n\n //-------------------------------------------------------------------------\n // set_item \n //\n // To prevent a combonatorial explosion, only objects are allowed for keys.\n // Users are encouraged to use the [] interface for setting values.\n //------------------------------------------------------------------------- \n virtual void set_item(const object& key, const object& val) {\n int rslt = PyObject_SetItem(_obj, key, val);\n if (rslt==-1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // operator[] \n //-------------------------------------------------------------------------\n // !! defined in weave_imp.cpp\n // !! I'd like to refactor things so that they can be defined here.\n keyed_ref operator [] (object& key);\n keyed_ref operator [] (const char* key);\n keyed_ref operator [] (const std::string& key);\n keyed_ref operator [] (int key);\n keyed_ref operator [] (double key);\n keyed_ref operator [] (const std::complex& key);\n \n //-------------------------------------------------------------------------\n // iter methods\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n \n //-------------------------------------------------------------------------\n // iostream operators\n //-------------------------------------------------------------------------\n friend std::ostream& operator <<(std::ostream& os, py::object& obj);\n //-------------------------------------------------------------------------\n // refcount utilities \n //-------------------------------------------------------------------------\n \n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n \n int refcount() {\n return _obj->ob_refcnt;\n }\n};\n\nstd::ostream& operator <<(std::ostream& os, py::object& obj)\n{\n os << (std::string)obj.repr();\n return os;\n}\n\n//---------------------------------------------------------------------------\n// keyed_ref\n//\n// Provides a reference value when operator[] returns an lvalue. The \n// reference has to keep track of its parent object and its key in the parent\n// object so that it can insert a new value into the parent at the \n// appropriate place when a new value is assigned to the keyed_ref object.\n//\n// The keyed_ref class is also used by the py::dict class derived from \n// py::object\n// !! Note: Need to check ref counting on key and parent here.\n//---------------------------------------------------------------------------\nclass object::keyed_ref : public object\n{\n object& _parent;\n object _key;\npublic:\n keyed_ref(object obj, object& parent, object& key)\n : object(obj), _parent(parent), _key(key) {}; \n virtual ~keyed_ref() {};\n\n keyed_ref& operator=(const object& other) {\n grab_ref(other);\n _parent.set_item(_key, other);\n return *this;\n }\n keyed_ref& operator=(int other) {\n object _other = object(other);\n return operator=(_other);\n } \n keyed_ref& operator=(double other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::complex& other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const char* other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::string& other) {\n object _other = object(other);\n return operator=(_other);\n }\n};\n} // namespace\n\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "methods": [ { "name": "py::object::grab_ref", "long_name": "py::object::grab_ref( PyObject * newObj)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "newObj" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::lose_ref", "long_name": "py::object::lose_ref( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 57, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 74, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( bool val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 85, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 88, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 91, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 94, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( double val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: complex & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std" ], "start_line": 100, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const char * val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "val" ], "start_line": 107, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: string & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 117, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 128, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 133, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 138, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator std :: complex < double >", "long_name": "py::object::operator std :: complex < double >() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [], "start_line": 143, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator char *", "long_name": "py::object::operator char *() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 163, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "f", "flags" ], "start_line": 174, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( object f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "f", "flags" ], "start_line": 180, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 192, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "nm" ], "start_line": 195, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 210, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 214, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 227, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "std", "val" ], "start_line": 233, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 239, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 246, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 253, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 260, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 51, "parameters": [ "nm", "val" ], "start_line": 268, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "std", "val" ], "start_line": 275, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "nm", "val" ], "start_line": 282, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 290, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 297, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 304, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "nm", "std" ], "start_line": 312, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "std", "std" ], "start_line": 319, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 53, "parameters": [ "nm", "std" ], "start_line": 326, "end_line": 331, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 52, "parameters": [ "nm", "val" ], "start_line": 334, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [ "std", "val" ], "start_line": 341, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [ "nm", "val" ], "start_line": 348, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 54, "parameters": [ "nm", "std" ], "start_line": 356, "end_line": 361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 60, "parameters": [ "std", "std" ], "start_line": 363, "end_line": 368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "std" ], "start_line": 370, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "nm" ], "start_line": 380, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const std :: string & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "std" ], "start_line": 385, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "nm" ], "start_line": 390, "end_line": 394, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 400, "end_line": 406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( int other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 407, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( unsigned long other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 411, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( double other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 415, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: complex & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 419, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const char * other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 424, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: string & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 429, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 434, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 437, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 440, "end_line": 442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 443, "end_line": 445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 446, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 449, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 452, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 456, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 459, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 462, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 465, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 468, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 471, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 474, "end_line": 476, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 478, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 481, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 484, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 487, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 490, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 493, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 496, "end_line": 498, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 500, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 503, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 509, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 512, "end_line": 514, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 518, "end_line": 520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 522, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 525, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 528, "end_line": 530, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 531, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 534, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 537, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 540, "end_line": 542, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 547, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 550, "end_line": 552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 553, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 556, "end_line": 558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 559, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 562, "end_line": 564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [], "start_line": 570, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::str", "long_name": "py::object::str() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [], "start_line": 577, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::unicode", "long_name": "py::object::unicode() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 585, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 49, "parameters": [ "nm" ], "start_line": 600, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "nm", "args_tup" ], "start_line": 608, "end_line": 614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 57, "parameters": [ "nm", "args_tup", "kw_dict" ], "start_line": 616, "end_line": 622, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 624, "end_line": 626, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "std", "args_tup" ], "start_line": 627, "end_line": 629, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std", "args_tup", "kw_dict" ], "start_line": 630, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [], "start_line": 639, "end_line": 644, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "args_tup" ], "start_line": 645, "end_line": 650, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup , object & kw_dict) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "args_tup", "kw_dict" ], "start_line": 651, "end_line": 656, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 661, "end_line": 663, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [], "start_line": 668, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 678, "end_line": 680, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 698, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_int", "long_name": "py::object::is_int() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 705, "end_line": 707, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_float", "long_name": "py::object::is_float() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 709, "end_line": 711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_complex", "long_name": "py::object::is_complex() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 713, "end_line": 715, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_list", "long_name": "py::object::is_list() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 717, "end_line": 719, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_tuple", "long_name": "py::object::is_tuple() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 721, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_dict", "long_name": "py::object::is_dict() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 725, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_string", "long_name": "py::object::is_string() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 729, "end_line": 731, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::size", "long_name": "py::object::size() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 739, "end_line": 744, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::len", "long_name": "py::object::len() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 745, "end_line": 747, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::length", "long_name": "py::object::length() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 748, "end_line": 750, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_item", "long_name": "py::object::set_item( const object & key , const object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "key", "val" ], "start_line": 758, "end_line": 762, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 789, "end_line": 792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::refcount", "long_name": "py::object::refcount()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 794, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::keyed_ref", "long_name": "py::object::keyed_ref::keyed_ref( object obj , object & parent , object & key)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 30, "parameters": [ "obj", "parent", "key" ], "start_line": 817, "end_line": 818, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::~keyed_ref", "long_name": "py::object::keyed_ref::~keyed_ref()", "filename": "object.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 819, "end_line": 819, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const object & other)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 821, "end_line": 825, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( int other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 826, "end_line": 829, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( double other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 830, "end_line": 833, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: complex & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 834, "end_line": 837, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const char * other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "other" ], "start_line": 838, "end_line": 841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: string & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "std" ], "start_line": 842, "end_line": 845, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::object::grab_ref", "long_name": "py::object::grab_ref( PyObject * newObj)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "newObj" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::lose_ref", "long_name": "py::object::lose_ref( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 57, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 74, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( bool val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 85, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 88, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 91, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 94, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( double val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: complex & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std" ], "start_line": 100, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const char * val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "val" ], "start_line": 107, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: string & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 117, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 128, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 133, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 138, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator std :: complex < double >", "long_name": "py::object::operator std :: complex < double >() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [], "start_line": 143, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator char *", "long_name": "py::object::operator char *() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 163, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "f", "flags" ], "start_line": 174, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( object f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "f", "flags" ], "start_line": 180, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 192, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "nm" ], "start_line": 195, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 210, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 214, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 227, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "std", "val" ], "start_line": 233, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 239, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 246, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 253, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 260, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 51, "parameters": [ "nm", "val" ], "start_line": 268, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "std", "val" ], "start_line": 275, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "nm", "val" ], "start_line": 282, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 290, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 297, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 304, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "nm", "std" ], "start_line": 312, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "std", "std" ], "start_line": 319, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 53, "parameters": [ "nm", "std" ], "start_line": 326, "end_line": 331, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 52, "parameters": [ "nm", "val" ], "start_line": 334, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [ "std", "val" ], "start_line": 341, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [ "nm", "val" ], "start_line": 348, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 54, "parameters": [ "nm", "std" ], "start_line": 356, "end_line": 361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 60, "parameters": [ "std", "std" ], "start_line": 363, "end_line": 368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "std" ], "start_line": 370, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "nm" ], "start_line": 380, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const std :: string & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "std" ], "start_line": 385, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "nm" ], "start_line": 390, "end_line": 394, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 400, "end_line": 406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( int other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 407, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( unsigned long other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 411, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( double other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 415, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: complex & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 419, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const char * other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 424, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: string & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 429, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 434, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 437, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 440, "end_line": 442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 443, "end_line": 445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 446, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 449, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 452, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 456, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 459, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 462, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 465, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 468, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 471, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 474, "end_line": 476, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 478, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 481, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 484, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 487, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 490, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 493, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 496, "end_line": 498, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 500, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 503, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 509, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 512, "end_line": 514, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 518, "end_line": 520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 522, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 525, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 528, "end_line": 530, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 531, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 534, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 537, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 540, "end_line": 542, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 547, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 550, "end_line": 552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 553, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 556, "end_line": 558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 559, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 562, "end_line": 564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 571, "end_line": 577, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::str", "long_name": "py::object::str() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 579, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::unicode", "long_name": "py::object::unicode() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 588, "end_line": 594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 49, "parameters": [ "nm" ], "start_line": 603, "end_line": 609, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "nm", "args_tup" ], "start_line": 611, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 57, "parameters": [ "nm", "args_tup", "kw_dict" ], "start_line": 619, "end_line": 625, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 627, "end_line": 629, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "std", "args_tup" ], "start_line": 630, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std", "args_tup", "kw_dict" ], "start_line": 633, "end_line": 635, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [], "start_line": 642, "end_line": 647, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "args_tup" ], "start_line": 648, "end_line": 653, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup , object & kw_dict) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "args_tup", "kw_dict" ], "start_line": 654, "end_line": 659, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 664, "end_line": 666, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [], "start_line": 671, "end_line": 676, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 681, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 701, "end_line": 706, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_int", "long_name": "py::object::is_int() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 708, "end_line": 710, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_float", "long_name": "py::object::is_float() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 712, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_complex", "long_name": "py::object::is_complex() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 716, "end_line": 718, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_list", "long_name": "py::object::is_list() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 720, "end_line": 722, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_tuple", "long_name": "py::object::is_tuple() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 724, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_dict", "long_name": "py::object::is_dict() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 728, "end_line": 730, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_string", "long_name": "py::object::is_string() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 732, "end_line": 734, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::size", "long_name": "py::object::size() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 742, "end_line": 747, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::len", "long_name": "py::object::len() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 748, "end_line": 750, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::length", "long_name": "py::object::length() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 751, "end_line": 753, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_item", "long_name": "py::object::set_item( const object & key , const object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "key", "val" ], "start_line": 761, "end_line": 765, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 792, "end_line": 795, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::refcount", "long_name": "py::object::refcount()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 797, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::operator < <", "long_name": "py::operator < <( std :: ostream & os , py :: object & obj)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "std", "py" ], "start_line": 802, "end_line": 806, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "py::object::keyed_ref::keyed_ref", "long_name": "py::object::keyed_ref::keyed_ref( object obj , object & parent , object & key)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 30, "parameters": [ "obj", "parent", "key" ], "start_line": 825, "end_line": 826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::~keyed_ref", "long_name": "py::object::keyed_ref::~keyed_ref()", "filename": "object.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 827, "end_line": 827, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const object & other)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 829, "end_line": 833, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( int other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 834, "end_line": 837, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( double other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 838, "end_line": 841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: complex & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 842, "end_line": 845, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const char * other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "other" ], "start_line": 846, "end_line": 849, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: string & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "std" ], "start_line": 850, "end_line": 853, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [], "start_line": 570, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::operator < <", "long_name": "py::operator < <( std :: ostream & os , py :: object & obj)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "std", "py" ], "start_line": 802, "end_line": 806, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "py::object::str", "long_name": "py::object::str() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [], "start_line": 577, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "nloc": 598, "complexity": 191, "token_count": 4351, "diff_parsed": { "added": [ " std::string repr() const {", " return std::string(PyString_AsString(result));", " std::string str() const {", " return std::string(PyString_AsString(result));" ], "deleted": [ " // !! Should these return std::string instead?", " object repr() const {", " lose_ref(result);", " return result;", " object str() const {", " lose_ref(result);", " return result;", "std::ostream& operator <<(std::ostream& os, py::object& obj)", "{", " os << (std::string)obj.repr();", " return os;", "}" ] } }, { "old_path": "weave/scxx/weave_imp.cpp", "new_path": "weave/scxx/weave_imp.cpp", "filename": "weave_imp.cpp", "extension": "cpp", "change_type": "MODIFY", "diff": "@@ -52,6 +52,12 @@ object::keyed_ref object::operator [] (const std::complex& key) {\n return operator [](_key);\n };\n \n+std::ostream& operator <<(std::ostream& os, py::object& obj)\n+{\n+ os << obj.repr();\n+ return os;\n+}\n+\n //---------------------------------------------------------------------------\n // Fail method for throwing exceptions with a given message.\n //---------------------------------------------------------------------------\n", "added_lines": 6, "deleted_lines": 0, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones.\n*********************************************/\n#include \"object.h\"\n\nusing namespace py;\n\n//---------------------------------------------------------------------------\n// object\n//\n// !! Wish I knew how to get these defined inline in object.h...\n//---------------------------------------------------------------------------\n\nobject::keyed_ref object::operator [] (object& key) {\n object rslt = PyObject_GetItem(_obj, key);\n lose_ref(rslt);\n if (!(PyObject*)rslt)\n {\n // don't throw error for when [] fails because it might be on left hand \n // side (a[0] = 1). If the obj was just created, it will be filled \n // with NULL values, and setting the values should be ok. However, we\n // do want to catch index errors that might occur on the right hand side\n // (obj = a[4] when a has len==3).\n if (PyErr_ExceptionMatches(PyExc_KeyError))\n PyErr_Clear(); // Ignore key errors\n else if (PyErr_ExceptionMatches(PyExc_IndexError))\n throw 1;\n }\n return object::keyed_ref(rslt, *this, key);\n};\nobject::keyed_ref object::operator [] (const char* key) {\n object _key = object(key);\n return operator[](_key);\n};\nobject::keyed_ref object::operator [] (const std::string& key) {\n object _key = object(key);\n return operator [](_key);\n};\nobject::keyed_ref object::operator [] (int key) {\n object _key = object(key);\n return operator [](_key);\n};\nobject::keyed_ref object::operator [] (double key) {\n object _key = object(key);\n return operator [](_key);\n};\nobject::keyed_ref object::operator [] (const std::complex& key) {\n object _key = object(key);\n return operator [](_key);\n};\n\nstd::ostream& operator <<(std::ostream& os, py::object& obj)\n{\n os << obj.repr();\n return os;\n}\n\n//---------------------------------------------------------------------------\n// Fail method for throwing exceptions with a given message.\n//---------------------------------------------------------------------------\n\nvoid py::fail(PyObject* exc, const char* msg)\n{\n PyErr_SetString(exc, msg);\n throw 1;\n}\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones.\n*********************************************/\n#include \"object.h\"\n\nusing namespace py;\n\n//---------------------------------------------------------------------------\n// object\n//\n// !! Wish I knew how to get these defined inline in object.h...\n//---------------------------------------------------------------------------\n\nobject::keyed_ref object::operator [] (object& key) {\n object rslt = PyObject_GetItem(_obj, key);\n lose_ref(rslt);\n if (!(PyObject*)rslt)\n {\n // don't throw error for when [] fails because it might be on left hand \n // side (a[0] = 1). If the obj was just created, it will be filled \n // with NULL values, and setting the values should be ok. However, we\n // do want to catch index errors that might occur on the right hand side\n // (obj = a[4] when a has len==3).\n if (PyErr_ExceptionMatches(PyExc_KeyError))\n PyErr_Clear(); // Ignore key errors\n else if (PyErr_ExceptionMatches(PyExc_IndexError))\n throw 1;\n }\n return object::keyed_ref(rslt, *this, key);\n};\nobject::keyed_ref object::operator [] (const char* key) {\n object _key = object(key);\n return operator[](_key);\n};\nobject::keyed_ref object::operator [] (const std::string& key) {\n object _key = object(key);\n return operator [](_key);\n};\nobject::keyed_ref object::operator [] (int key) {\n object _key = object(key);\n return operator [](_key);\n};\nobject::keyed_ref object::operator [] (double key) {\n object _key = object(key);\n return operator [](_key);\n};\nobject::keyed_ref object::operator [] (const std::complex& key) {\n object _key = object(key);\n return operator [](_key);\n};\n\n//---------------------------------------------------------------------------\n// Fail method for throwing exceptions with a given message.\n//---------------------------------------------------------------------------\n\nvoid py::fail(PyObject* exc, const char* msg)\n{\n PyErr_SetString(exc, msg);\n throw 1;\n}\n", "methods": [ { "name": "object::operator [ ]", "long_name": "object::operator [ ]( object & key)", "filename": "weave_imp.cpp", "nloc": 12, "complexity": 4, "token_count": 73, "parameters": [ "key" ], "start_line": 17, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( const char * key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "key" ], "start_line": 34, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( const std :: string & key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "std" ], "start_line": 38, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( int key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "key" ], "start_line": 42, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( double key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "key" ], "start_line": 46, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( const std :: complex & key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "std" ], "start_line": 50, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "operator < <", "long_name": "operator < <( std :: ostream & os , py :: object & obj)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "std", "py" ], "start_line": 55, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "py::fail", "long_name": "py::fail( PyObject * exc , const char * msg)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "exc", "msg" ], "start_line": 65, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "object::operator [ ]", "long_name": "object::operator [ ]( object & key)", "filename": "weave_imp.cpp", "nloc": 12, "complexity": 4, "token_count": 73, "parameters": [ "key" ], "start_line": 17, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( const char * key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "key" ], "start_line": 34, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( const std :: string & key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "std" ], "start_line": 38, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( int key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "key" ], "start_line": 42, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( double key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "key" ], "start_line": 46, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "object::operator [ ]", "long_name": "object::operator [ ]( const std :: complex & key)", "filename": "weave_imp.cpp", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "std" ], "start_line": 50, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "py::fail", "long_name": "py::fail( PyObject * exc , const char * msg)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "exc", "msg" ], "start_line": 59, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "operator < <", "long_name": "operator < <( std :: ostream & os , py :: object & obj)", "filename": "weave_imp.cpp", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "std", "py" ], "start_line": 55, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 44, "complexity": 11, "token_count": 311, "diff_parsed": { "added": [ "std::ostream& operator <<(std::ostream& os, py::object& obj)", "{", " os << obj.repr();", " return os;", "}", "" ], "deleted": [] } } ] }, { "hash": "7c0aa98776a31d7321a74f8df83a5d9d4ba0d214", "msg": "Removed weave dependence: lib2def lives in scipy_distutils already", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-11-18T21:06:13+00:00", "author_timezone": 0, "committer_date": "2002-11-18T21:06:13+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "21478aa10e8667d392a09d58b26d29a40e5f29c5" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 3, "insertions": 0, "lines": 3, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/mingw32_support.py", "new_path": "scipy_distutils/mingw32_support.py", "filename": "mingw32_support.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -36,10 +36,7 @@ def import_library_exists():\n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n- # lib2def lives in weave\n- sys.path.insert(0,os.path.join('.','weave'))\n import lib2def\n- del sys.path[0]\n \n #libfile, deffile = parse_cmd()\n #if deffile is None:\n", "added_lines": 0, "deleted_lines": 3, "source_code": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os, sys\nimport distutils.ccompiler\n\n# I'd really like to pull this out of scipy and make it part of distutils...\nimport scipy_distutils.command.build_flib as build_flib\n\n\nif sys.platform == 'win32':\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n \n # 1. Build libpython from .lib and .dll if they don't exist. \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if sys.platform == 'win32':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n #print full_path\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n import lib2def\n\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n print cmd\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print \"WARNING: failed to build import library for gcc. \"\\\n \"Linking will fail.\"\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \n def set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n \n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n ) \n def use_msvc():\n set_windows_compiler('msvc')\n \n def use_gcc(): \n set_windows_compiler('mingw32')\n \n standard_compiler_list = build_flib.all_compilers[:]\n def use_g77():\n build_flib.all_compilers = [build_flib.gnu_fortran_compiler] \n \n def use_standard_fortran_compiler():\n build_flib.all_compilers = standard_compiler_list\n \n # 2. force the use of gcc on windows platform\n use_gcc()\n # 3. force the use of g77 on windows platform\n use_g77()\n if not import_library_exists():\n build_import_library()\n", "source_code_before": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os, sys\nimport distutils.ccompiler\n\n# I'd really like to pull this out of scipy and make it part of distutils...\nimport scipy_distutils.command.build_flib as build_flib\n\n\nif sys.platform == 'win32':\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n \n # 1. Build libpython from .lib and .dll if they don't exist. \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if sys.platform == 'win32':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n #print full_path\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n # lib2def lives in weave\n sys.path.insert(0,os.path.join('.','weave'))\n import lib2def\n del sys.path[0]\n\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n print cmd\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print \"WARNING: failed to build import library for gcc. \"\\\n \"Linking will fail.\"\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \n def set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n \n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n ) \n def use_msvc():\n set_windows_compiler('msvc')\n \n def use_gcc(): \n set_windows_compiler('mingw32')\n \n standard_compiler_list = build_flib.all_compilers[:]\n def use_g77():\n build_flib.all_compilers = [build_flib.gnu_fortran_compiler] \n \n def use_standard_fortran_compiler():\n build_flib.all_compilers = standard_compiler_list\n \n # 2. force the use of gcc on windows platform\n use_gcc()\n # 3. force the use of g77 on windows platform\n use_g77()\n if not import_library_exists():\n build_import_library()\n", "methods": [ { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 25, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32_support.py", "nloc": 20, "complexity": 2, "token_count": 192, "parameters": [], "start_line": 36, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 70, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "use_msvc", "long_name": "use_msvc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 85, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "use_gcc", "long_name": "use_gcc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 88, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "use_g77", "long_name": "use_g77( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 92, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "use_standard_fortran_compiler", "long_name": "use_standard_fortran_compiler( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 95, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 25, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32_support.py", "nloc": 22, "complexity": 2, "token_count": 218, "parameters": [], "start_line": 36, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 73, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "use_msvc", "long_name": "use_msvc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 88, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "use_gcc", "long_name": "use_gcc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 91, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "use_g77", "long_name": "use_g77( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 95, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "use_standard_fortran_compiler", "long_name": "use_standard_fortran_compiler( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 98, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32_support.py", "nloc": 22, "complexity": 2, "token_count": 218, "parameters": [], "start_line": 36, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 } ], "nloc": 60, "complexity": 10, "token_count": 378, "diff_parsed": { "added": [], "deleted": [ " # lib2def lives in weave", " sys.path.insert(0,os.path.join('.','weave'))", " del sys.path[0]" ] } } ] }, { "hash": "c415fd107678e9537c998ff7be1cdadfa8881f23", "msg": "Bundle scipy_test,scipy_distutils to scipy_core. See the header of setup_scipy_core.py for usage information.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-11-18T22:39:31+00:00", "author_timezone": 0, "committer_date": "2002-11-18T22:39:31+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "7c0aa98776a31d7321a74f8df83a5d9d4ba0d214" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 0, "insertions": 41, "lines": 41, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": null, "new_path": "setup_scipy_core.py", "filename": "setup_scipy_core.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,41 @@\n+#!/usr/bin/env python\n+\"\"\"\n+Bundle of SciPy core modules:\n+ scipy_test, scipy_distutils\n+\n+Usage:\n+ python setup_scipy_core.py install\n+ python setup_scipy_core.py sdist -f -t MANIFEST_scipy_core.in\n+\"\"\"\n+\n+from scipy_distutils import scipy_distutils_version as v1\n+from scipy_test import scipy_test_version as v2\n+\n+major = max(v1.major,v2.major)\n+minor = max(v1.minor,v2.minor)\n+micro = max(v1.micro,v2.micro)\n+release_level = min(v1.release_level,v2.release_level)\n+cvs_minor = v1.cvs_minor + v2.cvs_minor\n+cvs_serial = v1.cvs_serial + v2.cvs_serial\n+\n+scipy_core_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n+ '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n+\n+if __name__ == \"__main__\":\n+ import os,sys\n+ from distutils.core import setup\n+ print 'SciPy core Version %s' % scipy_core_version\n+ setup (name = \"SciPy_core\",\n+ version = scipy_core_version,\n+ maintainer = \"SciPy Developers\",\n+ maintainer_email = \"scipy-dev@scipy.org\",\n+ description = \"SciPy core modules: scipy_test and scipy_distutils\",\n+ license = \"SciPy License (BSD Style)\",\n+ url = \"http://www.scipy.org\",\n+ packages=['scipy_distutils',\n+ 'scipy_distutils.command',\n+ 'scipy_test'],\n+ package_dir = {'scipy_distutils':'scipy_distutils',\n+ 'scipy_test':'scipy_test',\n+ },\n+ )\n", "added_lines": 41, "deleted_lines": 0, "source_code": "#!/usr/bin/env python\n\"\"\"\nBundle of SciPy core modules:\n scipy_test, scipy_distutils\n\nUsage:\n python setup_scipy_core.py install\n python setup_scipy_core.py sdist -f -t MANIFEST_scipy_core.in\n\"\"\"\n\nfrom scipy_distutils import scipy_distutils_version as v1\nfrom scipy_test import scipy_test_version as v2\n\nmajor = max(v1.major,v2.major)\nminor = max(v1.minor,v2.minor)\nmicro = max(v1.micro,v2.micro)\nrelease_level = min(v1.release_level,v2.release_level)\ncvs_minor = v1.cvs_minor + v2.cvs_minor\ncvs_serial = v1.cvs_serial + v2.cvs_serial\n\nscipy_core_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n\nif __name__ == \"__main__\":\n import os,sys\n from distutils.core import setup\n print 'SciPy core Version %s' % scipy_core_version\n setup (name = \"SciPy_core\",\n version = scipy_core_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy core modules: scipy_test and scipy_distutils\",\n license = \"SciPy License (BSD Style)\",\n url = \"http://www.scipy.org\",\n packages=['scipy_distutils',\n 'scipy_distutils.command',\n 'scipy_test'],\n package_dir = {'scipy_distutils':'scipy_distutils',\n 'scipy_test':'scipy_test',\n },\n )\n", "source_code_before": null, "methods": [], "methods_before": [], "changed_methods": [], "nloc": 36, "complexity": 0, "token_count": 163, "diff_parsed": { "added": [ "#!/usr/bin/env python", "\"\"\"", "Bundle of SciPy core modules:", " scipy_test, scipy_distutils", "", "Usage:", " python setup_scipy_core.py install", " python setup_scipy_core.py sdist -f -t MANIFEST_scipy_core.in", "\"\"\"", "", "from scipy_distutils import scipy_distutils_version as v1", "from scipy_test import scipy_test_version as v2", "", "major = max(v1.major,v2.major)", "minor = max(v1.minor,v2.minor)", "micro = max(v1.micro,v2.micro)", "release_level = min(v1.release_level,v2.release_level)", "cvs_minor = v1.cvs_minor + v2.cvs_minor", "cvs_serial = v1.cvs_serial + v2.cvs_serial", "", "scipy_core_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\", " '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())", "", "if __name__ == \"__main__\":", " import os,sys", " from distutils.core import setup", " print 'SciPy core Version %s' % scipy_core_version", " setup (name = \"SciPy_core\",", " version = scipy_core_version,", " maintainer = \"SciPy Developers\",", " maintainer_email = \"scipy-dev@scipy.org\",", " description = \"SciPy core modules: scipy_test and scipy_distutils\",", " license = \"SciPy License (BSD Style)\",", " url = \"http://www.scipy.org\",", " packages=['scipy_distutils',", " 'scipy_distutils.command',", " 'scipy_test'],", " package_dir = {'scipy_distutils':'scipy_distutils',", " 'scipy_test':'scipy_test',", " },", " )" ], "deleted": [] } } ] }, { "hash": "1376f6e0e0518a76133b89ac2919555c34ef7dc6", "msg": "changed the link order of libraries for absoft compiler. the order is now 'f90math' and then 'fmath'. This fixed link errors on windows with absoft 6.2", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-11-20T20:59:58+00:00", "author_timezone": 0, "committer_date": "2002-11-20T20:59:58+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "c415fd107678e9537c998ff7be1cdadfa8881f23" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -554,7 +554,7 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n- self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n+ self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Sun|SGI|Intel|Itanium|NAG|Compaq|Digital|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,temp_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic'\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n # -fixed specifies fixed-format instead of free-format F90/95 code\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f77_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n #self.f77_switches = self.f77_switches + self.f77_debug\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n #self.libraries = ['imf']\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Sun|SGI|Intel|Itanium|NAG|Compaq|Digital|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,temp_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic'\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n # -fixed specifies fixed-format instead of free-format F90/95 code\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f77_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n #self.f77_switches = self.f77_switches + self.f77_debug\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n #self.libraries = ['imf']\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 116, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 137, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 181, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 219, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 240, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 25, "complexity": 10, "token_count": 181, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 319, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 344, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 361, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 368, "end_line": 371, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 373, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 399, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 404, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 409, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 412, "end_line": 431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 21, "complexity": 6, "token_count": 149, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 433, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 475, "end_line": 482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 484, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 487, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 512, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 514, "end_line": 515, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 516, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 518, "end_line": 519, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 520, "end_line": 525, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 527, "end_line": 528, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 185, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 536, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 577, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 584, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 17, "complexity": 4, "token_count": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 615, "end_line": 641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 643, "end_line": 648, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 124, "parameters": [ "self" ], "start_line": 650, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 669, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 672, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 675, "end_line": 676, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 685, "end_line": 706, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 709, "end_line": 711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 712, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 715, "end_line": 716, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 717, "end_line": 718, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 95, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 725, "end_line": 744, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 746, "end_line": 764, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 772, "end_line": 803, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 45, "complexity": 21, "token_count": 254, "parameters": [ "self" ], "start_line": 805, "end_line": 851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 853, "end_line": 870, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 872, "end_line": 879, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 881, "end_line": 889, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 891, "end_line": 892, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 148, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 902, "end_line": 931, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 935, "end_line": 949, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 951, "end_line": 952, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 962, "end_line": 965, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 108, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 973, "end_line": 992, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 994, "end_line": 996, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 998, "end_line": 999, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1013, "end_line": 1041, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1047, "end_line": 1048, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1057, "end_line": 1081, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1085, "end_line": 1086, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 99, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1094, "end_line": 1116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1118, "end_line": 1121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1123, "end_line": 1124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 18, "complexity": 4, "token_count": 129, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1141, "end_line": 1164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1166, "end_line": 1168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 1171, "end_line": 1173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1175, "end_line": 1176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1178, "end_line": 1179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1181, "end_line": 1182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1184, "end_line": 1192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 116, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 137, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 181, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 219, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 240, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 25, "complexity": 10, "token_count": 181, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 319, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 344, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 361, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 368, "end_line": 371, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 373, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 399, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 404, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 409, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 412, "end_line": 431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 21, "complexity": 6, "token_count": 149, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 433, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 475, "end_line": 482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 484, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 487, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 512, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 514, "end_line": 515, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 516, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 518, "end_line": 519, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 520, "end_line": 525, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 527, "end_line": 528, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 185, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 536, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 577, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 584, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 17, "complexity": 4, "token_count": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 615, "end_line": 641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 643, "end_line": 648, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 124, "parameters": [ "self" ], "start_line": 650, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 669, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 672, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 675, "end_line": 676, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 685, "end_line": 706, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 709, "end_line": 711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 712, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 715, "end_line": 716, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 717, "end_line": 718, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 95, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 725, "end_line": 744, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 746, "end_line": 764, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 772, "end_line": 803, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 45, "complexity": 21, "token_count": 254, "parameters": [ "self" ], "start_line": 805, "end_line": 851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 853, "end_line": 870, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 872, "end_line": 879, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 881, "end_line": 889, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 891, "end_line": 892, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 148, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 902, "end_line": 931, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 935, "end_line": 949, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 951, "end_line": 952, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 962, "end_line": 965, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 108, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 973, "end_line": 992, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 994, "end_line": 996, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 998, "end_line": 999, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1013, "end_line": 1041, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1047, "end_line": 1048, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1057, "end_line": 1081, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1085, "end_line": 1086, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 99, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1094, "end_line": 1116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1118, "end_line": 1121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1123, "end_line": 1124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 18, "complexity": 4, "token_count": 129, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1141, "end_line": 1164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1166, "end_line": 1168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 1171, "end_line": 1173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1175, "end_line": 1176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1178, "end_line": 1179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1181, "end_line": 1182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1184, "end_line": 1192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 185, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 536, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 } ], "nloc": 875, "complexity": 222, "token_count": 5151, "diff_parsed": { "added": [ " self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']" ], "deleted": [ " self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']" ] } } ] }, { "hash": "bf70a2edb9714701e808581c934ba23864f74578", "msg": "Changed structure of stats module.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2002-11-22T09:07:42+00:00", "author_timezone": 0, "committer_date": "2002-11-22T09:07:42+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "1376f6e0e0518a76133b89ac2919555c34ef7dc6" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 2, "insertions": 1, "lines": 3, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_base/_compiled_base.c", "new_path": "scipy_base/_compiled_base.c", "filename": "_compiled_base.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -133,6 +133,7 @@ static PyObject *base_insert(PyObject *self, PyObject *args, PyObject *kwdict)\n if (avals == NULL) goto fail;\n avalscast = (PyArrayObject *)PyArray_Cast(avals, ainput->descr->type_num);\n if (avalscast == NULL) goto fail;\n+ Py_DECREF(avals);\n \n numvals = PyArray_SIZE(avalscast);\n nd = ainput->nd;\n@@ -152,7 +153,6 @@ static PyObject *base_insert(PyObject *self, PyObject *args, PyObject *kwdict)\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n }\n Py_DECREF(amask);\n- Py_DECREF(avals);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n@@ -190,7 +190,6 @@ static PyObject *base_insert(PyObject *self, PyObject *args, PyObject *kwdict)\n }\n \n Py_DECREF(amask);\n- Py_DECREF(avals);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n", "added_lines": 1, "deleted_lines": 2, "source_code": "\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n\n\nstatic char doc_base_unique[] = \"Return the unique elements of a 1-D sequence.\";\n\nstatic PyObject *base_unique(PyObject *self, PyObject *args, PyObject *kwdict)\n{\n /* Returns a 1-D array containing the unique elements of a 1-D sequence.\n */\n\n void *new_mem=NULL;\n PyArrayObject *ainput=NULL, *aoutput=NULL;\n int asize, abytes, new;\n int copied=0, nd;\n int instride=0, elsize, k, j, dims[1];\n char *ip, *op; /* Current memory buffer */\n char *op2;\n \n static char *kwlist[] = {\"input\", NULL};\n\n if (!PyArg_ParseTupleAndKeywords(args, kwdict, \"O!\", kwlist, &PyArray_Type, &ainput)) \n return NULL;\n \n if (ainput->nd > 1) {\n PyErr_SetString(PyExc_ValueError, \"Input array must be < 1 dimensional\");\n return NULL;\n }\n asize = PyArray_SIZE(ainput);\n elsize = ainput->descr->elsize;\n abytes = asize * elsize;\n nd = ainput->nd;\n if (nd > 0) {\n instride = ainput->strides[0];\n }\n\n new_mem = (void *)PyMem_Malloc((size_t) abytes);\n if (new_mem == NULL) {\n return PyErr_NoMemory();\n }\n \n ip = ainput->data;\n op = new_mem;\n for (k=0; k < asize; k++,ip+=instride) {\n new = 1; /* Assume it is new */\n op2 = new_mem;\n for (j=0; j < copied; j++,op2+=elsize) {\n if (memcmp(op2,ip,elsize) == 0) { /* Is a match found? */\n new = 0;\n break;\n }\n }\n /* No match found, copy this one over */\n if (new) {\n memcpy(op,ip,elsize);\n copied += 1;\n op += elsize; /* Get ready to put next match */\n }\n }\n\n dims[0] = copied;\n /* Make output array */\n if ((aoutput = (PyArrayObject *)PyArray_FromDims(nd, \n dims, ainput->descr->type_num))==NULL) goto fail;\n\n memcpy(aoutput->data,new_mem,elsize*copied);\n /* Reallocate memory to new-size */\n PyMem_Free(new_mem);\n return PyArray_Return(aoutput); \n \n fail:\n if (new_mem != NULL) PyMem_Free(new_mem);\n Py_XDECREF(aoutput);\n return NULL;\n}\n\n\nstatic char doc_base_insert[] = \"Insert vals sequenctially into equivalent 1-d positions indicated by mask.\";\n\nstatic PyObject *base_insert(PyObject *self, PyObject *args, PyObject *kwdict)\n{\n /* Returns input array with values inserted sequentially into places \n indicated by the mask\n */\n\n PyObject *mask=NULL, *vals=NULL;\n PyArrayObject *ainput=NULL, *amask=NULL, *avals=NULL, *avalscast=NULL, *tmp=NULL;\n int numvals, totmask, sameshape;\n char *input_data, *mptr, *vptr, *zero;\n int melsize, delsize, copied, nd;\n int *instrides, *inshape;\n int mindx, rem_indx, indx, i, k, objarray;\n \n static char *kwlist[] = {\"input\",\"mask\",\"vals\",NULL};\n\n if (!PyArg_ParseTupleAndKeywords(args, kwdict, \"O!OO\", kwlist, &PyArray_Type, &ainput, &mask, &vals))\n return NULL;\n\n /* Fixed problem with OBJECT ARRAYS\n if (ainput->descr->type_num == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"Not currently supported for Object arrays.\");\n return NULL;\n }\n */\n\n amask = (PyArrayObject *)PyArray_ContiguousFromObject(mask, PyArray_NOTYPE, 0, 0);\n if (amask == NULL) return NULL;\n /* Cast an object array */\n if (amask->descr->type_num == PyArray_OBJECT) {\n tmp = (PyArrayObject *)PyArray_Cast(amask, PyArray_LONG);\n if (tmp == NULL) goto fail;\n Py_DECREF(amask);\n amask = tmp;\n }\n\n sameshape = 1;\n if (amask->nd == ainput->nd) {\n for (k=0; k < amask->nd; k++) \n if (amask->dimensions[k] != ainput->dimensions[k])\n sameshape = 0;\n }\n else { /* Test to see if amask is 1d */\n if (amask->nd != 1) sameshape = 0;\n else if ((PyArray_SIZE(ainput)) != PyArray_SIZE(amask)) sameshape = 0;\n }\n if (!sameshape) {\n PyErr_SetString(PyExc_ValueError, \"Mask array must be 1D or same shape as input array.\");\n goto fail;\n }\n\n avals = (PyArrayObject *)PyArray_FromObject(vals, PyArray_NOTYPE, 0, 1);\n if (avals == NULL) goto fail;\n avalscast = (PyArrayObject *)PyArray_Cast(avals, ainput->descr->type_num);\n if (avalscast == NULL) goto fail;\n Py_DECREF(avals);\n\n numvals = PyArray_SIZE(avalscast);\n nd = ainput->nd;\n input_data = ainput->data;\n mptr = amask->data;\n melsize = amask->descr->elsize;\n vptr = avalscast->data;\n delsize = avalscast->descr->elsize;\n zero = amask->descr->zero;\n objarray = (ainput->descr->type_num == PyArray_OBJECT);\n \n /* Handle zero-dimensional case separately */\n if (nd == 0) {\n if (memcmp(mptr,zero,melsize) != 0) {\n /* Copy value element over to input array */\n memcpy(input_data,vptr,delsize);\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n }\n Py_DECREF(amask);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n }\n\n /* Walk through mask array, when non-zero is encountered\n copy next value in the vals array to the input array.\n If we get through the value array, repeat it as necessary. \n */\n totmask = PyArray_SIZE(amask);\n copied = 0;\n instrides = ainput->strides;\n inshape = ainput->dimensions;\n for (mindx = 0; mindx < totmask; mindx++) { \n if (memcmp(mptr,zero,melsize) != 0) { \n /* compute indx into input array \n */\n rem_indx = mindx;\n indx = 0;\n for(i=0; i < nd-1; ++i) {\n indx += (rem_indx / inshape[i]) * instrides[i];\n rem_indx %= inshape[i];\n }\n indx += rem_indx * instrides[nd-1];\n /* fprintf(stderr, \"mindx = %d, indx=%d\\n\", mindx, indx); */\n /* Copy value element over to input array */\n memcpy(input_data+indx,vptr,delsize);\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n vptr += delsize;\n copied += 1;\n /* If we move past value data. Reset */\n if (copied >= numvals) vptr = avalscast->data;\n }\n mptr += melsize;\n }\n\n Py_DECREF(amask);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n \n fail:\n Py_XDECREF(amask);\n Py_XDECREF(avals);\n Py_XDECREF(avalscast);\n return NULL;\n}\n\n\n/* Initialization function for the module (*must* be called initArray) */\n\nstatic struct PyMethodDef methods[] = {\n {\"_unique\",\t (PyCFunction)base_unique, METH_VARARGS | METH_KEYWORDS, doc_base_unique},\n {\"_insert\",\t (PyCFunction)base_insert, METH_VARARGS | METH_KEYWORDS, doc_base_insert},\n {NULL, NULL} /* sentinel */\n};\n\nDL_EXPORT(void) init_compiled_base(void) {\n PyObject *m, *d, *s;\n \n /* Create the module and add the functions */\n m = Py_InitModule(\"_compiled_base\", methods); \n\n /* Import the array and ufunc objects */\n import_array();\n\n /* Add some symbolic constants to the module */\n d = PyModule_GetDict(m);\n\n s = PyString_FromString(\"0.2\");\n PyDict_SetItemString(d, \"__version__\", s);\n Py_DECREF(s);\n\n /* Check for errors */\n if (PyErr_Occurred())\n\tPy_FatalError(\"can't initialize module _compiled_base\");\n}\n\n", "source_code_before": "\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n\n\nstatic char doc_base_unique[] = \"Return the unique elements of a 1-D sequence.\";\n\nstatic PyObject *base_unique(PyObject *self, PyObject *args, PyObject *kwdict)\n{\n /* Returns a 1-D array containing the unique elements of a 1-D sequence.\n */\n\n void *new_mem=NULL;\n PyArrayObject *ainput=NULL, *aoutput=NULL;\n int asize, abytes, new;\n int copied=0, nd;\n int instride=0, elsize, k, j, dims[1];\n char *ip, *op; /* Current memory buffer */\n char *op2;\n \n static char *kwlist[] = {\"input\", NULL};\n\n if (!PyArg_ParseTupleAndKeywords(args, kwdict, \"O!\", kwlist, &PyArray_Type, &ainput)) \n return NULL;\n \n if (ainput->nd > 1) {\n PyErr_SetString(PyExc_ValueError, \"Input array must be < 1 dimensional\");\n return NULL;\n }\n asize = PyArray_SIZE(ainput);\n elsize = ainput->descr->elsize;\n abytes = asize * elsize;\n nd = ainput->nd;\n if (nd > 0) {\n instride = ainput->strides[0];\n }\n\n new_mem = (void *)PyMem_Malloc((size_t) abytes);\n if (new_mem == NULL) {\n return PyErr_NoMemory();\n }\n \n ip = ainput->data;\n op = new_mem;\n for (k=0; k < asize; k++,ip+=instride) {\n new = 1; /* Assume it is new */\n op2 = new_mem;\n for (j=0; j < copied; j++,op2+=elsize) {\n if (memcmp(op2,ip,elsize) == 0) { /* Is a match found? */\n new = 0;\n break;\n }\n }\n /* No match found, copy this one over */\n if (new) {\n memcpy(op,ip,elsize);\n copied += 1;\n op += elsize; /* Get ready to put next match */\n }\n }\n\n dims[0] = copied;\n /* Make output array */\n if ((aoutput = (PyArrayObject *)PyArray_FromDims(nd, \n dims, ainput->descr->type_num))==NULL) goto fail;\n\n memcpy(aoutput->data,new_mem,elsize*copied);\n /* Reallocate memory to new-size */\n PyMem_Free(new_mem);\n return PyArray_Return(aoutput); \n \n fail:\n if (new_mem != NULL) PyMem_Free(new_mem);\n Py_XDECREF(aoutput);\n return NULL;\n}\n\n\nstatic char doc_base_insert[] = \"Insert vals sequenctially into equivalent 1-d positions indicated by mask.\";\n\nstatic PyObject *base_insert(PyObject *self, PyObject *args, PyObject *kwdict)\n{\n /* Returns input array with values inserted sequentially into places \n indicated by the mask\n */\n\n PyObject *mask=NULL, *vals=NULL;\n PyArrayObject *ainput=NULL, *amask=NULL, *avals=NULL, *avalscast=NULL, *tmp=NULL;\n int numvals, totmask, sameshape;\n char *input_data, *mptr, *vptr, *zero;\n int melsize, delsize, copied, nd;\n int *instrides, *inshape;\n int mindx, rem_indx, indx, i, k, objarray;\n \n static char *kwlist[] = {\"input\",\"mask\",\"vals\",NULL};\n\n if (!PyArg_ParseTupleAndKeywords(args, kwdict, \"O!OO\", kwlist, &PyArray_Type, &ainput, &mask, &vals))\n return NULL;\n\n /* Fixed problem with OBJECT ARRAYS\n if (ainput->descr->type_num == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"Not currently supported for Object arrays.\");\n return NULL;\n }\n */\n\n amask = (PyArrayObject *)PyArray_ContiguousFromObject(mask, PyArray_NOTYPE, 0, 0);\n if (amask == NULL) return NULL;\n /* Cast an object array */\n if (amask->descr->type_num == PyArray_OBJECT) {\n tmp = (PyArrayObject *)PyArray_Cast(amask, PyArray_LONG);\n if (tmp == NULL) goto fail;\n Py_DECREF(amask);\n amask = tmp;\n }\n\n sameshape = 1;\n if (amask->nd == ainput->nd) {\n for (k=0; k < amask->nd; k++) \n if (amask->dimensions[k] != ainput->dimensions[k])\n sameshape = 0;\n }\n else { /* Test to see if amask is 1d */\n if (amask->nd != 1) sameshape = 0;\n else if ((PyArray_SIZE(ainput)) != PyArray_SIZE(amask)) sameshape = 0;\n }\n if (!sameshape) {\n PyErr_SetString(PyExc_ValueError, \"Mask array must be 1D or same shape as input array.\");\n goto fail;\n }\n\n avals = (PyArrayObject *)PyArray_FromObject(vals, PyArray_NOTYPE, 0, 1);\n if (avals == NULL) goto fail;\n avalscast = (PyArrayObject *)PyArray_Cast(avals, ainput->descr->type_num);\n if (avalscast == NULL) goto fail;\n\n numvals = PyArray_SIZE(avalscast);\n nd = ainput->nd;\n input_data = ainput->data;\n mptr = amask->data;\n melsize = amask->descr->elsize;\n vptr = avalscast->data;\n delsize = avalscast->descr->elsize;\n zero = amask->descr->zero;\n objarray = (ainput->descr->type_num == PyArray_OBJECT);\n \n /* Handle zero-dimensional case separately */\n if (nd == 0) {\n if (memcmp(mptr,zero,melsize) != 0) {\n /* Copy value element over to input array */\n memcpy(input_data,vptr,delsize);\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n }\n Py_DECREF(amask);\n Py_DECREF(avals);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n }\n\n /* Walk through mask array, when non-zero is encountered\n copy next value in the vals array to the input array.\n If we get through the value array, repeat it as necessary. \n */\n totmask = PyArray_SIZE(amask);\n copied = 0;\n instrides = ainput->strides;\n inshape = ainput->dimensions;\n for (mindx = 0; mindx < totmask; mindx++) { \n if (memcmp(mptr,zero,melsize) != 0) { \n /* compute indx into input array \n */\n rem_indx = mindx;\n indx = 0;\n for(i=0; i < nd-1; ++i) {\n indx += (rem_indx / inshape[i]) * instrides[i];\n rem_indx %= inshape[i];\n }\n indx += rem_indx * instrides[nd-1];\n /* fprintf(stderr, \"mindx = %d, indx=%d\\n\", mindx, indx); */\n /* Copy value element over to input array */\n memcpy(input_data+indx,vptr,delsize);\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n vptr += delsize;\n copied += 1;\n /* If we move past value data. Reset */\n if (copied >= numvals) vptr = avalscast->data;\n }\n mptr += melsize;\n }\n\n Py_DECREF(amask);\n Py_DECREF(avals);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n \n fail:\n Py_XDECREF(amask);\n Py_XDECREF(avals);\n Py_XDECREF(avalscast);\n return NULL;\n}\n\n\n/* Initialization function for the module (*must* be called initArray) */\n\nstatic struct PyMethodDef methods[] = {\n {\"_unique\",\t (PyCFunction)base_unique, METH_VARARGS | METH_KEYWORDS, doc_base_unique},\n {\"_insert\",\t (PyCFunction)base_insert, METH_VARARGS | METH_KEYWORDS, doc_base_insert},\n {NULL, NULL} /* sentinel */\n};\n\nDL_EXPORT(void) init_compiled_base(void) {\n PyObject *m, *d, *s;\n \n /* Create the module and add the functions */\n m = Py_InitModule(\"_compiled_base\", methods); \n\n /* Import the array and ufunc objects */\n import_array();\n\n /* Add some symbolic constants to the module */\n d = PyModule_GetDict(m);\n\n s = PyString_FromString(\"0.2\");\n PyDict_SetItemString(d, \"__version__\", s);\n Py_DECREF(s);\n\n /* Check for errors */\n if (PyErr_Occurred())\n\tPy_FatalError(\"can't initialize module _compiled_base\");\n}\n\n", "methods": [ { "name": "base_unique", "long_name": "base_unique( PyObject * self , PyObject * args , PyObject * kwdict)", "filename": "_compiled_base.c", "nloc": 55, "complexity": 11, "token_count": 381, "parameters": [ "self", "args", "kwdict" ], "start_line": 8, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "base_insert", "long_name": "base_insert( PyObject * self , PyObject * args , PyObject * kwdict)", "filename": "_compiled_base.c", "nloc": 89, "complexity": 21, "token_count": 711, "parameters": [ "self", "args", "kwdict" ], "start_line": 81, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 122, "top_nesting_level": 0 }, { "name": "init_compiled_base", "long_name": "init_compiled_base()", "filename": "_compiled_base.c", "nloc": 11, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 213, "end_line": 232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 } ], "methods_before": [ { "name": "base_unique", "long_name": "base_unique( PyObject * self , PyObject * args , PyObject * kwdict)", "filename": "_compiled_base.c", "nloc": 55, "complexity": 11, "token_count": 381, "parameters": [ "self", "args", "kwdict" ], "start_line": 8, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "base_insert", "long_name": "base_insert( PyObject * self , PyObject * args , PyObject * kwdict)", "filename": "_compiled_base.c", "nloc": 90, "complexity": 21, "token_count": 716, "parameters": [ "self", "args", "kwdict" ], "start_line": 81, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 123, "top_nesting_level": 0 }, { "name": "init_compiled_base", "long_name": "init_compiled_base()", "filename": "_compiled_base.c", "nloc": 11, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 214, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "base_insert", "long_name": "base_insert( PyObject * self , PyObject * args , PyObject * kwdict)", "filename": "_compiled_base.c", "nloc": 89, "complexity": 21, "token_count": 711, "parameters": [ "self", "args", "kwdict" ], "start_line": 81, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 122, "top_nesting_level": 0 } ], "nloc": 164, "complexity": 34, "token_count": 1235, "diff_parsed": { "added": [ " Py_DECREF(avals);" ], "deleted": [ " Py_DECREF(avals);", " Py_DECREF(avals);" ] } } ] }, { "hash": "cf28dad0ecc182fc727d2e118d99069e0e6a88f1", "msg": "Removed sun_fortran_compiler.get_runtime_library_dirs method that caused linkage error due to -W flag that is supposed to be used only with gnu compilers", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-11-22T18:42:22+00:00", "author_timezone": 0, "committer_date": "2002-11-22T18:42:22+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "bf70a2edb9714701e808581c934ba23864f74578" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 3, "insertions": 0, "lines": 3, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -666,9 +666,6 @@ def find_lib_dir(self):\n self.version,'lib'))\n return library_dirs\n \n- def get_runtime_library_dirs(self):\n- return self.find_lib_dir()\n-\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n \n", "added_lines": 0, "deleted_lines": 3, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Sun|SGI|Intel|Itanium|NAG|Compaq|Digital|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,temp_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic'\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n # -fixed specifies fixed-format instead of free-format F90/95 code\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f77_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n #self.f77_switches = self.f77_switches + self.f77_debug\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n #self.libraries = ['imf']\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Sun|SGI|Intel|Itanium|NAG|Compaq|Digital|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,temp_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic'\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n # -fixed specifies fixed-format instead of free-format F90/95 code\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f77_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n #self.f77_switches = self.f77_switches + self.f77_debug\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n #self.libraries = ['imf']\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 116, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 137, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 181, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 219, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 240, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 25, "complexity": 10, "token_count": 181, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 319, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 344, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 361, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 368, "end_line": 371, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 373, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 399, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 404, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 409, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 412, "end_line": 431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 21, "complexity": 6, "token_count": 149, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 433, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 475, "end_line": 482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 484, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 487, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 512, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 514, "end_line": 515, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 516, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 518, "end_line": 519, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 520, "end_line": 525, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 527, "end_line": 528, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 185, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 536, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 577, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 584, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 17, "complexity": 4, "token_count": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 615, "end_line": 641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 643, "end_line": 648, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 124, "parameters": [ "self" ], "start_line": 650, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 669, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 672, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 682, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 706, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 709, "end_line": 711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 712, "end_line": 713, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 714, "end_line": 715, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 95, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 722, "end_line": 741, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 743, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 769, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 45, "complexity": 21, "token_count": 254, "parameters": [ "self" ], "start_line": 802, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 850, "end_line": 867, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 869, "end_line": 876, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 878, "end_line": 886, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 888, "end_line": 889, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 148, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 899, "end_line": 928, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 932, "end_line": 946, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 948, "end_line": 949, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 959, "end_line": 962, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 108, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 970, "end_line": 989, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 991, "end_line": 993, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 995, "end_line": 996, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1010, "end_line": 1038, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1044, "end_line": 1045, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1054, "end_line": 1078, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1082, "end_line": 1083, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 99, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1091, "end_line": 1113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1115, "end_line": 1118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1120, "end_line": 1121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 18, "complexity": 4, "token_count": 129, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1138, "end_line": 1161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1163, "end_line": 1165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 1168, "end_line": 1170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1172, "end_line": 1173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1175, "end_line": 1176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1178, "end_line": 1179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1181, "end_line": 1189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 116, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 137, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 181, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 219, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 240, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 25, "complexity": 10, "token_count": 181, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 319, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 344, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 361, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 368, "end_line": 371, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 373, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 399, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 404, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 409, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 412, "end_line": 431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 21, "complexity": 6, "token_count": 149, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 433, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 475, "end_line": 482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 484, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 487, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 512, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 514, "end_line": 515, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 516, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 518, "end_line": 519, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 520, "end_line": 525, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 527, "end_line": 528, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 185, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 536, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 577, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 584, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 17, "complexity": 4, "token_count": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 615, "end_line": 641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 643, "end_line": 648, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 124, "parameters": [ "self" ], "start_line": 650, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 669, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 672, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 675, "end_line": 676, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 685, "end_line": 706, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 709, "end_line": 711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 712, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 715, "end_line": 716, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 717, "end_line": 718, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 95, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 725, "end_line": 744, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 746, "end_line": 764, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 772, "end_line": 803, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 45, "complexity": 21, "token_count": 254, "parameters": [ "self" ], "start_line": 805, "end_line": 851, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 853, "end_line": 870, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 872, "end_line": 879, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 881, "end_line": 889, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 891, "end_line": 892, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 148, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 902, "end_line": 931, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 935, "end_line": 949, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 951, "end_line": 952, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 962, "end_line": 965, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 108, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 973, "end_line": 992, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 994, "end_line": 996, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 998, "end_line": 999, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1013, "end_line": 1041, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1047, "end_line": 1048, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1057, "end_line": 1081, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1085, "end_line": 1086, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 99, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1094, "end_line": 1116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1118, "end_line": 1121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1123, "end_line": 1124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 18, "complexity": 4, "token_count": 129, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1141, "end_line": 1164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1166, "end_line": 1168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 1171, "end_line": 1173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1175, "end_line": 1176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1178, "end_line": 1179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1181, "end_line": 1182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1184, "end_line": 1192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 669, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "nloc": 873, "complexity": 221, "token_count": 5139, "diff_parsed": { "added": [], "deleted": [ " def get_runtime_library_dirs(self):", " return self.find_lib_dir()", "" ] } } ] }, { "hash": "18f6cc54d9a0fe3dd53474858e6dc2fcefb0e657", "msg": "Fixed dummy file name for multi-user systems", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-11-22T23:08:01+00:00", "author_timezone": 0, "committer_date": "2002-11-22T23:08:01+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "cf28dad0ecc182fc727d2e118d99069e0e6a88f1" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 6, "insertions": 5, "lines": 11, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -473,13 +473,12 @@ def build_library(self,library_name,source_list,module_dirs=None,\n self.create_static_lib(object_list,library_name,temp_dir)\n \n def dummy_fortran_files(self):\n- import tempfile \n- d = tempfile.gettempdir()\n- dummy_name = os.path.join(d,'__dummy.f')\n- dummy = open(dummy_name,'w')\n+ import tempfile\n+ dummy_name = tempfile.mktemp()+'__dummy'\n+ dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n- return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))\n+ return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n@@ -651,7 +650,7 @@ def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n- cmd = self.f90_compiler + ' -dryrun dummy.f'\n+ cmd = self.f90_compiler + ' -dryrun __dummy.f'\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n", "added_lines": 5, "deleted_lines": 6, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Sun|SGI|Intel|Itanium|NAG|Compaq|Digital|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,temp_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic'\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n # -fixed specifies fixed-format instead of free-format F90/95 code\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun __dummy.f'\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f77_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n #self.f77_switches = self.f77_switches + self.f77_debug\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n #self.libraries = ['imf']\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Sun|SGI|Intel|Itanium|NAG|Compaq|Digital|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,temp_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic'\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n # -fixed specifies fixed-format instead of free-format F90/95 code\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f77_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n #self.f77_switches = self.f77_switches + self.f77_debug\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n #self.libraries = ['imf']\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 116, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 137, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 181, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 219, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 240, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 25, "complexity": 10, "token_count": 181, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 319, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 344, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 361, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 368, "end_line": 371, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 373, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 399, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 404, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 409, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 412, "end_line": 431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 21, "complexity": 6, "token_count": 149, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 433, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 475, "end_line": 481, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 483, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 486, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 511, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 513, "end_line": 514, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 515, "end_line": 516, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 517, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 519, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 526, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 185, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 535, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 576, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 583, "end_line": 584, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 17, "complexity": 4, "token_count": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 614, "end_line": 640, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 642, "end_line": 647, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 124, "parameters": [ "self" ], "start_line": 649, "end_line": 666, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 668, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 671, "end_line": 672, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 681, "end_line": 702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 705, "end_line": 707, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 708, "end_line": 710, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 711, "end_line": 712, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 713, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 95, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 721, "end_line": 740, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 742, "end_line": 760, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 768, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 45, "complexity": 21, "token_count": 254, "parameters": [ "self" ], "start_line": 801, "end_line": 847, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 849, "end_line": 866, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 868, "end_line": 875, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 877, "end_line": 885, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 887, "end_line": 888, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 148, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 898, "end_line": 927, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 931, "end_line": 945, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 947, "end_line": 948, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 958, "end_line": 961, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 108, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 969, "end_line": 988, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 990, "end_line": 992, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 994, "end_line": 995, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1009, "end_line": 1037, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1043, "end_line": 1044, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1053, "end_line": 1077, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1081, "end_line": 1082, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 99, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1090, "end_line": 1112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1114, "end_line": 1117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1119, "end_line": 1120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 18, "complexity": 4, "token_count": 129, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1137, "end_line": 1160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1162, "end_line": 1164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 1167, "end_line": 1169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1171, "end_line": 1172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1174, "end_line": 1175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1177, "end_line": 1178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1180, "end_line": 1188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 116, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 137, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 181, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 219, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 240, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 25, "complexity": 10, "token_count": 181, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 319, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 344, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 361, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 368, "end_line": 371, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 373, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 399, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 404, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 409, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 412, "end_line": 431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 21, "complexity": 6, "token_count": 149, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 433, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 475, "end_line": 482, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 484, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 487, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 512, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 514, "end_line": 515, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 516, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 518, "end_line": 519, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 520, "end_line": 525, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 527, "end_line": 528, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 185, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 536, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 577, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 584, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 17, "complexity": 4, "token_count": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 615, "end_line": 641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 643, "end_line": 648, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 124, "parameters": [ "self" ], "start_line": 650, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 669, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 672, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 682, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 706, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 709, "end_line": 711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 712, "end_line": 713, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 714, "end_line": 715, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 95, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 722, "end_line": 741, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 743, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 769, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 45, "complexity": 21, "token_count": 254, "parameters": [ "self" ], "start_line": 802, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 850, "end_line": 867, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 869, "end_line": 876, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 878, "end_line": 886, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 888, "end_line": 889, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 148, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 899, "end_line": 928, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 932, "end_line": 946, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 948, "end_line": 949, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 959, "end_line": 962, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 108, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 970, "end_line": 989, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 991, "end_line": 993, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 995, "end_line": 996, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1010, "end_line": 1038, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1044, "end_line": 1045, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1054, "end_line": 1078, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1082, "end_line": 1083, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 99, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1091, "end_line": 1113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1115, "end_line": 1118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1120, "end_line": 1121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 18, "complexity": 4, "token_count": 129, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1138, "end_line": 1161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1163, "end_line": 1165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 1168, "end_line": 1170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1172, "end_line": 1173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1175, "end_line": 1176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1178, "end_line": 1179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1181, "end_line": 1189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 475, "end_line": 481, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 124, "parameters": [ "self" ], "start_line": 649, "end_line": 666, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 } ], "nloc": 872, "complexity": 221, "token_count": 5117, "diff_parsed": { "added": [ " import tempfile", " dummy_name = tempfile.mktemp()+'__dummy'", " dummy = open(dummy_name+'.f','w')", " return (dummy_name+'.f',dummy_name+'.o')", " cmd = self.f90_compiler + ' -dryrun __dummy.f'" ], "deleted": [ " import tempfile", " d = tempfile.gettempdir()", " dummy_name = os.path.join(d,'__dummy.f')", " dummy = open(dummy_name,'w')", " return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.o'))", " cmd = self.f90_compiler + ' -dryrun dummy.f'" ] } } ] }, { "hash": "dcc65693d78f065ec13d613056ae825b3d66d077", "msg": "Added support for now separate f77 and f90 wrappers that the latest f2py may generate.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-11-23T00:01:42+00:00", "author_timezone": 0, "committer_date": "2002-11-23T00:01:42+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "18f6cc54d9a0fe3dd53474858e6dc2fcefb0e657" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 10, "insertions": 21, "lines": 31, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/command/run_f2py.py", "new_path": "scipy_distutils/command/run_f2py.py", "filename": "run_f2py.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -80,15 +80,19 @@ def f2py_sources (self, sources, ext):\n .pyf file from the Fortran files found in 'sources'.\n \"\"\"\n try:\n- import f2py2e\n- self.announce('using F2PY %s' % (f2py2e.f2py2e.f2py_version))\n+ if sys.modules.has_key('f2py2e'):\n+ import f2py2e\n+ else:\n+ import f2py2e\n+ self.announce('using F2PY %s' % (f2py2e.f2py2e.f2py_version))\n except ImportError:\n print sys.exc_value\n raise F2pyNotFoundError,F2pyNotFoundError.__doc__\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n- # -f2pywrappers.f [occasionally]\n+ # -f2pywrappers.f [occasionally]\n+ # -f2pywrappers2.f90 [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains definitions for exactly\n@@ -103,6 +107,7 @@ def f2py_sources (self, sources, ext):\n f2py_fortran_targets = {}\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n+ fortran90_target_ext = '-f2pywrappers2.f90'\n ext_name = string.split(ext.name,'.')[-1]\n \n for source in sources:\n@@ -129,9 +134,12 @@ def f2py_sources (self, sources, ext):\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,\n base+fortran_target_ext)\n+ fortran90_target_file = os.path.join(target_dir,\n+ base+fortran90_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n- f2py_fortran_targets[source] = fortran_target_file\n+ f2py_fortran_targets[source] = [fortran_target_file,\n+ fortran90_target_file]\n elif fortran_ext_re(source_ext):\n fortran_sources.append(source) \n else:\n@@ -148,8 +156,6 @@ def f2py_sources (self, sources, ext):\n # creating a temporary pyf file from fortran sources\n pyf_target = os.path.join(target_dir,ext_name+'.pyf')\n pyf_target_file = os.path.join(target_dir,ext_name+target_ext)\n- pyf_fortran_target_file = os.path.join(target_dir,\n- ext_name+fortran_target_ext)\n f2py_opts2 = ['-m',ext_name,'-h',pyf_target,'--overwrite-signature']\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n@@ -160,9 +166,14 @@ def f2py_sources (self, sources, ext):\n string.join(fortran_sources + f2py_opts2,' ')))\n f2py2e.run_main(fortran_sources + f2py_opts2)\n break\n+ pyf_fortran_target_file = os.path.join(target_dir,\n+ ext_name+fortran_target_ext)\n+ pyf_fortran90_target_file = os.path.join(target_dir,\n+ ext_name+fortran90_target_ext)\n f2py_sources.append(pyf_target)\n f2py_targets[pyf_target] = pyf_target_file\n- f2py_fortran_targets[pyf_target] = pyf_fortran_target_file\n+ f2py_fortran_targets[pyf_target] = [pyf_fortran_target_file,\n+ pyf_fortran90_target_file]\n \n new_sources.extend(fortran_sources)\n \n@@ -185,14 +196,14 @@ def f2py_sources (self, sources, ext):\n f2py_options.append('--quiet')\n for source in f2py_sources:\n target = f2py_targets[source]\n- fortran_target = f2py_fortran_targets[source]\n if newer(source,target) or self.force:\n self.announce(yellow_text(\"f2py %s\" % \\\n string.join(f2py_options+[source],' ')))\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n- if os.path.exists(fortran_target):\n- new_sources.append(fortran_target)\n+ for fortran_target in f2py_fortran_targets[source]:\n+ if os.path.exists(fortran_target):\n+ new_sources.append(fortran_target)\n return new_sources\n \n # f2py_sources ()\n", "added_lines": 21, "deleted_lines": 10, "source_code": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom distutils.cmd import Command\n#from scipy_distutils.core import Command\nfrom scipy_distutils.system_info import F2pyNotFoundError\nfrom scipy_distutils.misc_util import red_text,yellow_text\n\nimport re,os,sys,string\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\nuser_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?'\\\n '__user__[\\w_]*)',re.I).match\nfortran_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('no-wrap-functions', None,\n \"do not generate wrappers for Fortran functions,etc.\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.no_wrap_functions = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n if self.no_wrap_functions is not None:\n self.f2py_options.append('--no-wrap-functions')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n # XXX: might need also\n # build_flib = self.get_finalized_command('build_flib')\n # ...\n # for getting extra f2py_options that are specific to\n # a given fortran compiler.\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\" Walk the list of source files in `sources`, looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return the modified `sources` list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n If 'sources' contains no .pyf files, then create a temporary\n .pyf file from the Fortran files found in 'sources'.\n \"\"\"\n try:\n if sys.modules.has_key('f2py2e'):\n import f2py2e\n else:\n import f2py2e\n self.announce('using F2PY %s' % (f2py2e.f2py2e.f2py_version))\n except ImportError:\n print sys.exc_value\n raise F2pyNotFoundError,F2pyNotFoundError.__doc__\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # -f2pywrappers2.f90 [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains definitions for exactly\n # one extension module.\n\n target_dir = self.build_dir\n \n new_sources = []\n f2py_sources = []\n fortran_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n fortran90_target_ext = '-f2pywrappers2.f90'\n ext_name = string.split(ext.name,'.')[-1]\n\n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = module_name_re(line)\n if m:\n if user_module_name_re(line): # skip *__user__* names\n continue\n base = m.group('name')\n break\n f.close()\n if ext.name == 'untitled':\n ext.name = base\n if base != ext_name:\n # XXX: Should we do here more than just warn?\n self.warn(red_text('%s provides %s but this extension is %s' \\\n % (source,`base`,`ext_name`)))\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,\n base+fortran_target_ext)\n fortran90_target_file = os.path.join(target_dir,\n base+fortran90_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = [fortran_target_file,\n fortran90_target_file]\n elif fortran_ext_re(source_ext):\n fortran_sources.append(source) \n else:\n new_sources.append(source)\n\n if not (f2py_sources or fortran_sources):\n return new_sources\n\n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n if not f2py_sources:\n # creating a temporary pyf file from fortran sources\n pyf_target = os.path.join(target_dir,ext_name+'.pyf')\n pyf_target_file = os.path.join(target_dir,ext_name+target_ext)\n f2py_opts2 = ['-m',ext_name,'-h',pyf_target,'--overwrite-signature']\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_opts2.append('--quiet')\n for source in fortran_sources:\n if newer(source,pyf_target) or self.force:\n self.announce(yellow_text(\"f2py %s\" % \\\n string.join(fortran_sources + f2py_opts2,' ')))\n f2py2e.run_main(fortran_sources + f2py_opts2)\n break\n pyf_fortran_target_file = os.path.join(target_dir,\n ext_name+fortran_target_ext)\n pyf_fortran90_target_file = os.path.join(target_dir,\n ext_name+fortran90_target_ext)\n f2py_sources.append(pyf_target)\n f2py_targets[pyf_target] = pyf_target_file\n f2py_fortran_targets[pyf_target] = [pyf_fortran_target_file,\n pyf_fortran90_target_file]\n\n new_sources.extend(fortran_sources)\n\n if len(f2py_sources) > 1:\n self.warn(red_text('Only one .pyf file can be used per Extension'\\\n ' but got %s.' % (len(f2py_sources))))\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n if ext.f2py_options != self.f2py_options:\n f2py_options = ext.f2py_options + self.f2py_options\n else:\n f2py_options = self.f2py_options[:]\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_options.append('--quiet')\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target) or self.force:\n self.announce(yellow_text(\"f2py %s\" % \\\n string.join(f2py_options+[source],' ')))\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n for fortran_target in f2py_fortran_targets[source]:\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n return new_sources\n\n # f2py_sources ()\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n\n for file in ext.sources:\n if fortran_ext_re(file):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.distribution.fortran_libraries is None:\n self.distribution.fortran_libraries = []\n fortran_libraries = self.distribution.fortran_libraries\n\n ext_name = string.split(ext.name,'.')[-1]\n name = ext_name\n flib = None\n for n,d in fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {}\n fortran_libraries.append((name,flib))\n \n flib.setdefault('sources',[]).extend(f_files)\n flib.setdefault('define_macros',[]).extend(ext.define_macros)\n flib.setdefault('undef_macros',[]).extend(ext.undef_macros)\n flib.setdefault('include_dirs',[]).extend(ext.include_dirs)\n \n# class run_f2py\n", "source_code_before": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom distutils.cmd import Command\n#from scipy_distutils.core import Command\nfrom scipy_distutils.system_info import F2pyNotFoundError\nfrom scipy_distutils.misc_util import red_text,yellow_text\n\nimport re,os,sys,string\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\nuser_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?'\\\n '__user__[\\w_]*)',re.I).match\nfortran_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('no-wrap-functions', None,\n \"do not generate wrappers for Fortran functions,etc.\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.no_wrap_functions = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n if self.no_wrap_functions is not None:\n self.f2py_options.append('--no-wrap-functions')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n # XXX: might need also\n # build_flib = self.get_finalized_command('build_flib')\n # ...\n # for getting extra f2py_options that are specific to\n # a given fortran compiler.\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\" Walk the list of source files in `sources`, looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return the modified `sources` list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n If 'sources' contains no .pyf files, then create a temporary\n .pyf file from the Fortran files found in 'sources'.\n \"\"\"\n try:\n import f2py2e\n self.announce('using F2PY %s' % (f2py2e.f2py2e.f2py_version))\n except ImportError:\n print sys.exc_value\n raise F2pyNotFoundError,F2pyNotFoundError.__doc__\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains definitions for exactly\n # one extension module.\n\n target_dir = self.build_dir\n \n new_sources = []\n f2py_sources = []\n fortran_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n ext_name = string.split(ext.name,'.')[-1]\n\n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = module_name_re(line)\n if m:\n if user_module_name_re(line): # skip *__user__* names\n continue\n base = m.group('name')\n break\n f.close()\n if ext.name == 'untitled':\n ext.name = base\n if base != ext_name:\n # XXX: Should we do here more than just warn?\n self.warn(red_text('%s provides %s but this extension is %s' \\\n % (source,`base`,`ext_name`)))\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,\n base+fortran_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = fortran_target_file\n elif fortran_ext_re(source_ext):\n fortran_sources.append(source) \n else:\n new_sources.append(source)\n\n if not (f2py_sources or fortran_sources):\n return new_sources\n\n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n if not f2py_sources:\n # creating a temporary pyf file from fortran sources\n pyf_target = os.path.join(target_dir,ext_name+'.pyf')\n pyf_target_file = os.path.join(target_dir,ext_name+target_ext)\n pyf_fortran_target_file = os.path.join(target_dir,\n ext_name+fortran_target_ext)\n f2py_opts2 = ['-m',ext_name,'-h',pyf_target,'--overwrite-signature']\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_opts2.append('--quiet')\n for source in fortran_sources:\n if newer(source,pyf_target) or self.force:\n self.announce(yellow_text(\"f2py %s\" % \\\n string.join(fortran_sources + f2py_opts2,' ')))\n f2py2e.run_main(fortran_sources + f2py_opts2)\n break\n f2py_sources.append(pyf_target)\n f2py_targets[pyf_target] = pyf_target_file\n f2py_fortran_targets[pyf_target] = pyf_fortran_target_file\n\n new_sources.extend(fortran_sources)\n\n if len(f2py_sources) > 1:\n self.warn(red_text('Only one .pyf file can be used per Extension'\\\n ' but got %s.' % (len(f2py_sources))))\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n if ext.f2py_options != self.f2py_options:\n f2py_options = ext.f2py_options + self.f2py_options\n else:\n f2py_options = self.f2py_options[:]\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_options.append('--quiet')\n for source in f2py_sources:\n target = f2py_targets[source]\n fortran_target = f2py_fortran_targets[source]\n if newer(source,target) or self.force:\n self.announce(yellow_text(\"f2py %s\" % \\\n string.join(f2py_options+[source],' ')))\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n return new_sources\n\n # f2py_sources ()\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n\n for file in ext.sources:\n if fortran_ext_re(file):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.distribution.fortran_libraries is None:\n self.distribution.fortran_libraries = []\n fortran_libraries = self.distribution.fortran_libraries\n\n ext_name = string.split(ext.name,'.')[-1]\n name = ext_name\n flib = None\n for n,d in fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {}\n fortran_libraries.append((name,flib))\n \n flib.setdefault('sources',[]).extend(f_files)\n flib.setdefault('define_macros',[]).extend(ext.define_macros)\n flib.setdefault('undef_macros',[]).extend(ext.undef_macros)\n flib.setdefault('include_dirs',[]).extend(ext.include_dirs)\n \n# class run_f2py\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 38, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 9, "complexity": 3, "token_count": 69, "parameters": [ "self" ], "start_line": 47, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 61, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 102, "complexity": 28, "token_count": 719, "parameters": [ "self", "sources", "ext" ], "start_line": 73, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 135, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 28, "complexity": 8, "token_count": 196, "parameters": [ "self", "ext" ], "start_line": 211, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 38, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 9, "complexity": 3, "token_count": 69, "parameters": [ "self" ], "start_line": 47, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 61, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 92, "complexity": 26, "token_count": 664, "parameters": [ "self", "sources", "ext" ], "start_line": 73, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 124, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 28, "complexity": 8, "token_count": 196, "parameters": [ "self", "ext" ], "start_line": 200, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 102, "complexity": 28, "token_count": 719, "parameters": [ "self", "sources", "ext" ], "start_line": 73, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 135, "top_nesting_level": 1 } ], "nloc": 176, "complexity": 43, "token_count": 1195, "diff_parsed": { "added": [ " if sys.modules.has_key('f2py2e'):", " import f2py2e", " else:", " import f2py2e", " self.announce('using F2PY %s' % (f2py2e.f2py2e.f2py_version))", " # -f2pywrappers.f [occasionally]", " # -f2pywrappers2.f90 [occasionally]", " fortran90_target_ext = '-f2pywrappers2.f90'", " fortran90_target_file = os.path.join(target_dir,", " base+fortran90_target_ext)", " f2py_fortran_targets[source] = [fortran_target_file,", " fortran90_target_file]", " pyf_fortran_target_file = os.path.join(target_dir,", " ext_name+fortran_target_ext)", " pyf_fortran90_target_file = os.path.join(target_dir,", " ext_name+fortran90_target_ext)", " f2py_fortran_targets[pyf_target] = [pyf_fortran_target_file,", " pyf_fortran90_target_file]", " for fortran_target in f2py_fortran_targets[source]:", " if os.path.exists(fortran_target):", " new_sources.append(fortran_target)" ], "deleted": [ " import f2py2e", " self.announce('using F2PY %s' % (f2py2e.f2py2e.f2py_version))", " # -f2pywrappers.f [occasionally]", " f2py_fortran_targets[source] = fortran_target_file", " pyf_fortran_target_file = os.path.join(target_dir,", " ext_name+fortran_target_ext)", " f2py_fortran_targets[pyf_target] = pyf_fortran_target_file", " fortran_target = f2py_fortran_targets[source]", " if os.path.exists(fortran_target):", " new_sources.append(fortran_target)" ] } } ] }, { "hash": "8003ebb85561bacfcfbe4e374a739325e3a80733", "msg": "Display F2PY version only once", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-11-23T00:12:22+00:00", "author_timezone": 0, "committer_date": "2002-11-23T00:12:22+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "dcc65693d78f065ec13d613056ae825b3d66d077" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 4, "insertions": 3, "lines": 7, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/command/run_f2py.py", "new_path": "scipy_distutils/command/run_f2py.py", "filename": "run_f2py.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -80,11 +80,10 @@ def f2py_sources (self, sources, ext):\n .pyf file from the Fortran files found in 'sources'.\n \"\"\"\n try:\n- if sys.modules.has_key('f2py2e'):\n- import f2py2e\n- else:\n- import f2py2e\n+ import f2py2e\n+ if not hasattr(self,'_f2py_sources_been_here'):\n self.announce('using F2PY %s' % (f2py2e.f2py2e.f2py_version))\n+ setattr(self,'_f2py_sources_been_here',1)\n except ImportError:\n print sys.exc_value\n raise F2pyNotFoundError,F2pyNotFoundError.__doc__\n", "added_lines": 3, "deleted_lines": 4, "source_code": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom distutils.cmd import Command\n#from scipy_distutils.core import Command\nfrom scipy_distutils.system_info import F2pyNotFoundError\nfrom scipy_distutils.misc_util import red_text,yellow_text\n\nimport re,os,sys,string\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\nuser_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?'\\\n '__user__[\\w_]*)',re.I).match\nfortran_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('no-wrap-functions', None,\n \"do not generate wrappers for Fortran functions,etc.\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.no_wrap_functions = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n if self.no_wrap_functions is not None:\n self.f2py_options.append('--no-wrap-functions')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n # XXX: might need also\n # build_flib = self.get_finalized_command('build_flib')\n # ...\n # for getting extra f2py_options that are specific to\n # a given fortran compiler.\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\" Walk the list of source files in `sources`, looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return the modified `sources` list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n If 'sources' contains no .pyf files, then create a temporary\n .pyf file from the Fortran files found in 'sources'.\n \"\"\"\n try:\n import f2py2e\n if not hasattr(self,'_f2py_sources_been_here'):\n self.announce('using F2PY %s' % (f2py2e.f2py2e.f2py_version))\n setattr(self,'_f2py_sources_been_here',1)\n except ImportError:\n print sys.exc_value\n raise F2pyNotFoundError,F2pyNotFoundError.__doc__\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # -f2pywrappers2.f90 [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains definitions for exactly\n # one extension module.\n\n target_dir = self.build_dir\n \n new_sources = []\n f2py_sources = []\n fortran_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n fortran90_target_ext = '-f2pywrappers2.f90'\n ext_name = string.split(ext.name,'.')[-1]\n\n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = module_name_re(line)\n if m:\n if user_module_name_re(line): # skip *__user__* names\n continue\n base = m.group('name')\n break\n f.close()\n if ext.name == 'untitled':\n ext.name = base\n if base != ext_name:\n # XXX: Should we do here more than just warn?\n self.warn(red_text('%s provides %s but this extension is %s' \\\n % (source,`base`,`ext_name`)))\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,\n base+fortran_target_ext)\n fortran90_target_file = os.path.join(target_dir,\n base+fortran90_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = [fortran_target_file,\n fortran90_target_file]\n elif fortran_ext_re(source_ext):\n fortran_sources.append(source) \n else:\n new_sources.append(source)\n\n if not (f2py_sources or fortran_sources):\n return new_sources\n\n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n if not f2py_sources:\n # creating a temporary pyf file from fortran sources\n pyf_target = os.path.join(target_dir,ext_name+'.pyf')\n pyf_target_file = os.path.join(target_dir,ext_name+target_ext)\n f2py_opts2 = ['-m',ext_name,'-h',pyf_target,'--overwrite-signature']\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_opts2.append('--quiet')\n for source in fortran_sources:\n if newer(source,pyf_target) or self.force:\n self.announce(yellow_text(\"f2py %s\" % \\\n string.join(fortran_sources + f2py_opts2,' ')))\n f2py2e.run_main(fortran_sources + f2py_opts2)\n break\n pyf_fortran_target_file = os.path.join(target_dir,\n ext_name+fortran_target_ext)\n pyf_fortran90_target_file = os.path.join(target_dir,\n ext_name+fortran90_target_ext)\n f2py_sources.append(pyf_target)\n f2py_targets[pyf_target] = pyf_target_file\n f2py_fortran_targets[pyf_target] = [pyf_fortran_target_file,\n pyf_fortran90_target_file]\n\n new_sources.extend(fortran_sources)\n\n if len(f2py_sources) > 1:\n self.warn(red_text('Only one .pyf file can be used per Extension'\\\n ' but got %s.' % (len(f2py_sources))))\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n if ext.f2py_options != self.f2py_options:\n f2py_options = ext.f2py_options + self.f2py_options\n else:\n f2py_options = self.f2py_options[:]\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_options.append('--quiet')\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target) or self.force:\n self.announce(yellow_text(\"f2py %s\" % \\\n string.join(f2py_options+[source],' ')))\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n for fortran_target in f2py_fortran_targets[source]:\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n return new_sources\n\n # f2py_sources ()\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n\n for file in ext.sources:\n if fortran_ext_re(file):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.distribution.fortran_libraries is None:\n self.distribution.fortran_libraries = []\n fortran_libraries = self.distribution.fortran_libraries\n\n ext_name = string.split(ext.name,'.')[-1]\n name = ext_name\n flib = None\n for n,d in fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {}\n fortran_libraries.append((name,flib))\n \n flib.setdefault('sources',[]).extend(f_files)\n flib.setdefault('define_macros',[]).extend(ext.define_macros)\n flib.setdefault('undef_macros',[]).extend(ext.undef_macros)\n flib.setdefault('include_dirs',[]).extend(ext.include_dirs)\n \n# class run_f2py\n", "source_code_before": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom distutils.cmd import Command\n#from scipy_distutils.core import Command\nfrom scipy_distutils.system_info import F2pyNotFoundError\nfrom scipy_distutils.misc_util import red_text,yellow_text\n\nimport re,os,sys,string\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\nuser_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?'\\\n '__user__[\\w_]*)',re.I).match\nfortran_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('no-wrap-functions', None,\n \"do not generate wrappers for Fortran functions,etc.\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.no_wrap_functions = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n if self.no_wrap_functions is not None:\n self.f2py_options.append('--no-wrap-functions')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n # XXX: might need also\n # build_flib = self.get_finalized_command('build_flib')\n # ...\n # for getting extra f2py_options that are specific to\n # a given fortran compiler.\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\" Walk the list of source files in `sources`, looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return the modified `sources` list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n If 'sources' contains no .pyf files, then create a temporary\n .pyf file from the Fortran files found in 'sources'.\n \"\"\"\n try:\n if sys.modules.has_key('f2py2e'):\n import f2py2e\n else:\n import f2py2e\n self.announce('using F2PY %s' % (f2py2e.f2py2e.f2py_version))\n except ImportError:\n print sys.exc_value\n raise F2pyNotFoundError,F2pyNotFoundError.__doc__\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # -f2pywrappers2.f90 [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains definitions for exactly\n # one extension module.\n\n target_dir = self.build_dir\n \n new_sources = []\n f2py_sources = []\n fortran_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n fortran90_target_ext = '-f2pywrappers2.f90'\n ext_name = string.split(ext.name,'.')[-1]\n\n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = module_name_re(line)\n if m:\n if user_module_name_re(line): # skip *__user__* names\n continue\n base = m.group('name')\n break\n f.close()\n if ext.name == 'untitled':\n ext.name = base\n if base != ext_name:\n # XXX: Should we do here more than just warn?\n self.warn(red_text('%s provides %s but this extension is %s' \\\n % (source,`base`,`ext_name`)))\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,\n base+fortran_target_ext)\n fortran90_target_file = os.path.join(target_dir,\n base+fortran90_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = [fortran_target_file,\n fortran90_target_file]\n elif fortran_ext_re(source_ext):\n fortran_sources.append(source) \n else:\n new_sources.append(source)\n\n if not (f2py_sources or fortran_sources):\n return new_sources\n\n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n if not f2py_sources:\n # creating a temporary pyf file from fortran sources\n pyf_target = os.path.join(target_dir,ext_name+'.pyf')\n pyf_target_file = os.path.join(target_dir,ext_name+target_ext)\n f2py_opts2 = ['-m',ext_name,'-h',pyf_target,'--overwrite-signature']\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_opts2.append('--quiet')\n for source in fortran_sources:\n if newer(source,pyf_target) or self.force:\n self.announce(yellow_text(\"f2py %s\" % \\\n string.join(fortran_sources + f2py_opts2,' ')))\n f2py2e.run_main(fortran_sources + f2py_opts2)\n break\n pyf_fortran_target_file = os.path.join(target_dir,\n ext_name+fortran_target_ext)\n pyf_fortran90_target_file = os.path.join(target_dir,\n ext_name+fortran90_target_ext)\n f2py_sources.append(pyf_target)\n f2py_targets[pyf_target] = pyf_target_file\n f2py_fortran_targets[pyf_target] = [pyf_fortran_target_file,\n pyf_fortran90_target_file]\n\n new_sources.extend(fortran_sources)\n\n if len(f2py_sources) > 1:\n self.warn(red_text('Only one .pyf file can be used per Extension'\\\n ' but got %s.' % (len(f2py_sources))))\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n if ext.f2py_options != self.f2py_options:\n f2py_options = ext.f2py_options + self.f2py_options\n else:\n f2py_options = self.f2py_options[:]\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_options.append('--quiet')\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target) or self.force:\n self.announce(yellow_text(\"f2py %s\" % \\\n string.join(f2py_options+[source],' ')))\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n for fortran_target in f2py_fortran_targets[source]:\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n return new_sources\n\n # f2py_sources ()\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n\n for file in ext.sources:\n if fortran_ext_re(file):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.distribution.fortran_libraries is None:\n self.distribution.fortran_libraries = []\n fortran_libraries = self.distribution.fortran_libraries\n\n ext_name = string.split(ext.name,'.')[-1]\n name = ext_name\n flib = None\n for n,d in fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {}\n fortran_libraries.append((name,flib))\n \n flib.setdefault('sources',[]).extend(f_files)\n flib.setdefault('define_macros',[]).extend(ext.define_macros)\n flib.setdefault('undef_macros',[]).extend(ext.undef_macros)\n flib.setdefault('include_dirs',[]).extend(ext.include_dirs)\n \n# class run_f2py\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 38, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 9, "complexity": 3, "token_count": 69, "parameters": [ "self" ], "start_line": 47, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 61, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 101, "complexity": 28, "token_count": 722, "parameters": [ "self", "sources", "ext" ], "start_line": 73, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 28, "complexity": 8, "token_count": 196, "parameters": [ "self", "ext" ], "start_line": 210, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 38, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 9, "complexity": 3, "token_count": 69, "parameters": [ "self" ], "start_line": 47, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 61, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 102, "complexity": 28, "token_count": 719, "parameters": [ "self", "sources", "ext" ], "start_line": 73, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 135, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 28, "complexity": 8, "token_count": 196, "parameters": [ "self", "ext" ], "start_line": 211, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 101, "complexity": 28, "token_count": 722, "parameters": [ "self", "sources", "ext" ], "start_line": 73, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 1 } ], "nloc": 175, "complexity": 43, "token_count": 1198, "diff_parsed": { "added": [ " import f2py2e", " if not hasattr(self,'_f2py_sources_been_here'):", " setattr(self,'_f2py_sources_been_here',1)" ], "deleted": [ " if sys.modules.has_key('f2py2e'):", " import f2py2e", " else:", " import f2py2e" ] } } ] }, { "hash": "7867841c263eb865a1e61d2dff202c27706e507a", "msg": "Impl. memusage() for Linux. memusage is useful for detecting memory leaks", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-11-25T07:38:35+00:00", "author_timezone": 0, "committer_date": "2002-11-25T07:38:35+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "8003ebb85561bacfcfbe4e374a739325e3a80733" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 0, "insertions": 14, "lines": 14, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_test/testing.py", "new_path": "scipy_test/testing.py", "filename": "testing.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -56,6 +56,17 @@ def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n+\n+ def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n+ \"\"\" Return virtual memory size in bytes of the running python.\n+ \"\"\"\n+ try:\n+ f=open(_proc_pid_stat,'r')\n+ l = f.readline().split(' ')\n+ f.close()\n+ return int(l[22])\n+ except:\n+ return\n else:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n@@ -65,6 +76,9 @@ def jiffies(_load_time=time.time()):\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n \n+ def memusage():\n+ \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n+ return\n \n __all__.append('ScipyTestCase')\n class ScipyTestCase (unittest.TestCase):\n", "added_lines": 14, "deleted_lines": 0, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\n__all__.append('set_package_path')\ndef set_package_path():\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n del sys.path[0]\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(1)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i//test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n del sys.path[0]\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(1)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i' under the base build directory. We only use one of\n+ # them for a given distribution, though --\n+ if self.build_purelib is None:\n+ self.build_purelib = os.path.join(self.build_base, 'lib')\n+ if self.build_platlib is None:\n+ self.build_platlib = os.path.join(self.build_base,\n+ 'lib' + plat_specifier)\n+\n+ # 'build_lib' is the actual directory that we will use for this\n+ # particular module distribution -- if user didn't supply it, pick\n+ # one of 'build_purelib' or 'build_platlib'.\n+ if self.build_lib is None:\n+ if self.distribution.ext_modules:\n+ self.build_lib = self.build_platlib\n+ else:\n+ self.build_lib = self.build_purelib\n+\n+ # 'build_temp' -- temporary directory for compiler turds,\n+ # \"build/temp.\"\n+ if self.build_temp is None:\n+ self.build_temp = os.path.join(self.build_base,\n+ 'temp' + plat_specifier)\n+ if self.build_scripts is None:\n+ self.build_scripts = os.path.join(self.build_base,\n+ 'scripts-' + sys.version[0:3])\n+\n+ # finalize_options ()\n", "added_lines": 60, "deleted_lines": 0, "source_code": "# Need to override the build command to include building of fortran libraries\n# This class must be used as the entry for the build key in the cmdclass\n# dictionary which is given to the setup command.\n\nimport sys, os\nfrom distutils import util\nfrom distutils.command.build import build as old_build\n\nclass build(old_build):\n def has_f_libraries(self):\n return self.distribution.has_f_libraries()\n def has_f2py_sources(self):\n return self.distribution.has_f2py_sources()\n\n sub_commands = [('build_py', old_build.has_pure_modules),\n ('build_clib', old_build.has_c_libraries),\n ('run_f2py', has_f2py_sources), # new feature\n ('build_flib', has_f_libraries), # new feature\n ('build_ext', old_build.has_ext_modules),\n ('build_scripts', old_build.has_scripts),\n ]\n\n def get_plat_specifier(self):\n \"\"\" Return a unique string that identifies this platform.\n The string is used to build path names and contains no\n spaces or control characters. (we hope)\n \"\"\" \n plat_specifier = \".%s-%s\" % (util.get_platform(), sys.version[0:3])\n \n #--------------------------------------------------------------------\n # get rid of spaces -- added for OS X support.\n #--------------------------------------------------------------------\n plat_specifier = plat_specifier.replace(' ','')\n \n #--------------------------------------------------------------------\n # make lower case ?? is this desired'\n #--------------------------------------------------------------------\n #plat_specifier = plat_specifier.lower()\n \n return plat_specifier\n \n def finalize_options (self):\n\n #--------------------------------------------------------------------\n # This line is re-factored to a function -- everything else in the\n # function is identical to the finalize_options function in the\n # standard distutils build.\n #--------------------------------------------------------------------\n #plat_specifier = \".%s-%s\" % (get_platform(), sys.version[0:3]) \n plat_specifier = self.get_plat_specifier()\n \n # 'build_purelib' and 'build_platlib' just default to 'lib' and\n # 'lib.' under the base build directory. We only use one of\n # them for a given distribution, though --\n if self.build_purelib is None:\n self.build_purelib = os.path.join(self.build_base, 'lib')\n if self.build_platlib is None:\n self.build_platlib = os.path.join(self.build_base,\n 'lib' + plat_specifier)\n\n # 'build_lib' is the actual directory that we will use for this\n # particular module distribution -- if user didn't supply it, pick\n # one of 'build_purelib' or 'build_platlib'.\n if self.build_lib is None:\n if self.distribution.ext_modules:\n self.build_lib = self.build_platlib\n else:\n self.build_lib = self.build_purelib\n\n # 'build_temp' -- temporary directory for compiler turds,\n # \"build/temp.\"\n if self.build_temp is None:\n self.build_temp = os.path.join(self.build_base,\n 'temp' + plat_specifier)\n if self.build_scripts is None:\n self.build_scripts = os.path.join(self.build_base,\n 'scripts-' + sys.version[0:3])\n\n # finalize_options ()\n", "source_code_before": "# Need to override the build command to include building of fortran libraries\n# This class must be used as the entry for the build key in the cmdclass\n# dictionary which is given to the setup command.\n\nfrom distutils.command.build import build as old_build\n\nclass build(old_build):\n def has_f_libraries(self):\n return self.distribution.has_f_libraries()\n def has_f2py_sources(self):\n return self.distribution.has_f2py_sources()\n\n sub_commands = [('build_py', old_build.has_pure_modules),\n ('build_clib', old_build.has_c_libraries),\n ('run_f2py', has_f2py_sources), # new feature\n ('build_flib', has_f_libraries), # new feature\n ('build_ext', old_build.has_ext_modules),\n ('build_scripts', old_build.has_scripts),\n ]\n", "methods": [ { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 10, "end_line": 11, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self )", "filename": "build.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 12, "end_line": 13, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_plat_specifier", "long_name": "get_plat_specifier( self )", "filename": "build.py", "nloc": 4, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 23, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build.py", "nloc": 18, "complexity": 7, "token_count": 147, "parameters": [ "self" ], "start_line": 42, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 } ], "methods_before": [ { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 8, "end_line": 9, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self )", "filename": "build.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 10, "end_line": 11, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "get_plat_specifier", "long_name": "get_plat_specifier( self )", "filename": "build.py", "nloc": 4, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 23, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build.py", "nloc": 18, "complexity": 7, "token_count": 147, "parameters": [ "self" ], "start_line": 42, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 } ], "nloc": 37, "complexity": 10, "token_count": 287, "diff_parsed": { "added": [ "import sys, os", "from distutils import util", "", " def get_plat_specifier(self):", " \"\"\" Return a unique string that identifies this platform.", " The string is used to build path names and contains no", " spaces or control characters. (we hope)", " \"\"\"", " plat_specifier = \".%s-%s\" % (util.get_platform(), sys.version[0:3])", "", " #--------------------------------------------------------------------", " # get rid of spaces -- added for OS X support.", " #--------------------------------------------------------------------", " plat_specifier = plat_specifier.replace(' ','')", "", " #--------------------------------------------------------------------", " # make lower case ?? is this desired'", " #--------------------------------------------------------------------", " #plat_specifier = plat_specifier.lower()", "", " return plat_specifier", "", " def finalize_options (self):", "", " #--------------------------------------------------------------------", " # This line is re-factored to a function -- everything else in the", " # function is identical to the finalize_options function in the", " # standard distutils build.", " #--------------------------------------------------------------------", " #plat_specifier = \".%s-%s\" % (get_platform(), sys.version[0:3])", " plat_specifier = self.get_plat_specifier()", "", " # 'build_purelib' and 'build_platlib' just default to 'lib' and", " # 'lib.' under the base build directory. We only use one of", " # them for a given distribution, though --", " if self.build_purelib is None:", " self.build_purelib = os.path.join(self.build_base, 'lib')", " if self.build_platlib is None:", " self.build_platlib = os.path.join(self.build_base,", " 'lib' + plat_specifier)", "", " # 'build_lib' is the actual directory that we will use for this", " # particular module distribution -- if user didn't supply it, pick", " # one of 'build_purelib' or 'build_platlib'.", " if self.build_lib is None:", " if self.distribution.ext_modules:", " self.build_lib = self.build_platlib", " else:", " self.build_lib = self.build_purelib", "", " # 'build_temp' -- temporary directory for compiler turds,", " # \"build/temp.\"", " if self.build_temp is None:", " self.build_temp = os.path.join(self.build_base,", " 'temp' + plat_specifier)", " if self.build_scripts is None:", " self.build_scripts = os.path.join(self.build_base,", " 'scripts-' + sys.version[0:3])", "", " # finalize_options ()" ], "deleted": [] } } ] }, { "hash": "e3abc3304f7dec7c45843955520ffce3aa23e92c", "msg": "Backport to Python 2.1", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-12-18T19:05:51+00:00", "author_timezone": 0, "committer_date": "2002-12-18T19:05:51+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "f56ab8feb4b1d7b7907ab5f020ea9eede9e8ded1" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 1, "insertions": 3, "lines": 4, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/setup_scipy_distutils.py", "new_path": "scipy_distutils/setup_scipy_distutils.py", "filename": "setup_scipy_distutils.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -18,7 +18,9 @@ def configuration(parent_package=''):\n print 'scipy_distutils Version',scipy_distutils_version\n from distutils.core import setup\n config = configuration()\n- [config.__delitem__(k) for k,v in config.items() if not v]\n+ for k,v in config.items():\n+ if not v:\n+ del config[k]\n setup(version = scipy_distutils_version,\n description = \"Changes to distutils needed for SciPy \"\\\n \"-- mostly Fortran support\",\n", "added_lines": 3, "deleted_lines": 1, "source_code": "#!/usr/bin/env python\n\nimport os\nfrom misc_util import get_path, default_config_dict, dot_join\n\ndef configuration(parent_package=''):\n package = 'scipy_distutils'\n local_path = get_path(__name__)\n config = default_config_dict(package,parent_package)\n\n sub_package = dot_join(package,'command')\n config['packages'].append(dot_join(parent_package,sub_package))\n config['package_dir'][sub_package] = os.path.join(local_path,'command')\n return config\n\nif __name__ == '__main__':\n from scipy_distutils_version import scipy_distutils_version\n print 'scipy_distutils Version',scipy_distutils_version\n from distutils.core import setup\n config = configuration()\n for k,v in config.items():\n if not v:\n del config[k]\n setup(version = scipy_distutils_version,\n description = \"Changes to distutils needed for SciPy \"\\\n \"-- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n author_email = \"scipy-dev@scipy.org\",\n license = \"SciPy License (BSD Style)\",\n url = 'http://www.scipy.org',\n **config\n )\n", "source_code_before": "#!/usr/bin/env python\n\nimport os\nfrom misc_util import get_path, default_config_dict, dot_join\n\ndef configuration(parent_package=''):\n package = 'scipy_distutils'\n local_path = get_path(__name__)\n config = default_config_dict(package,parent_package)\n\n sub_package = dot_join(package,'command')\n config['packages'].append(dot_join(parent_package,sub_package))\n config['package_dir'][sub_package] = os.path.join(local_path,'command')\n return config\n\nif __name__ == '__main__':\n from scipy_distutils_version import scipy_distutils_version\n print 'scipy_distutils Version',scipy_distutils_version\n from distutils.core import setup\n config = configuration()\n [config.__delitem__(k) for k,v in config.items() if not v]\n setup(version = scipy_distutils_version,\n description = \"Changes to distutils needed for SciPy \"\\\n \"-- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n author_email = \"scipy-dev@scipy.org\",\n license = \"SciPy License (BSD Style)\",\n url = 'http://www.scipy.org',\n **config\n )\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_distutils.py", "nloc": 8, "complexity": 1, "token_count": 66, "parameters": [ "parent_package" ], "start_line": 6, "end_line": 14, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_distutils.py", "nloc": 8, "complexity": 1, "token_count": 66, "parameters": [ "parent_package" ], "start_line": 6, "end_line": 14, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 27, "complexity": 1, "token_count": 152, "diff_parsed": { "added": [ " for k,v in config.items():", " if not v:", " del config[k]" ], "deleted": [ " [config.__delitem__(k) for k,v in config.items() if not v]" ] } } ] }, { "hash": "49dfa817e7136027ec281d150f7918979d9f6f99", "msg": "made changes to use a PYTHONINCLUDE environment variable to search for\ninclude files during extension building.\n\n(1) include directories.\nDistutils knows to include files from /usr/include/python2.2 (or wherever it is installed) whenever building extension modules. Numeric installs its header files inside this directory when installed as root. However, when I install Numeric in /home/eric/linux, the header files are installed in /home/eric/linux/python2.2. Distutils doesn't know to look in hear for headers. To solve this, I'd have to hack all the setup.py files for modules that rely on Numeric to use my include_dirs. This isn't so nice.\n\nTo rectify the problem, scipy_distutils now searches for an environment variable called PYTHONINCLUDE that uses the same syntax as PYTHONPATH and PATH. If PYTHONINCLUDE is found, the directories listed in it are added to the include path during compilation of C/C++ files by build_ext.py and build_clib.py. On my machine, I specify\n\nexport PYTHONINCLUDE=$OSDIR/include/python2.2\n\nand all setup.py files work unaltered. I think this is a reasonable solution.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2002-12-19T07:15:18+00:00", "author_timezone": 0, "committer_date": "2002-12-19T07:15:18+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "e3abc3304f7dec7c45843955520ffce3aa23e92c" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 0, "insertions": 16, "lines": 16, "files": 3, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/command/build_clib.py", "new_path": "scipy_distutils/command/build_clib.py", "filename": "build_clib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -117,6 +117,9 @@ def finalize_options (self):\n self.include_dirs = string.split(self.include_dirs,\n os.pathsep)\n \n+ from scipy_distutils import misc_util\n+ extra_includes = misc_util.get_environ_include_dirs()\n+ self.include_dirs.extend(extra_includes)\n # XXX same as for build_ext -- what about 'self.define' and\n # 'self.undef' ?\n \n", "added_lines": 3, "deleted_lines": 0, "source_code": "\"\"\"distutils.command.build_clib\n\nImplements the Distutils 'build_clib' command, to build a C/C++ library\nthat is included in the module distribution and needed by an extension\nmodule.\"\"\"\n\n# created (an empty husk) 1999/12/18, Greg Ward\n# fleshed out 2000/02/03-04\n\n__revision__ = \"$Id$\"\n\n\n# XXX this module has *lots* of code ripped-off quite transparently from\n# build_ext.py -- not surprisingly really, as the work required to build\n# a static library from a collection of C source files is not really all\n# that different from what's required to build a shared object file from\n# a collection of C source files. Nevertheless, I haven't done the\n# necessary refactoring to account for the overlap in code between the\n# two modules, mainly because a number of subtle details changed in the\n# cut 'n paste. Sigh.\n\nimport os, string\nfrom glob import glob\nfrom types import *\nfrom distutils.core import Command\nfrom distutils.errors import *\nfrom distutils.sysconfig import customize_compiler\nfrom scipy_distutils.misc_util import red_text,yellow_text\n\ndef show_compilers ():\n from distutils.ccompiler import show_compilers\n show_compilers()\n\ndef get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for dir in directory_list:\n head = glob(os.path.join(dir,\"*.h\"))\n headers.extend(head)\n\n return headers\n\ndef get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for file in list_of_sources:\n dir = os.path.split(file)\n if dir[0] != '' and not dir[0] in direcs:\n direcs.append(dir[0])\n\n return direcs\n\n\nclass build_clib (Command):\n\n description = \"build C/C++ libraries used by Python extensions\"\n\n user_options = [\n ('build-clib', 'b',\n \"directory to build C/C++ libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('compiler=', 'c',\n \"specify the compiler type\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n self.build_clib = None\n self.build_temp = None\n\n # List of libraries to build\n self.libraries = None\n\n # Compilation options for all libraries\n self.include_dirs = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.compiler = None\n\n # initialize_options()\n\n\n def finalize_options (self):\n\n # This might be confusing: both build-clib and build-temp default\n # to build-temp as defined by the \"build\" command. This is because\n # I think that C libraries are really just temporary build\n # by-products, at least from the point of view of building Python\n # extensions -- but I want to keep my options open.\n self.set_undefined_options('build',\n ('build_temp', 'build_clib'),\n ('build_temp', 'build_temp'),\n ('compiler', 'compiler'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.libraries = self.distribution.libraries\n if self.libraries:\n self.check_library_list(self.libraries)\n\n if self.include_dirs is None:\n self.include_dirs = self.distribution.include_dirs or []\n if type(self.include_dirs) is StringType:\n self.include_dirs = string.split(self.include_dirs,\n os.pathsep)\n\n from scipy_distutils import misc_util\n extra_includes = misc_util.get_environ_include_dirs()\n self.include_dirs.extend(extra_includes)\n # XXX same as for build_ext -- what about 'self.define' and\n # 'self.undef' ?\n\n # finalize_options()\n\n\n def run (self):\n\n if not self.libraries:\n return\n\n # Yech -- this is cut 'n pasted from build_ext.py!\n from distutils.ccompiler import new_compiler\n self.compiler = new_compiler(compiler=self.compiler,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n customize_compiler(self.compiler)\n\n if self.include_dirs is not None:\n self.compiler.set_include_dirs(self.include_dirs)\n if self.define is not None:\n # 'define' option is a list of (name,value) tuples\n for (name,value) in self.define:\n self.compiler.define_macro(name, value)\n if self.undef is not None:\n for macro in self.undef:\n self.compiler.undefine_macro(macro)\n\n self.build_libraries(self.libraries)\n\n # run()\n\n\n def check_library_list (self, libraries):\n \"\"\"Ensure that the list of libraries (presumably provided as a\n command option 'libraries') is valid, i.e. it is a list of\n 2-tuples, where the tuples are (library_name, build_info_dict).\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\"\"\"\n\n # Yechh, blecch, ackk: this is ripped straight out of build_ext.py,\n # with only names changed to protect the innocent!\n\n if type(libraries) is not ListType:\n print type(libraries)\n raise DistutilsSetupError, \\\n \"'libraries' option must be a list of tuples\"\n\n for lib in libraries:\n if type(lib) is not TupleType and len(lib) != 2:\n raise DistutilsSetupError, \\\n \"each element of 'libraries' must a 2-tuple\"\n\n if type(lib[0]) is not StringType:\n raise DistutilsSetupError, \\\n \"first element of each tuple in 'libraries' \" + \\\n \"must be a string (the library name)\"\n if '/' in lib[0] or (os.sep != '/' and os.sep in lib[0]):\n raise DistutilsSetupError, \\\n (\"bad library name '%s': \" + \n \"may not contain directory separators\") % \\\n lib[0]\n\n if type(lib[1]) is not DictionaryType:\n raise DistutilsSetupError, \\\n \"second element of each tuple in 'libraries' \" + \\\n \"must be a dictionary (build info)\"\n # for lib\n\n # check_library_list ()\n\n\n def get_library_names (self):\n # Assume the library list is valid -- 'check_library_list()' is\n # called from 'finalize_options()', so it should be!\n\n if not self.libraries:\n return None\n\n lib_names = []\n for (lib_name, build_info) in self.libraries:\n lib_names.append(lib_name)\n return lib_names\n\n # get_library_names ()\n\n\n def get_source_files (self):\n self.check_library_list(self.libraries)\n filenames = []\n\n # Gets source files specified and any \"*.h\" header files in\n # those directories. \n for ext in self.libraries:\n filenames.extend(ext[1]['sources'])\n filenames.extend(get_headers(get_directories(ext[1]['sources'])))\n\n return filenames\n\n def build_libraries (self, libraries):\n\n compiler = self.compiler\n\n for (lib_name, build_info) in libraries:\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n\n self.announce(\"building '%s' library\" % lib_name)\n\n # First, compile the source code to object files in the library\n # directory. (This should probably change to putting object\n # files in a temporary build directory.)\n macros = build_info.get('macros')\n include_dirs = build_info.get('include_dirs')\n objects = self.compiler.compile(sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug)\n\n # Now \"link\" the object files together into a static library.\n # (On Unix at least, this isn't really linking -- it just\n # builds an archive. Whatever.)\n self.compiler.create_static_lib(objects, lib_name,\n output_dir=self.build_clib,\n debug=self.debug)\n #XXX: ranlib may not be available on non-GNU platforms.\n cmd = 'ranlib %s/lib%s.a' % (self.build_clib,lib_name)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n self.warn(red_text('Ignoring failure during build'\\\n ' (exit status = %s)'%failure))\n\n # for libraries\n\n # build_libraries ()\n\n# class build_lib\n", "source_code_before": "\"\"\"distutils.command.build_clib\n\nImplements the Distutils 'build_clib' command, to build a C/C++ library\nthat is included in the module distribution and needed by an extension\nmodule.\"\"\"\n\n# created (an empty husk) 1999/12/18, Greg Ward\n# fleshed out 2000/02/03-04\n\n__revision__ = \"$Id$\"\n\n\n# XXX this module has *lots* of code ripped-off quite transparently from\n# build_ext.py -- not surprisingly really, as the work required to build\n# a static library from a collection of C source files is not really all\n# that different from what's required to build a shared object file from\n# a collection of C source files. Nevertheless, I haven't done the\n# necessary refactoring to account for the overlap in code between the\n# two modules, mainly because a number of subtle details changed in the\n# cut 'n paste. Sigh.\n\nimport os, string\nfrom glob import glob\nfrom types import *\nfrom distutils.core import Command\nfrom distutils.errors import *\nfrom distutils.sysconfig import customize_compiler\nfrom scipy_distutils.misc_util import red_text,yellow_text\n\ndef show_compilers ():\n from distutils.ccompiler import show_compilers\n show_compilers()\n\ndef get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for dir in directory_list:\n head = glob(os.path.join(dir,\"*.h\"))\n headers.extend(head)\n\n return headers\n\ndef get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for file in list_of_sources:\n dir = os.path.split(file)\n if dir[0] != '' and not dir[0] in direcs:\n direcs.append(dir[0])\n\n return direcs\n\n\nclass build_clib (Command):\n\n description = \"build C/C++ libraries used by Python extensions\"\n\n user_options = [\n ('build-clib', 'b',\n \"directory to build C/C++ libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('compiler=', 'c',\n \"specify the compiler type\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n self.build_clib = None\n self.build_temp = None\n\n # List of libraries to build\n self.libraries = None\n\n # Compilation options for all libraries\n self.include_dirs = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.compiler = None\n\n # initialize_options()\n\n\n def finalize_options (self):\n\n # This might be confusing: both build-clib and build-temp default\n # to build-temp as defined by the \"build\" command. This is because\n # I think that C libraries are really just temporary build\n # by-products, at least from the point of view of building Python\n # extensions -- but I want to keep my options open.\n self.set_undefined_options('build',\n ('build_temp', 'build_clib'),\n ('build_temp', 'build_temp'),\n ('compiler', 'compiler'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.libraries = self.distribution.libraries\n if self.libraries:\n self.check_library_list(self.libraries)\n\n if self.include_dirs is None:\n self.include_dirs = self.distribution.include_dirs or []\n if type(self.include_dirs) is StringType:\n self.include_dirs = string.split(self.include_dirs,\n os.pathsep)\n\n # XXX same as for build_ext -- what about 'self.define' and\n # 'self.undef' ?\n\n # finalize_options()\n\n\n def run (self):\n\n if not self.libraries:\n return\n\n # Yech -- this is cut 'n pasted from build_ext.py!\n from distutils.ccompiler import new_compiler\n self.compiler = new_compiler(compiler=self.compiler,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n customize_compiler(self.compiler)\n\n if self.include_dirs is not None:\n self.compiler.set_include_dirs(self.include_dirs)\n if self.define is not None:\n # 'define' option is a list of (name,value) tuples\n for (name,value) in self.define:\n self.compiler.define_macro(name, value)\n if self.undef is not None:\n for macro in self.undef:\n self.compiler.undefine_macro(macro)\n\n self.build_libraries(self.libraries)\n\n # run()\n\n\n def check_library_list (self, libraries):\n \"\"\"Ensure that the list of libraries (presumably provided as a\n command option 'libraries') is valid, i.e. it is a list of\n 2-tuples, where the tuples are (library_name, build_info_dict).\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\"\"\"\n\n # Yechh, blecch, ackk: this is ripped straight out of build_ext.py,\n # with only names changed to protect the innocent!\n\n if type(libraries) is not ListType:\n print type(libraries)\n raise DistutilsSetupError, \\\n \"'libraries' option must be a list of tuples\"\n\n for lib in libraries:\n if type(lib) is not TupleType and len(lib) != 2:\n raise DistutilsSetupError, \\\n \"each element of 'libraries' must a 2-tuple\"\n\n if type(lib[0]) is not StringType:\n raise DistutilsSetupError, \\\n \"first element of each tuple in 'libraries' \" + \\\n \"must be a string (the library name)\"\n if '/' in lib[0] or (os.sep != '/' and os.sep in lib[0]):\n raise DistutilsSetupError, \\\n (\"bad library name '%s': \" + \n \"may not contain directory separators\") % \\\n lib[0]\n\n if type(lib[1]) is not DictionaryType:\n raise DistutilsSetupError, \\\n \"second element of each tuple in 'libraries' \" + \\\n \"must be a dictionary (build info)\"\n # for lib\n\n # check_library_list ()\n\n\n def get_library_names (self):\n # Assume the library list is valid -- 'check_library_list()' is\n # called from 'finalize_options()', so it should be!\n\n if not self.libraries:\n return None\n\n lib_names = []\n for (lib_name, build_info) in self.libraries:\n lib_names.append(lib_name)\n return lib_names\n\n # get_library_names ()\n\n\n def get_source_files (self):\n self.check_library_list(self.libraries)\n filenames = []\n\n # Gets source files specified and any \"*.h\" header files in\n # those directories. \n for ext in self.libraries:\n filenames.extend(ext[1]['sources'])\n filenames.extend(get_headers(get_directories(ext[1]['sources'])))\n\n return filenames\n\n def build_libraries (self, libraries):\n\n compiler = self.compiler\n\n for (lib_name, build_info) in libraries:\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n\n self.announce(\"building '%s' library\" % lib_name)\n\n # First, compile the source code to object files in the library\n # directory. (This should probably change to putting object\n # files in a temporary build directory.)\n macros = build_info.get('macros')\n include_dirs = build_info.get('include_dirs')\n objects = self.compiler.compile(sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug)\n\n # Now \"link\" the object files together into a static library.\n # (On Unix at least, this isn't really linking -- it just\n # builds an archive. Whatever.)\n self.compiler.create_static_lib(objects, lib_name,\n output_dir=self.build_clib,\n debug=self.debug)\n #XXX: ranlib may not be available on non-GNU platforms.\n cmd = 'ranlib %s/lib%s.a' % (self.build_clib,lib_name)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n self.warn(red_text('Ignoring failure during build'\\\n ' (exit status = %s)'%failure))\n\n # for libraries\n\n # build_libraries ()\n\n# class build_lib\n", "methods": [ { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_clib.py", "nloc": 3, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 30, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_headers", "long_name": "get_headers( directory_list )", "filename": "build_clib.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "directory_list" ], "start_line": 34, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "get_directories", "long_name": "get_directories( list_of_sources )", "filename": "build_clib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "list_of_sources" ], "start_line": 43, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_clib.py", "nloc": 10, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 78, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_clib.py", "nloc": 18, "complexity": 5, "token_count": 127, "parameters": [ "self" ], "start_line": 96, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_clib.py", "nloc": 18, "complexity": 7, "token_count": 132, "parameters": [ "self" ], "start_line": 129, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "check_library_list", "long_name": "check_library_list( self , libraries )", "filename": "build_clib.py", "nloc": 22, "complexity": 10, "token_count": 133, "parameters": [ "self", "libraries" ], "start_line": 157, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self )", "filename": "build_clib.py", "nloc": 7, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 196, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_clib.py", "nloc": 7, "complexity": 2, "token_count": 56, "parameters": [ "self" ], "start_line": 211, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , libraries )", "filename": "build_clib.py", "nloc": 27, "complexity": 5, "token_count": 185, "parameters": [ "self", "libraries" ], "start_line": 223, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 } ], "methods_before": [ { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_clib.py", "nloc": 3, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 30, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_headers", "long_name": "get_headers( directory_list )", "filename": "build_clib.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "directory_list" ], "start_line": 34, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "get_directories", "long_name": "get_directories( list_of_sources )", "filename": "build_clib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "list_of_sources" ], "start_line": 43, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_clib.py", "nloc": 10, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 78, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_clib.py", "nloc": 15, "complexity": 5, "token_count": 108, "parameters": [ "self" ], "start_line": 96, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_clib.py", "nloc": 18, "complexity": 7, "token_count": 132, "parameters": [ "self" ], "start_line": 126, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "check_library_list", "long_name": "check_library_list( self , libraries )", "filename": "build_clib.py", "nloc": 22, "complexity": 10, "token_count": 133, "parameters": [ "self", "libraries" ], "start_line": 154, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self )", "filename": "build_clib.py", "nloc": 7, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 193, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_clib.py", "nloc": 7, "complexity": 2, "token_count": 56, "parameters": [ "self" ], "start_line": 208, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , libraries )", "filename": "build_clib.py", "nloc": 27, "complexity": 5, "token_count": 185, "parameters": [ "self", "libraries" ], "start_line": 220, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_clib.py", "nloc": 18, "complexity": 5, "token_count": 127, "parameters": [ "self" ], "start_line": 96, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 } ], "nloc": 157, "complexity": 40, "token_count": 946, "diff_parsed": { "added": [ " from scipy_distutils import misc_util", " extra_includes = misc_util.get_environ_include_dirs()", " self.include_dirs.extend(extra_includes)" ], "deleted": [] } }, { "old_path": "scipy_distutils/command/build_ext.py", "new_path": "scipy_distutils/command/build_ext.py", "filename": "build_ext.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -8,9 +8,16 @@\n from distutils.command.build_ext import build_ext as old_build_ext\n \n from scipy_distutils.command.build_clib import get_headers,get_directories\n+from scipy_distutils import misc_util\n+\n \n class build_ext (old_build_ext):\n \n+ def finalize_options (self):\n+ old_build_ext.finalize_options(self)\n+ extra_includes = misc_util.get_environ_include_dirs()\n+ self.include_dirs.extend(extra_includes)\n+ \n def build_extension(self, ext):\n \n # The MSVC compiler doesn't have a linker_so attribute.\n", "added_lines": 7, "deleted_lines": 0, "source_code": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\nfrom scipy_distutils import misc_util\n\n\nclass build_ext (old_build_ext):\n\n def finalize_options (self):\n old_build_ext.finalize_options(self)\n extra_includes = misc_util.get_environ_include_dirs()\n self.include_dirs.extend(extra_includes)\n \n def build_extension(self, ext):\n \n # The MSVC compiler doesn't have a linker_so attribute.\n # Giving it a dummy one of None seems to do the trick.\n if not hasattr(self.compiler,'linker_so'):\n self.compiler.linker_so = None\n \n #XXX: anything else we need to save?\n save_linker_so = self.compiler.linker_so\n save_compiler_libs = self.compiler.libraries\n save_compiler_libs_dirs = self.compiler.library_dirs\n \n # support for building static fortran libraries\n need_f_libs = 0\n need_f_opts = getattr(ext,'need_fcompiler_opts',0)\n ext_name = string.split(ext.name,'.')[-1]\n\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n if build_flib.has_f_library(ext_name):\n need_f_libs = 1\n else:\n for lib_name in ext.libraries:\n if build_flib.has_f_library(lib_name):\n need_f_libs = 1\n break\n elif need_f_opts:\n build_flib = self.get_finalized_command('build_flib')\n\n #self.announce('%s %s needs fortran libraries %s %s'%(\\\n # ext.name,ext_name,need_f_libs,need_f_opts))\n \n if need_f_libs:\n if build_flib.has_f_library(ext_name) and \\\n ext_name not in ext.libraries:\n ext.libraries.insert(0,ext_name)\n for lib_name in ext.libraries[:]:\n ext.libraries.extend(build_flib.get_library_names(lib_name))\n ext.library_dirs.extend(build_flib.get_library_dirs(lib_name))\n ext.library_dirs.append(build_flib.build_flib)\n\n if need_f_libs or need_f_opts:\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []:\n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n\n linker_so = build_flib.fcompiler.get_linker_so()\n\n if linker_so is not None:\n if linker_so is not save_linker_so:\n self.announce('replacing linker_so %r with %r' %(\\\n ' '.join(save_linker_so),\n ' '.join(linker_so)))\n self.compiler.linker_so = linker_so\n l = build_flib.get_fcompiler_library_names()\n #l = self.compiler.libraries + l\n self.compiler.libraries = l\n l = ( self.compiler.library_dirs +\n build_flib.get_fcompiler_library_dirs() )\n self.compiler.library_dirs = l\n else:\n libs = build_flib.get_fcompiler_library_names()\n for lib in libs:\n if lib not in self.compiler.libraries:\n self.compiler.libraries.append(lib)\n\n lib_dirs = build_flib.get_fcompiler_library_dirs()\n for lib_dir in lib_dirs:\n if lib_dir not in self.compiler.library_dirs:\n self.compiler.library_dirs.append(lib_dir)\n\n # end of fortran source support\n res = old_build_ext.build_extension(self,ext)\n\n if save_linker_so is not self.compiler.linker_so:\n self.announce('restoring linker_so %r' % ' '.join(save_linker_so))\n self.compiler.linker_so = save_linker_so\n self.compiler.libraries = save_compiler_libs\n self.compiler.library_dirs = save_compiler_libs_dirs\n\n return res\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n \n", "source_code_before": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\n\nclass build_ext (old_build_ext):\n\n def build_extension(self, ext):\n \n # The MSVC compiler doesn't have a linker_so attribute.\n # Giving it a dummy one of None seems to do the trick.\n if not hasattr(self.compiler,'linker_so'):\n self.compiler.linker_so = None\n \n #XXX: anything else we need to save?\n save_linker_so = self.compiler.linker_so\n save_compiler_libs = self.compiler.libraries\n save_compiler_libs_dirs = self.compiler.library_dirs\n \n # support for building static fortran libraries\n need_f_libs = 0\n need_f_opts = getattr(ext,'need_fcompiler_opts',0)\n ext_name = string.split(ext.name,'.')[-1]\n\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n if build_flib.has_f_library(ext_name):\n need_f_libs = 1\n else:\n for lib_name in ext.libraries:\n if build_flib.has_f_library(lib_name):\n need_f_libs = 1\n break\n elif need_f_opts:\n build_flib = self.get_finalized_command('build_flib')\n\n #self.announce('%s %s needs fortran libraries %s %s'%(\\\n # ext.name,ext_name,need_f_libs,need_f_opts))\n \n if need_f_libs:\n if build_flib.has_f_library(ext_name) and \\\n ext_name not in ext.libraries:\n ext.libraries.insert(0,ext_name)\n for lib_name in ext.libraries[:]:\n ext.libraries.extend(build_flib.get_library_names(lib_name))\n ext.library_dirs.extend(build_flib.get_library_dirs(lib_name))\n ext.library_dirs.append(build_flib.build_flib)\n\n if need_f_libs or need_f_opts:\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []:\n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n\n linker_so = build_flib.fcompiler.get_linker_so()\n\n if linker_so is not None:\n if linker_so is not save_linker_so:\n self.announce('replacing linker_so %r with %r' %(\\\n ' '.join(save_linker_so),\n ' '.join(linker_so)))\n self.compiler.linker_so = linker_so\n l = build_flib.get_fcompiler_library_names()\n #l = self.compiler.libraries + l\n self.compiler.libraries = l\n l = ( self.compiler.library_dirs +\n build_flib.get_fcompiler_library_dirs() )\n self.compiler.library_dirs = l\n else:\n libs = build_flib.get_fcompiler_library_names()\n for lib in libs:\n if lib not in self.compiler.libraries:\n self.compiler.libraries.append(lib)\n\n lib_dirs = build_flib.get_fcompiler_library_dirs()\n for lib_dir in lib_dirs:\n if lib_dir not in self.compiler.library_dirs:\n self.compiler.library_dirs.append(lib_dir)\n\n # end of fortran source support\n res = old_build_ext.build_extension(self,ext)\n\n if save_linker_so is not self.compiler.linker_so:\n self.announce('restoring linker_so %r' % ' '.join(save_linker_so))\n self.compiler.linker_so = save_linker_so\n self.compiler.libraries = save_compiler_libs\n self.compiler.library_dirs = save_compiler_libs_dirs\n\n return res\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n \n", "methods": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 16, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 65, "complexity": 23, "token_count": 476, "parameters": [ "self", "ext" ], "start_line": 21, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 87, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 109, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "methods_before": [ { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 65, "complexity": 23, "token_count": 476, "parameters": [ "self", "ext" ], "start_line": 14, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 87, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 102, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 16, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 } ], "nloc": 85, "complexity": 26, "token_count": 600, "diff_parsed": { "added": [ "from scipy_distutils import misc_util", "", " def finalize_options (self):", " old_build_ext.finalize_options(self)", " extra_includes = misc_util.get_environ_include_dirs()", " self.include_dirs.extend(extra_includes)", "" ], "deleted": [] } }, { "old_path": "scipy_distutils/misc_util.py", "new_path": "scipy_distutils/misc_util.py", "filename": "misc_util.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -359,3 +359,9 @@ def fortran_library_item(lib_name,\n build_info[key] = value\n \n return (lib_name,build_info)\n+\n+def get_environ_include_dirs():\n+ includes = []\n+ if os.environ.has_key('PYTHONINCLUDE'):\n+ includes = os.environ['PYTHONINCLUDE'].split(os.pathsep)\n+ return includes\n\\ No newline at end of file\n", "added_lines": 6, "deleted_lines": 0, "source_code": "import os,sys,string\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if not hasattr(sys.stdout,'isatty') or not sys.stdout.isatty(): \n return 0\n try:\n import curses\n curses.setupterm()\n return (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None))\n except: pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\nclass PostponedException:\n \"\"\"Postpone exception until an attempt is made to use a resource.\"\"\"\n #Example usage:\n # try: import foo\n # except ImportError: foo = PostponedException()\n __all__ = []\n def __init__(self):\n self._info = sys.exc_info()[:2]\n self.__doc__ = '%s: %s' % tuple(self._info)\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n\n#XXX: update_version and related functions are not used\n# in the scipy project. Should we remove them?\ndef update_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n overwrite_version_py = 1):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . If the version information is different from the one\n found in the /__version__.py file, update_version updates\n the file automatically. The version information will be always\n increasing in time.\n If CVS tree does not exist (e.g. as in distribution packages),\n return the version string found from /__version__.py.\n If no version information is available, return None.\n\n Default version string is in the form\n\n ..--\n\n The items have the following meanings:\n\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n minor - indicates the changes in micro value (files are added\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n\n \"\"\"\n # Issues:\n # *** Recommend or not to add __version__.py file to CVS\n # repository? If it is in CVS, then when commiting, the\n # version information will change, but __version__.py\n # is commited with the old version information. To get\n # __version__.py also up to date, a second commit of the\n # __version__.py file is required after you re-run\n # update_version(..). To summarize:\n # 1) cvs commit ...\n # 2) python setup.py # that should call update_version\n # 3) cvs commit -m \"updating version\" __version__.py\n\n release_level_map = {'alpha':0,\n 'beta':1,\n 'canditate':2,\n 'final':3}\n release_level_value = release_level_map.get(release_level)\n if release_level_value is None:\n print 'Warning: release_level=%s is not %s'\\\n % (release_level,\n string.join(release_level_map.keys(),','))\n\n cwd = os.getcwd()\n os.chdir(path)\n try:\n version_module = __import__('__version__')\n reload(version_module)\n old_version_info = version_module.version_info\n old_version = version_module.version\n except:\n print sys.exc_value\n old_version_info = None\n old_version = None\n os.chdir(cwd)\n\n cvs_revs = get_cvs_revision(path)\n if cvs_revs is None:\n return old_version\n\n minor = 1\n micro,serial = cvs_revs\n if old_version_info is not None:\n minor = old_version_info[1]\n old_release_level_value = release_level_map.get(old_version_info[3])\n if micro != old_version_info[2]: # files have beed added or removed\n minor = minor + 1\n if major is None:\n major = old_version_info[0]\n if old_release_level_value is not None:\n if old_release_level_value > release_level_value:\n major = major + 1\n if major is None:\n major = 0\n\n version_info = (major,minor,micro,release_level,serial)\n version_dict = {'major':major,'minor':minor,'micro':micro,\n 'release_level':release_level,'serial':serial\n }\n version = version_template % version_dict\n\n if version_info != old_version_info:\n print 'version increase detected: %s -> %s'%(old_version,version)\n version_file = os.path.join(path,'__version__.py')\n if not overwrite_version_py:\n print 'keeping %s with old version, returing new version' \\\n % (version_file)\n return version\n print 'updating version in %s' % version_file\n version_file = os.path.abspath(version_file)\n f = open(version_file,'w')\n f.write('# This file is automatically updated with update_version\\n'\\\n '# function from scipy_distutils.misc_util.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n f.close()\n return version\n\ndef get_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n ):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . Does not change /__version__.py.\n See also update_version(..) function.\n \"\"\"\n return update_version(release_level = release_level,path = path,\n version_template = version_template,\n major = major,overwrite_version_py = 0)\n\n\ndef get_cvs_revision(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n tree (this is often true, but not always) and the second number\n characterizes the changes in these files.\n If /CVS/Entries is not existing then return None.\n \"\"\"\n entries_file = os.path.join(path,'CVS','Entries')\n if os.path.exists(entries_file):\n rev1,rev2 = 0,0\n for line in open(entries_file).readlines():\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n d1,d2 = get_cvs_revision(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n\t\tlast_numbers = map(eval,string.split(items[2],'.')[-2:])\n\t\tif len(last_numbers)==2:\n\t\t d1,d2 = last_numbers\n\t\telse: # this is when 'cvs add' but not yet 'cvs commit'\n\t\t d1,d2 = 0,0\n else:\n continue\n rev1,rev2 = rev1+d1,rev2+d2\n return rev1,rev2\n\ndef get_path(mod_name):\n \"\"\" This function makes sure installation is done from the\n correct directory no matter if it is installed from the\n command line or from another package or run_setup function.\n \n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n return d\n \ndef add_local_to_path(mod_name):\n local_path = get_path(mod_name)\n sys.path.insert(0,local_path)\n\n\ndef add_grandparent_to_path(mod_name):\n local_path = get_path(mod_name)\n gp_dir = os.path.split(local_path)[0]\n sys.path.insert(0,gp_dir)\n\ndef restore_path():\n del sys.path[0]\n\ndef append_package_dir_to_path(package_name): \n \"\"\" Search for a directory with package_name and append it to PYTHONPATH\n \n The local directory is searched first and then the parent directory.\n \"\"\"\n # first see if it is in the current path\n # then try parent. If it isn't found, fail silently\n # and let the import error occur.\n \n # not an easy way to clean up after this...\n import os,sys\n if os.path.exists(package_name):\n sys.path.append(package_name)\n elif os.path.exists(os.path.join('..',package_name)):\n sys.path.append(os.path.join('..',package_name))\n\ndef get_package_config(package_name):\n \"\"\" grab the configuration info from the setup_xxx.py file\n in a package directory. The package directory is searched\n from the current directory, so setting the path to the\n setup.py file directory of the file calling this is usually\n needed to get search the path correct.\n \"\"\"\n append_package_dir_to_path(package_name)\n mod = __import__('setup_'+package_name)\n config = mod.configuration()\n return config\n\ndef package_config(primary,dependencies=[]):\n \"\"\" Create a configuration dictionary ready for setup.py from\n a list of primary and dependent package names. Each\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n has a configuration() function in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n config.extend([get_package_config(x) for x in dependencies]) \n config_dict = merge_config_dicts(config)\n return config_dict\n \nlist_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\ndict_keys = ['package_dir']\n\ndef default_config_dict(name = None, parent_name = None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n\n full_name = dot_join(parent_name,name)\n\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n # Todo: implement check for this assumption.\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n test_path = os.path.join(local_path,'tests')\n if 0 and name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n if os.path.exists(test_path):\n d['packages'].append(dot_join(full_name,'tests'))\n d['package_dir'][dot_join(full_name,'tests')] = test_path\n d['name'] = full_name\n if 0 and not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n p,'scipy_distutils'))\n if os.path.exists(dir_name):\n d['packages'].append('scipy_distutils')\n d['packages'].append('scipy_distutils.command')\n d['package_dir']['scipy_distutils'] = dir_name\n break\n return d\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef merge_config_dicts(config_list):\n result = default_config_dict()\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef dot_join(*args):\n return string.join(filter(None,args),'.')\n\ndef fortran_library_item(lib_name,\n sources,\n **attrs\n ):\n \"\"\" Helper function for creating fortran_libraries items. \"\"\"\n build_info = {'sources':sources}\n known_attrs = ['module_files','module_dirs',\n 'libraries','library_dirs']\n for key,value in attrs.items():\n if key not in known_attrs:\n raise TypeError,\\\n \"fortran_library_item() got an unexpected keyword \"\\\n \"argument '%s'\" % key\n build_info[key] = value\n \n return (lib_name,build_info)\n\ndef get_environ_include_dirs():\n includes = []\n if os.environ.has_key('PYTHONINCLUDE'):\n includes = os.environ['PYTHONINCLUDE'].split(os.pathsep)\n return includes", "source_code_before": "import os,sys,string\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if not hasattr(sys.stdout,'isatty') or not sys.stdout.isatty(): \n return 0\n try:\n import curses\n curses.setupterm()\n return (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None))\n except: pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\nclass PostponedException:\n \"\"\"Postpone exception until an attempt is made to use a resource.\"\"\"\n #Example usage:\n # try: import foo\n # except ImportError: foo = PostponedException()\n __all__ = []\n def __init__(self):\n self._info = sys.exc_info()[:2]\n self.__doc__ = '%s: %s' % tuple(self._info)\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n\n#XXX: update_version and related functions are not used\n# in the scipy project. Should we remove them?\ndef update_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n overwrite_version_py = 1):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . If the version information is different from the one\n found in the /__version__.py file, update_version updates\n the file automatically. The version information will be always\n increasing in time.\n If CVS tree does not exist (e.g. as in distribution packages),\n return the version string found from /__version__.py.\n If no version information is available, return None.\n\n Default version string is in the form\n\n ..--\n\n The items have the following meanings:\n\n serial - shows cumulative changes in all files in the CVS\n repository\n micro - a number that is equivalent to the number of files\n minor - indicates the changes in micro value (files are added\n or removed)\n release_level - is alpha, beta, canditate, or final\n major - indicates changes in release_level.\n\n \"\"\"\n # Issues:\n # *** Recommend or not to add __version__.py file to CVS\n # repository? If it is in CVS, then when commiting, the\n # version information will change, but __version__.py\n # is commited with the old version information. To get\n # __version__.py also up to date, a second commit of the\n # __version__.py file is required after you re-run\n # update_version(..). To summarize:\n # 1) cvs commit ...\n # 2) python setup.py # that should call update_version\n # 3) cvs commit -m \"updating version\" __version__.py\n\n release_level_map = {'alpha':0,\n 'beta':1,\n 'canditate':2,\n 'final':3}\n release_level_value = release_level_map.get(release_level)\n if release_level_value is None:\n print 'Warning: release_level=%s is not %s'\\\n % (release_level,\n string.join(release_level_map.keys(),','))\n\n cwd = os.getcwd()\n os.chdir(path)\n try:\n version_module = __import__('__version__')\n reload(version_module)\n old_version_info = version_module.version_info\n old_version = version_module.version\n except:\n print sys.exc_value\n old_version_info = None\n old_version = None\n os.chdir(cwd)\n\n cvs_revs = get_cvs_revision(path)\n if cvs_revs is None:\n return old_version\n\n minor = 1\n micro,serial = cvs_revs\n if old_version_info is not None:\n minor = old_version_info[1]\n old_release_level_value = release_level_map.get(old_version_info[3])\n if micro != old_version_info[2]: # files have beed added or removed\n minor = minor + 1\n if major is None:\n major = old_version_info[0]\n if old_release_level_value is not None:\n if old_release_level_value > release_level_value:\n major = major + 1\n if major is None:\n major = 0\n\n version_info = (major,minor,micro,release_level,serial)\n version_dict = {'major':major,'minor':minor,'micro':micro,\n 'release_level':release_level,'serial':serial\n }\n version = version_template % version_dict\n\n if version_info != old_version_info:\n print 'version increase detected: %s -> %s'%(old_version,version)\n version_file = os.path.join(path,'__version__.py')\n if not overwrite_version_py:\n print 'keeping %s with old version, returing new version' \\\n % (version_file)\n return version\n print 'updating version in %s' % version_file\n version_file = os.path.abspath(version_file)\n f = open(version_file,'w')\n f.write('# This file is automatically updated with update_version\\n'\\\n '# function from scipy_distutils.misc_util.py\\n'\\\n 'version = %s\\n'\\\n 'version_info = %s\\n'%(repr(version),version_info))\n f.close()\n return version\n\ndef get_version(release_level='alpha',\n path='.',\n version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d',\n major=None,\n ):\n \"\"\"\n Return version string calculated from CVS/Entries file(s) starting\n at . Does not change /__version__.py.\n See also update_version(..) function.\n \"\"\"\n return update_version(release_level = release_level,path = path,\n version_template = version_template,\n major = major,overwrite_version_py = 0)\n\n\ndef get_cvs_revision(path):\n \"\"\"\n Return two last cumulative revision numbers of a CVS tree starting\n at . The first number shows the number of files in the CVS\n tree (this is often true, but not always) and the second number\n characterizes the changes in these files.\n If /CVS/Entries is not existing then return None.\n \"\"\"\n entries_file = os.path.join(path,'CVS','Entries')\n if os.path.exists(entries_file):\n rev1,rev2 = 0,0\n for line in open(entries_file).readlines():\n items = string.split(line,'/')\n if items[0]=='D' and len(items)>1:\n try:\n d1,d2 = get_cvs_revision(os.path.join(path,items[1]))\n except:\n d1,d2 = 0,0\n elif items[0]=='' and len(items)>3 and items[1]!='__version__.py':\n\t\tlast_numbers = map(eval,string.split(items[2],'.')[-2:])\n\t\tif len(last_numbers)==2:\n\t\t d1,d2 = last_numbers\n\t\telse: # this is when 'cvs add' but not yet 'cvs commit'\n\t\t d1,d2 = 0,0\n else:\n continue\n rev1,rev2 = rev1+d1,rev2+d2\n return rev1,rev2\n\ndef get_path(mod_name):\n \"\"\" This function makes sure installation is done from the\n correct directory no matter if it is installed from the\n command line or from another package or run_setup function.\n \n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n return d\n \ndef add_local_to_path(mod_name):\n local_path = get_path(mod_name)\n sys.path.insert(0,local_path)\n\n\ndef add_grandparent_to_path(mod_name):\n local_path = get_path(mod_name)\n gp_dir = os.path.split(local_path)[0]\n sys.path.insert(0,gp_dir)\n\ndef restore_path():\n del sys.path[0]\n\ndef append_package_dir_to_path(package_name): \n \"\"\" Search for a directory with package_name and append it to PYTHONPATH\n \n The local directory is searched first and then the parent directory.\n \"\"\"\n # first see if it is in the current path\n # then try parent. If it isn't found, fail silently\n # and let the import error occur.\n \n # not an easy way to clean up after this...\n import os,sys\n if os.path.exists(package_name):\n sys.path.append(package_name)\n elif os.path.exists(os.path.join('..',package_name)):\n sys.path.append(os.path.join('..',package_name))\n\ndef get_package_config(package_name):\n \"\"\" grab the configuration info from the setup_xxx.py file\n in a package directory. The package directory is searched\n from the current directory, so setting the path to the\n setup.py file directory of the file calling this is usually\n needed to get search the path correct.\n \"\"\"\n append_package_dir_to_path(package_name)\n mod = __import__('setup_'+package_name)\n config = mod.configuration()\n return config\n\ndef package_config(primary,dependencies=[]):\n \"\"\" Create a configuration dictionary ready for setup.py from\n a list of primary and dependent package names. Each\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n has a configuration() function in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n config.extend([get_package_config(x) for x in dependencies]) \n config_dict = merge_config_dicts(config)\n return config_dict\n \nlist_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\ndict_keys = ['package_dir']\n\ndef default_config_dict(name = None, parent_name = None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n\n full_name = dot_join(parent_name,name)\n\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n # Todo: implement check for this assumption.\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n test_path = os.path.join(local_path,'tests')\n if 0 and name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n if os.path.exists(test_path):\n d['packages'].append(dot_join(full_name,'tests'))\n d['package_dir'][dot_join(full_name,'tests')] = test_path\n d['name'] = full_name\n if 0 and not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n p,'scipy_distutils'))\n if os.path.exists(dir_name):\n d['packages'].append('scipy_distutils')\n d['packages'].append('scipy_distutils.command')\n d['package_dir']['scipy_distutils'] = dir_name\n break\n return d\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef merge_config_dicts(config_list):\n result = default_config_dict()\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef dot_join(*args):\n return string.join(filter(None,args),'.')\n\ndef fortran_library_item(lib_name,\n sources,\n **attrs\n ):\n \"\"\" Helper function for creating fortran_libraries items. \"\"\"\n build_info = {'sources':sources}\n known_attrs = ['module_files','module_dirs',\n 'libraries','library_dirs']\n for key,value in attrs.items():\n if key not in known_attrs:\n raise TypeError,\\\n \"fortran_library_item() got an unexpected keyword \"\\\n \"argument '%s'\" % key\n build_info[key] = value\n \n return (lib_name,build_info)\n", "methods": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 15, "complexity": 10, "token_count": 116, "parameters": [], "start_line": 5, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 40, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "name" ], "start_line": 43, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "update_version", "long_name": "update_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , overwrite_version_py = 1 )", "filename": "misc_util.py", "nloc": 65, "complexity": 12, "token_count": 351, "parameters": [ "release_level", "path", "major", "overwrite_version_py" ], "start_line": 48, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 107, "top_nesting_level": 0 }, { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , )", "filename": "misc_util.py", "nloc": 9, "complexity": 1, "token_count": 45, "parameters": [ "release_level", "path", "major" ], "start_line": 156, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "get_cvs_revision", "long_name": "get_cvs_revision( path )", "filename": "misc_util.py", "nloc": 21, "complexity": 10, "token_count": 190, "parameters": [ "path" ], "start_line": 172, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 201, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "add_local_to_path", "long_name": "add_local_to_path( mod_name )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "mod_name" ], "start_line": 218, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "add_grandparent_to_path", "long_name": "add_grandparent_to_path( mod_name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "mod_name" ], "start_line": 223, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 228, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "append_package_dir_to_path", "long_name": "append_package_dir_to_path( package_name )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 64, "parameters": [ "package_name" ], "start_line": 231, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( package_name )", "filename": "misc_util.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "package_name" ], "start_line": 247, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 259, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 29, "complexity": 13, "token_count": 266, "parameters": [ "name", "parent_name" ], "start_line": 278, "end_line": 316, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 318, "end_line": 325, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 327, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 336, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "args" ], "start_line": 343, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "fortran_library_item", "long_name": "fortran_library_item( lib_name , sources , ** attrs )", "filename": "misc_util.py", "nloc": 14, "complexity": 3, "token_count": 67, "parameters": [ "lib_name", "sources", "attrs" ], "start_line": 346, "end_line": 361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "get_environ_include_dirs", "long_name": "get_environ_include_dirs( )", "filename": "misc_util.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 363, "end_line": 367, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 15, "complexity": 10, "token_count": 116, "parameters": [], "start_line": 5, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 40, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "name" ], "start_line": 43, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "update_version", "long_name": "update_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , overwrite_version_py = 1 )", "filename": "misc_util.py", "nloc": 65, "complexity": 12, "token_count": 351, "parameters": [ "release_level", "path", "major", "overwrite_version_py" ], "start_line": 48, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 107, "top_nesting_level": 0 }, { "name": "get_version", "long_name": "get_version( release_level = 'alpha' , path = '.' , version_template = \\\n '%(major)d.%(minor)d.%(micro)d-%(release_level)s-%(serial)d' , major = None , )", "filename": "misc_util.py", "nloc": 9, "complexity": 1, "token_count": 45, "parameters": [ "release_level", "path", "major" ], "start_line": 156, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "get_cvs_revision", "long_name": "get_cvs_revision( path )", "filename": "misc_util.py", "nloc": 21, "complexity": 10, "token_count": 190, "parameters": [ "path" ], "start_line": 172, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 201, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "add_local_to_path", "long_name": "add_local_to_path( mod_name )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "mod_name" ], "start_line": 218, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "add_grandparent_to_path", "long_name": "add_grandparent_to_path( mod_name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "mod_name" ], "start_line": 223, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 228, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "append_package_dir_to_path", "long_name": "append_package_dir_to_path( package_name )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 64, "parameters": [ "package_name" ], "start_line": 231, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( package_name )", "filename": "misc_util.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "package_name" ], "start_line": 247, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 259, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 29, "complexity": 13, "token_count": 266, "parameters": [ "name", "parent_name" ], "start_line": 278, "end_line": 316, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 318, "end_line": 325, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 327, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 336, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "args" ], "start_line": 343, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "fortran_library_item", "long_name": "fortran_library_item( lib_name , sources , ** attrs )", "filename": "misc_util.py", "nloc": 14, "complexity": 3, "token_count": 67, "parameters": [ "lib_name", "sources", "attrs" ], "start_line": 346, "end_line": 361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "get_environ_include_dirs", "long_name": "get_environ_include_dirs( )", "filename": "misc_util.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 363, "end_line": 367, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 243, "complexity": 77, "token_count": 1739, "diff_parsed": { "added": [ "", "def get_environ_include_dirs():", " includes = []", " if os.environ.has_key('PYTHONINCLUDE'):", " includes = os.environ['PYTHONINCLUDE'].split(os.pathsep)", " return includes" ], "deleted": [] } } ] }, { "hash": "bc62be8f1132b378a49590f598ba1d1e0337f79c", "msg": "Fixed compiling Fortran 90 fixed and free format files (HP and Compaq compiler classes still need the 'fixed format' switch). For testing the mix of F77/F90 fixed/F90 free Fortran codes, see f2py2e/tests/mixed/.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-12-23T01:40:54+00:00", "author_timezone": 0, "committer_date": "2002-12-23T01:40:54+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "49dfa817e7136027ec281d150f7918979d9f6f99" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 37, "insertions": 116, "lines": 153, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0851063829787234, "dmm_unit_interfacing": 0.40425531914893614, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -301,6 +301,47 @@ def build_libraries (self, fortran_libraries):\n \n # build_libraries ()\n \n+#############################################################\n+\n+remove_files = []\n+def remove_files_atexit(files = remove_files):\n+ for f in files:\n+ try:\n+ os.remove(f)\n+ except OSError:\n+ pass\n+import atexit\n+atexit.register(remove_files_atexit)\n+\n+\n+is_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n+_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n+_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n+_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n+\n+def is_free_format(file):\n+ \"\"\"Check if file is in free format Fortran.\"\"\"\n+ # f90 allows both fixed and free format, assuming fixed unless\n+ # signs of free format are detected.\n+ result = 0\n+ f = open(file,'r')\n+ line = f.readline()\n+ n = 15\n+ if _has_f_header(line):\n+ n = 0\n+ elif _has_f90_header(line):\n+ n = 0\n+ result = 1\n+ while n>0 and line:\n+ if line[0]!='!':\n+ n -= 1\n+ if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n+ result = 1\n+ break\n+ line = f.readline()\n+ f.close()\n+ return result\n+\n class fortran_compiler_base(CCompiler):\n \n vendor = None\n@@ -330,7 +371,9 @@ def __init__(self,verbose=0,dry_run=0,force=0):\n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n- \n+\n+ self.f90_fixed_switch = ''\n+\n #self.libraries = []\n #self.library_dirs = []\n \n@@ -345,18 +388,33 @@ def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n- files = string.join(dirty_files)\n- f90_files = get_f90_files(dirty_files)\n- f77_files = get_f77_files(dirty_files)\n- if f90_files != []:\n- obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n- else:\n- obj1 = []\n- if f77_files != []:\n- obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n- else:\n- obj2 = []\n- return obj1 + obj2\n+\n+ f77_files,f90_fixed_files,f90_files = [],[],[]\n+ objects = []\n+\n+ for f in dirty_files:\n+ if is_f_file(f):\n+ f77_files.append(f)\n+ elif is_free_format(f):\n+ f90_files.append(f)\n+ else:\n+ f90_fixed_files.append(f)\n+\n+ #XXX: F90 files containing modules should be compiled\n+ # before F90 files that use these modules.\n+ if f77_files:\n+ objects.extend(\\\n+ self.f77_compile(f77_files,temp_dir=temp_dir))\n+\n+ if f90_fixed_files:\n+ objects.extend(\\\n+ self.f90_fixed_compile(f90_fixed_files,\n+ module_dirs,temp_dir=temp_dir))\n+ if f90_files:\n+ objects.extend(\\\n+ self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n+\n+ return objects\n \n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n@@ -401,6 +459,13 @@ def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n \n+ def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n+ switches = string.join((self.f90_fixed_switch,\n+ self.f90_switches,\n+ self.f90_opt))\n+ return self.f_compile(self.f90_compiler,switches,\n+ source_files, module_dirs,temp_dir)\n+\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n@@ -473,11 +538,13 @@ def build_library(self,library_name,source_list,module_dirs=None,\n self.create_static_lib(object_list,library_name,temp_dir)\n \n def dummy_fortran_files(self):\n+ global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n+ remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n@@ -547,23 +614,28 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n- self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n+ self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n+\n+ self.f90_fixed_switch = ' -f fixed '\n+ \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n- self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n+ self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n \n+ self.f90_fixed_switch = ' -ffixed '\n+\n self.libraries = ['fio', 'f77math', 'f90math']\n- \n+\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n@@ -624,10 +696,11 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n \n self.f90_compiler = f90c\n- # -fixed specifies fixed-format instead of free-format F90/95 code\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n \n+ self.f90_fixed_switch = ' -fixed '\n+\n self.ver_cmd = self.f90_compiler + ' -V'\n \n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n@@ -650,7 +723,8 @@ def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n- cmd = self.f90_compiler + ' -dryrun __dummy.f'\n+ dummy_file = self.dummy_fortran_files()[0]\n+ cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n@@ -691,9 +765,11 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n self.f77_opt = ' -O3 '\n \n self.f90_compiler = f90c\n- self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n+ self.f90_switches = ' -n32 -KPIC '\n self.f90_opt = ' ' \n \n+ self.f90_fixed_switch = ' -fixedform '\n+\n self.ver_cmd = self.f77_compiler + ' -version '\n \n #self.libraries = ['fortran', 'ftn', 'm']\n@@ -734,6 +810,8 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n \n+ self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n+\n self.ver_cmd = self.f77_compiler + ' +version '\n \n self.libraries = ['m']\n@@ -916,18 +994,16 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n+ self.f90_fixed_switch = ' -FI '\n \n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n \n- #self.f77_switches = self.f77_switches + self.f77_debug\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n \n- #self.libraries = ['imf']\n-\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n@@ -985,6 +1061,8 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n+ self.f90_fixed_switch = ' -fixed '\n+\n self.ver_cmd = self.f77_compiler+' -V '\n \n def get_opt(self):\n@@ -1050,6 +1128,10 @@ class vast_fortran_compiler(fortran_compiler_base):\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n \n+ # VAST f90 does not support -o with -c. So, object files are created\n+ # to the current directory and then moved to build directory\n+ object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n+\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n \n@@ -1065,8 +1147,9 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n \n+ # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n- if not gnu.is_available(): # VAST compiler requires g77.\n+ if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n@@ -1076,7 +1159,11 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n \n- # XXX: need f90 switches, debug, opt\n+ self.f90_switches = gnu.f77_switches\n+ self.f90_debug = gnu.f77_debug\n+ self.f90_opt = gnu.f77_opt\n+\n+ self.f90_fixed_switch = ' -Wv,-ya '\n \n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n@@ -1105,6 +1192,8 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n+ self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n+\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n \n@@ -1159,23 +1248,13 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n+ self.f90_fixed_switch = ' /fixed '\n+\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n \n-\n-def match_extension(files,ext):\n- match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n- return filter(lambda x,match = match: match(x),files)\n-\n-def get_f77_files(files):\n- return match_extension(files,'for|f77|ftn|f')\n-\n-def get_f90_files(files):\n- return match_extension(files,'f90|f95')\n-\n-def get_fortran_files(files):\n- return match_extension(files,'f90|f95|for|f77|ftn|f')\n+##############################################################################\n \n def find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n", "added_lines": 116, "deleted_lines": 37, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Sun|SGI|Intel|Itanium|NAG|Compaq|Digital|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,temp_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.f90_fixed_switch = ' -ffixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic'\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f77_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n self.f90_opt = ' ' \n\n self.f90_fixed_switch = ' -fixedform '\n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Sun|SGI|Intel|Itanium|NAG|Compaq|Digital|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n \n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,temp_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.libraries = ['fio', 'f77math', 'f90math']\n \n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic'\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n # -fixed specifies fixed-format instead of free-format F90/95 code\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun __dummy.f'\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f77_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n #self.f77_switches = self.f77_switches + self.f77_debug\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n #self.libraries = ['imf']\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 116, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 137, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 181, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 219, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 240, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 25, "complexity": 10, "token_count": 181, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 307, "end_line": 312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 322, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 360, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 387, "end_line": 417, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 426, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 431, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 457, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 462, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 469, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 474, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 477, "end_line": 496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 21, "complexity": 6, "token_count": 149, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 498, "end_line": 538, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 540, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 550, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 553, "end_line": 576, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 578, "end_line": 579, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 580, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 582, "end_line": 583, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 584, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 586, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 593, "end_line": 594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 33, "complexity": 5, "token_count": 195, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 602, "end_line": 646, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 648, "end_line": 653, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 655, "end_line": 656, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 18, "complexity": 4, "token_count": 122, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 686, "end_line": 713, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 715, "end_line": 720, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 722, "end_line": 740, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 742, "end_line": 743, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 745, "end_line": 746, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 755, "end_line": 778, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 781, "end_line": 783, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 784, "end_line": 786, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 787, "end_line": 788, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 789, "end_line": 790, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 797, "end_line": 818, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 820, "end_line": 838, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 846, "end_line": 877, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 45, "complexity": 21, "token_count": 254, "parameters": [ "self" ], "start_line": 879, "end_line": 925, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 927, "end_line": 944, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 946, "end_line": 953, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 955, "end_line": 963, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 965, "end_line": 966, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 976, "end_line": 1005, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1007, "end_line": 1021, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1023, "end_line": 1024, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1034, "end_line": 1037, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1045, "end_line": 1066, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1068, "end_line": 1070, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1072, "end_line": 1073, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1087, "end_line": 1115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1121, "end_line": 1122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1135, "end_line": 1166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1168, "end_line": 1169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 104, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1177, "end_line": 1201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1203, "end_line": 1206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1208, "end_line": 1209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1226, "end_line": 1251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1253, "end_line": 1255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1259, "end_line": 1267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 116, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 137, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 181, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 219, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 240, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 25, "complexity": 10, "token_count": 181, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 319, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 89, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 344, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 361, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 368, "end_line": 371, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 373, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 399, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 404, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 409, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 412, "end_line": 431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 21, "complexity": 6, "token_count": 149, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 433, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 475, "end_line": 481, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 483, "end_line": 484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 486, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 511, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 513, "end_line": 514, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 515, "end_line": 516, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 517, "end_line": 518, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 519, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 526, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 31, "complexity": 5, "token_count": 185, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 535, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 576, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 583, "end_line": 584, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 17, "complexity": 4, "token_count": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 614, "end_line": 640, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 642, "end_line": 647, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 124, "parameters": [ "self" ], "start_line": 649, "end_line": 666, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 668, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 671, "end_line": 672, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 681, "end_line": 702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 705, "end_line": 707, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 708, "end_line": 710, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 711, "end_line": 712, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 713, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 95, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 721, "end_line": 740, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 742, "end_line": 760, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 768, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 45, "complexity": 21, "token_count": 254, "parameters": [ "self" ], "start_line": 801, "end_line": 847, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 849, "end_line": 866, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 868, "end_line": 875, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 877, "end_line": 885, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 887, "end_line": 888, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 22, "complexity": 5, "token_count": 148, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 898, "end_line": 927, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 931, "end_line": 945, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 947, "end_line": 948, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 958, "end_line": 961, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 108, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 969, "end_line": 988, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 990, "end_line": 992, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 994, "end_line": 995, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1009, "end_line": 1037, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1043, "end_line": 1044, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 5, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1053, "end_line": 1077, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1081, "end_line": 1082, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 99, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1090, "end_line": 1112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1114, "end_line": 1117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1119, "end_line": 1120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 18, "complexity": 4, "token_count": 129, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1137, "end_line": 1160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1162, "end_line": 1164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 1167, "end_line": 1169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1171, "end_line": 1172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1174, "end_line": 1175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1177, "end_line": 1178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1180, "end_line": 1188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 307, "end_line": 312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 33, "complexity": 5, "token_count": 195, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 602, "end_line": 646, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 722, "end_line": 740, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 387, "end_line": 417, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_fortran_files", "long_name": "get_fortran_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1177, "end_line": 1178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_f90_files", "long_name": "get_f90_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1174, "end_line": 1175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "match_extension", "long_name": "match_extension( files , ext )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 44, "parameters": [ "files", "ext" ], "start_line": 1167, "end_line": 1169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 540, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 462, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_f77_files", "long_name": "get_f77_files( files )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "files" ], "start_line": 1171, "end_line": 1172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 322, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 360, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 } ], "nloc": 927, "complexity": 233, "token_count": 5440, "diff_parsed": { "added": [ "#############################################################", "", "remove_files = []", "def remove_files_atexit(files = remove_files):", " for f in files:", " try:", " os.remove(f)", " except OSError:", " pass", "import atexit", "atexit.register(remove_files_atexit)", "", "", "is_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match", "_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search", "_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search", "_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match", "", "def is_free_format(file):", " \"\"\"Check if file is in free format Fortran.\"\"\"", " # f90 allows both fixed and free format, assuming fixed unless", " # signs of free format are detected.", " result = 0", " f = open(file,'r')", " line = f.readline()", " n = 15", " if _has_f_header(line):", " n = 0", " elif _has_f90_header(line):", " n = 0", " result = 1", " while n>0 and line:", " if line[0]!='!':", " n -= 1", " if _free_f90_start(line[:5]) or line[-2:-1]=='&':", " result = 1", " break", " line = f.readline()", " f.close()", " return result", "", "", " self.f90_fixed_switch = ''", "", "", " f77_files,f90_fixed_files,f90_files = [],[],[]", " objects = []", "", " for f in dirty_files:", " if is_f_file(f):", " f77_files.append(f)", " elif is_free_format(f):", " f90_files.append(f)", " else:", " f90_fixed_files.append(f)", "", " #XXX: F90 files containing modules should be compiled", " # before F90 files that use these modules.", " if f77_files:", " objects.extend(\\", " self.f77_compile(f77_files,temp_dir=temp_dir))", "", " if f90_fixed_files:", " objects.extend(\\", " self.f90_fixed_compile(f90_fixed_files,", " module_dirs,temp_dir=temp_dir))", " if f90_files:", " objects.extend(\\", " self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))", "", " return objects", " def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):", " switches = string.join((self.f90_fixed_switch,", " self.f90_switches,", " self.f90_opt))", " return self.f_compile(self.f90_compiler,switches,", " source_files, module_dirs,temp_dir)", "", " global remove_files", " remove_files.extend([dummy_name+'.f',dummy_name+'.o'])", " self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\", "", " self.f90_fixed_switch = ' -f fixed '", "", " self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\", " self.f90_fixed_switch = ' -ffixed '", "", "", " self.f90_fixed_switch = ' -fixed '", "", " dummy_file = self.dummy_fortran_files()[0]", " cmd = self.f90_compiler + ' -dryrun ' + dummy_file", " self.f90_switches = ' -n32 -KPIC '", " self.f90_fixed_switch = ' -fixedform '", "", " self.f90_fixed_switch = ' ' # XXX: need fixed format flag", "", " self.f90_fixed_switch = ' -FI '", " self.f90_fixed_switch = ' -fixed '", "", " # VAST f90 does not support -o with -c. So, object files are created", " # to the current directory and then moved to build directory", " object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '", "", " # VAST compiler requires g77.", " if not gnu.is_available():", " self.f90_switches = gnu.f77_switches", " self.f90_debug = gnu.f77_debug", " self.f90_opt = gnu.f77_opt", "", " self.f90_fixed_switch = ' -Wv,-ya '", " self.f90_fixed_switch = ' ' # XXX: need fixed format flag", "", " self.f90_fixed_switch = ' /fixed '", "", "##############################################################################" ], "deleted": [ "", " files = string.join(dirty_files)", " f90_files = get_f90_files(dirty_files)", " f77_files = get_f77_files(dirty_files)", " if f90_files != []:", " obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)", " else:", " obj1 = []", " if f77_files != []:", " obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)", " else:", " obj2 = []", " return obj1 + obj2", " self.f90_switches = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\", " self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\", "", " # -fixed specifies fixed-format instead of free-format F90/95 code", " cmd = self.f90_compiler + ' -dryrun __dummy.f'", " self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???", " #self.f77_switches = self.f77_switches + self.f77_debug", " #self.libraries = ['imf']", "", " if not gnu.is_available(): # VAST compiler requires g77.", " # XXX: need f90 switches, debug, opt", "", "def match_extension(files,ext):", " match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match", " return filter(lambda x,match = match: match(x),files)", "", "def get_f77_files(files):", " return match_extension(files,'for|f77|ftn|f')", "", "def get_f90_files(files):", " return match_extension(files,'f90|f95')", "", "def get_fortran_files(files):", " return match_extension(files,'f90|f95|for|f77|ftn|f')" ] } } ] }, { "hash": "1d5fd99dd359093961049f8d714af88005a851a1", "msg": "Fixed Forte Fortran 90 compiler support.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2002-12-27T14:17:32+00:00", "author_timezone": 0, "committer_date": "2002-12-27T14:17:32+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "bc62be8f1132b378a49590f598ba1d1e0337f79c" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 3, "insertions": 21, "lines": 24, "files": 1, "dmm_unit_size": 0.6666666666666666, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -675,6 +675,9 @@ class sun_fortran_compiler(fortran_compiler_base):\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n+\n+ Consider renaming this class to forte_fortran_compiler and define\n+ sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n@@ -687,12 +690,12 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n \n if fc is None:\n- fc = 'f77'\n+ fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n \n self.f77_compiler = fc\n- self.f77_switches = ' -pic'\n+ self.f77_switches = ' -pic -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n \n self.f90_compiler = f90c\n@@ -703,9 +706,21 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n \n self.ver_cmd = self.f90_compiler + ' -V'\n \n+ return\n+\n+ # When using f90 as a linker, nothing from below is needed.\n+ # Tested against:\n+ # Forte Developer 7 Fortran 95 7.0 2002/03/09\n+ # If there are issues with older Sun compilers, then these must be\n+ # solved explicitly (possibly defining separate Sun compiler class)\n+ # while keeping this simple/minimal configuration\n+ # for the latest Forte compilers.\n+\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n \n+ #self.libraries = ['fsu','sunmath']\n+\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n@@ -743,7 +758,7 @@ def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n \n def get_linker_so(self):\n- return [self.f77_compiler]\n+ return [self.f90_compiler]\n \n \n class mips_fortran_compiler(fortran_compiler_base):\n@@ -965,6 +980,9 @@ def get_extra_link_args(self):\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n \n+ def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n+ raise DistutilsExecError, 'f90 not supported by Gnu'\n+\n \n #http://developer.intel.com/software/products/compilers/f60l/\n class intel_ia32_fortran_compiler(fortran_compiler_base):\n", "added_lines": 21, "deleted_lines": 3, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Sun|SGI|Intel|Itanium|NAG|Compaq|Digital|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,temp_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.f90_fixed_switch = ' -ffixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n self.f90_opt = ' ' \n\n self.f90_fixed_switch = ' -fixedform '\n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Sun|SGI|Intel|Itanium|NAG|Compaq|Digital|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,temp_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.f90_fixed_switch = ' -ffixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic'\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f77_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n self.f90_opt = ' ' \n\n self.f90_fixed_switch = ' -fixedform '\n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 116, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 137, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 181, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 219, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 240, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 25, "complexity": 10, "token_count": 181, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 307, "end_line": 312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 322, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 360, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 387, "end_line": 417, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 426, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 431, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 457, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 462, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 469, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 474, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 477, "end_line": 496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 21, "complexity": 6, "token_count": 149, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 498, "end_line": 538, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 540, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 550, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 553, "end_line": 576, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 578, "end_line": 579, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 580, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 582, "end_line": 583, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 584, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 586, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 593, "end_line": 594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 33, "complexity": 5, "token_count": 195, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 602, "end_line": 646, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 648, "end_line": 653, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 655, "end_line": 656, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 123, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 689, "end_line": 728, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 730, "end_line": 735, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 737, "end_line": 755, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 757, "end_line": 758, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 760, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 770, "end_line": 793, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 796, "end_line": 798, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 799, "end_line": 801, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 802, "end_line": 803, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 804, "end_line": 805, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 812, "end_line": 833, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 835, "end_line": 853, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 861, "end_line": 892, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 45, "complexity": 21, "token_count": 254, "parameters": [ "self" ], "start_line": 894, "end_line": 940, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 942, "end_line": 959, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 961, "end_line": 968, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 970, "end_line": 978, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 980, "end_line": 981, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 983, "end_line": 984, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 994, "end_line": 1023, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1025, "end_line": 1039, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1041, "end_line": 1042, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1052, "end_line": 1055, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1063, "end_line": 1084, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1086, "end_line": 1088, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1090, "end_line": 1091, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1105, "end_line": 1133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1139, "end_line": 1140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1153, "end_line": 1184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1186, "end_line": 1187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 104, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1195, "end_line": 1219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1221, "end_line": 1224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1226, "end_line": 1227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1244, "end_line": 1269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1271, "end_line": 1273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1277, "end_line": 1285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 116, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 137, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 181, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 219, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 240, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 25, "complexity": 10, "token_count": 181, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 307, "end_line": 312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 322, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 360, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 387, "end_line": 417, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 426, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 431, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 457, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 462, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 469, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 474, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 477, "end_line": 496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 21, "complexity": 6, "token_count": 149, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 498, "end_line": 538, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 540, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 550, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 553, "end_line": 576, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 578, "end_line": 579, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 580, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 582, "end_line": 583, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 584, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 586, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 593, "end_line": 594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 33, "complexity": 5, "token_count": 195, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 602, "end_line": 646, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 648, "end_line": 653, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 655, "end_line": 656, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 18, "complexity": 4, "token_count": 122, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 686, "end_line": 713, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 715, "end_line": 720, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 722, "end_line": 740, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 742, "end_line": 743, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 745, "end_line": 746, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 755, "end_line": 778, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 781, "end_line": 783, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 784, "end_line": 786, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 787, "end_line": 788, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 789, "end_line": 790, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 797, "end_line": 818, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 820, "end_line": 838, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 846, "end_line": 877, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 45, "complexity": 21, "token_count": 254, "parameters": [ "self" ], "start_line": 879, "end_line": 925, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 927, "end_line": 944, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 946, "end_line": 953, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 955, "end_line": 963, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 965, "end_line": 966, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 976, "end_line": 1005, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1007, "end_line": 1021, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1023, "end_line": 1024, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1034, "end_line": 1037, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1045, "end_line": 1066, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1068, "end_line": 1070, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1072, "end_line": 1073, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1087, "end_line": 1115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1121, "end_line": 1122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1135, "end_line": 1166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1168, "end_line": 1169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 104, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1177, "end_line": 1201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1203, "end_line": 1206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1208, "end_line": 1209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1226, "end_line": 1251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1253, "end_line": 1255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1259, "end_line": 1267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 123, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 689, "end_line": 728, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 983, "end_line": 984, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 760, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "nloc": 933, "complexity": 234, "token_count": 5459, "diff_parsed": { "added": [ "", " Consider renaming this class to forte_fortran_compiler and define", " sun_fortran_compiler separately for older Sun f77 compilers.", " fc = 'f90'", " self.f77_switches = ' -pic -f77 -ftrap=%none '", " return", "", " # When using f90 as a linker, nothing from below is needed.", " # Tested against:", " # Forte Developer 7 Fortran 95 7.0 2002/03/09", " # If there are issues with older Sun compilers, then these must be", " # solved explicitly (possibly defining separate Sun compiler class)", " # while keeping this simple/minimal configuration", " # for the latest Forte compilers.", "", " #self.libraries = ['fsu','sunmath']", "", " return [self.f90_compiler]", " def f90_fixed_compile(self,source_files,module_files,temp_dir=''):", " raise DistutilsExecError, 'f90 not supported by Gnu'", "" ], "deleted": [ " fc = 'f77'", " self.f77_switches = ' -pic'", " return [self.f77_compiler]" ] } } ] }, { "hash": "339894e598e70c7736640659fb1e677b88866a72", "msg": "Fixed --build_flib/build_temp flags of setup.py build_flib command. It seems that the standard distutils needs the same fix for the build_clib command.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-01-01T15:32:27+00:00", "author_timezone": 0, "committer_date": "2003-01-01T15:32:27+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "1d5fd99dd359093961049f8d714af88005a851a1" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 6, "insertions": 12, "lines": 18, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.5, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -90,9 +90,9 @@ class build_flib (build_clib):\n description = \"build f77/f90 libraries used by Python extensions\"\n \n user_options = [\n- ('build-flib', 'b',\n+ ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n- ('build-temp', 't',\n+ ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n@@ -295,7 +295,10 @@ def build_libraries (self, fortran_libraries):\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n- module_dirs, temp_dir=self.build_temp)\n+ module_dirs,\n+ temp_dir=self.build_temp,\n+ build_dir=self.build_flib,\n+ )\n \n # for loop\n \n@@ -496,10 +499,13 @@ def create_static_lib(self, object_files, library_name,\n 'failure during build (exit status = %s)'%failure \n \n def build_library(self,library_name,source_list,module_dirs=None,\n- temp_dir = ''):\n+ temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n+ if not build_dir:\n+ build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n+ distutils.dir_util.mkpath(build_dir)\n \n #this compiles the files\n object_list = self.to_object(source_list,\n@@ -532,10 +538,10 @@ def build_library(self,library_name,source_list,module_dirs=None,\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n- self.create_static_lib(obj,library_name,temp_dir,\n+ self.create_static_lib(obj,library_name,build_dir,\n skip_ranlib = len(objects))\n else:\n- self.create_static_lib(object_list,library_name,temp_dir)\n+ self.create_static_lib(object_list,library_name,build_dir)\n \n def dummy_fortran_files(self):\n global remove_files\n", "added_lines": 12, "deleted_lines": 6, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Sun|SGI|Intel|Itanium|NAG|Compaq|Digital|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,build_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,build_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.f90_fixed_switch = ' -ffixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n self.f90_opt = ' ' \n\n self.f90_fixed_switch = ' -fixedform '\n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Sun|SGI|Intel|Itanium|NAG|Compaq|Digital|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,temp_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.f90_fixed_switch = ' -ffixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n self.f90_opt = ' ' \n\n self.f90_fixed_switch = ' -fixedform '\n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 116, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 137, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 181, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 219, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 240, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 310, "end_line": 315, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 325, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 363, "end_line": 388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 390, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 422, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 429, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 434, "end_line": 456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 460, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 465, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 472, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 477, "end_line": 478, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 480, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 168, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 501, "end_line": 544, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 546, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 556, "end_line": 557, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 559, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 584, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 586, "end_line": 587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 588, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 590, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 592, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 599, "end_line": 600, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 33, "complexity": 5, "token_count": 195, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 608, "end_line": 652, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 654, "end_line": 659, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 661, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 123, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 695, "end_line": 734, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 736, "end_line": 741, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 743, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 763, "end_line": 764, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 766, "end_line": 767, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 776, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 802, "end_line": 804, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 805, "end_line": 807, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 808, "end_line": 809, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 810, "end_line": 811, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 818, "end_line": 839, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 841, "end_line": 859, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 867, "end_line": 898, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 45, "complexity": 21, "token_count": 254, "parameters": [ "self" ], "start_line": 900, "end_line": 946, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 948, "end_line": 965, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 967, "end_line": 974, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 976, "end_line": 984, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 986, "end_line": 987, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 989, "end_line": 990, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1000, "end_line": 1029, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1031, "end_line": 1045, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1047, "end_line": 1048, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1058, "end_line": 1061, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1069, "end_line": 1090, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1092, "end_line": 1094, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1096, "end_line": 1097, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1111, "end_line": 1139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1145, "end_line": 1146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1159, "end_line": 1190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1192, "end_line": 1193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 104, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1201, "end_line": 1225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1227, "end_line": 1230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1232, "end_line": 1233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1250, "end_line": 1275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1277, "end_line": 1279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1283, "end_line": 1291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 116, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 137, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 181, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 219, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 240, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 25, "complexity": 10, "token_count": 181, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 307, "end_line": 312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 322, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 360, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 387, "end_line": 417, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 426, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 431, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 457, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 462, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 469, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 474, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 477, "end_line": 496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 21, "complexity": 6, "token_count": 149, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 498, "end_line": 538, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 540, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 550, "end_line": 551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 553, "end_line": 576, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 578, "end_line": 579, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 580, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 582, "end_line": 583, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 584, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 586, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 593, "end_line": 594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 33, "complexity": 5, "token_count": 195, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 602, "end_line": 646, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 648, "end_line": 653, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 655, "end_line": 656, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 123, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 689, "end_line": 728, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 730, "end_line": 735, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 737, "end_line": 755, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 757, "end_line": 758, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 760, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 770, "end_line": 793, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 796, "end_line": 798, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 799, "end_line": 801, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 802, "end_line": 803, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 804, "end_line": 805, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 812, "end_line": 833, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 835, "end_line": 853, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 861, "end_line": 892, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 45, "complexity": 21, "token_count": 254, "parameters": [ "self" ], "start_line": 894, "end_line": 940, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 942, "end_line": 959, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 961, "end_line": 968, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 970, "end_line": 978, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 980, "end_line": 981, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 983, "end_line": 984, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 994, "end_line": 1023, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1025, "end_line": 1039, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1041, "end_line": 1042, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1052, "end_line": 1055, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1063, "end_line": 1084, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1086, "end_line": 1088, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1090, "end_line": 1091, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1105, "end_line": 1133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1139, "end_line": 1140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1153, "end_line": 1184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1186, "end_line": 1187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 104, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1195, "end_line": 1219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1221, "end_line": 1224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1226, "end_line": 1227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1244, "end_line": 1269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1271, "end_line": 1273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1277, "end_line": 1285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 21, "complexity": 6, "token_count": 149, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir" ], "start_line": 498, "end_line": 538, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 168, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 501, "end_line": 544, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 } ], "nloc": 939, "complexity": 235, "token_count": 5485, "diff_parsed": { "added": [ " ('build-flib=', 'b',", " ('build-temp=', 't',", " module_dirs,", " temp_dir=self.build_temp,", " build_dir=self.build_flib,", " )", " temp_dir = '', build_dir = ''):", " if not build_dir:", " build_dir = temp_dir", " distutils.dir_util.mkpath(build_dir)", " self.create_static_lib(obj,library_name,build_dir,", " self.create_static_lib(object_list,library_name,build_dir)" ], "deleted": [ " ('build-flib', 'b',", " ('build-temp', 't',", " module_dirs, temp_dir=self.build_temp)", " temp_dir = ''):", " self.create_static_lib(obj,library_name,temp_dir,", " self.create_static_lib(object_list,library_name,temp_dir)" ] } } ] }, { "hash": "7a8d8ba25ca745cfad7fe0db93159da6f72091ba", "msg": "This module helps find the location of the compiler used by distutils.\nThis is needed so that we can create compiler specific directories for\nintermediate files (.o) created by weave. An md5 check sum of the\ncompiler binary provides a reasonably reliable way to differentiate\nbetween compilers. This approach works across multiple platforms that\nshare the same file system.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2003-01-02T23:59:26+00:00", "author_timezone": 0, "committer_date": "2003-01-02T23:59:26+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "339894e598e70c7736640659fb1e677b88866a72" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 0, "insertions": 217, "lines": 217, "files": 1, "dmm_unit_size": 0.8288288288288288, "dmm_unit_complexity": 0.8828828828828829, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": null, "new_path": "weave/find_compiler.py", "filename": "find_compiler.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,217 @@\n+import os, sys\n+\n+import distutils\n+from distutils.core import Extension, setup\n+from distutils.command.build_ext import build_ext\n+from distutils.sysconfig import customize_compiler\n+from distutils.ccompiler import new_compiler\n+\n+import distutils.bcppcompiler\n+\n+#from scipy_distutils import mingw32_support\n+\n+def dummy_dist():\n+ # create a dummy distribution. It will look at any site configuration files\n+ # and parse the command line to pick up any user configured stuff. The \n+ # resulting Distribution object is returned from setup.\n+ # Setting _setup_stop_after prevents the any commands from actually executing.\n+ distutils.core._setup_stop_after = \"commandline\"\n+ dist = setup(name=\"dummy\")\n+ distutils.core._setup_stop_after = None\n+ return dist\n+\n+def create_compiler_instance(dist): \n+ # build_ext is in charge of building C/C++ files.\n+ # We are using it and dist to parse config files, and command line \n+ # configurations. There may be other ways to handle this, but I'm\n+ # worried I may miss one of the steps in distutils if I do it my self.\n+ #ext_builder = build_ext(dist)\n+ #ext_builder.finalize_options ()\n+ \n+ # For some reason the build_ext stuff wasn't picking up the compiler \n+ # setting, so we grab it manually from the distribution object instead.\n+ opts = dist.command_options.get('build_ext',None)\n+ compiler_name = ''\n+ if opts:\n+ comp = opts.get('compiler',('',''))\n+ compiler_name = comp[1]\n+ \n+ # Create a new compiler, customize it based on the build settings,\n+ # and return it. \n+ if not compiler_name:\n+ compiler_name = None\n+ print \"compiler:\", compiler_name\n+ compiler = new_compiler(compiler=compiler_name)\n+ customize_compiler(compiler)\n+ return compiler\n+\n+def compiler_exe_name(compiler): \n+ exe_name = ''\n+ # this is really ugly... Why aren't the attribute names \n+ # standardized and used in a consistent way?\n+ if hasattr(compiler, \"compiler\"):\n+ # standard unix format\n+ exe_name = compiler.compiler[0]\n+ elif hasattr(compiler, \"cc\"):\n+ exe_name = compiler.cc\n+ elif compiler.__class__ is distutils.bcppcompiler.BCPPCompiler:\n+ exe_name = 'brcc32'\n+ return exe_name\n+\n+def compiler_exe_path(exe_name):\n+ exe_path = None\n+ if os.path.exists(exe_name):\n+ exe_path = exe_name\n+ else:\n+ path_string = os.environ['PATH']\n+ path_string = os.path.expandvars(path_string)\n+ path_string = os.path.expanduser(path_string)\n+ paths = path_string.split(os.pathsep)\n+ for path in paths:\n+ path = os.path.join(path,exe_name)\n+ if os.path.exists(path):\n+ exe_path = path\n+ break \n+ # needed to catch gcc on mingw32 installations. \n+ path = path + '.exe' \n+ if os.path.exists(path):\n+ exe_path = path\n+ break\n+ return exe_path\n+\n+def check_sum(file):\n+ \n+ import md5\n+ try:\n+ f = open(file,'r')\n+ bytes = f.read(-1)\n+ except IOError:\n+ bytes = '' \n+ chk_sum = md5.md5(bytes)\n+ return chk_sum.hexdigest()\n+\n+def get_compiler_dir(compiler_name):\n+ \"\"\" Try to figure out the compiler directory based on the\n+ input compiler name. This is fragile and really should\n+ be done at the distutils level inside the compiler. I\n+ think it is only useful on windows at the moment.\n+ \"\"\"\n+ compiler_type = choose_compiler(compiler_name)\n+ #print compiler_type\n+ configure_sys_argv(compiler_type)\n+ #print sys.argv\n+ dist = dummy_dist() \n+ compiler_obj = create_compiler_instance(dist)\n+ #print compiler_obj.__class__\n+ exe_name = compiler_exe_name(compiler_obj)\n+ exe_path = compiler_exe_path(exe_name)\n+ if not exe_path:\n+ raise ValueError, \"The '%s' compiler was not found.\" % compiler_name\n+ chk_sum = check_sum(exe_path) \n+ restore_sys_argv()\n+ \n+ return 'compiler_'+chk_sum\n+\n+#----------------------------------------------------------------------------\n+# Not needed -- used for testing.\n+#----------------------------------------------------------------------------\n+\n+def choose_compiler(compiler_name=''):\n+ \"\"\" Try and figure out which compiler is gonna be used on windows.\n+ On other platforms, it just returns whatever value it is given.\n+ \n+ converts 'gcc' to 'mingw32' on win32\n+ \"\"\"\n+ if sys.platform == 'win32': \n+ if not compiler_name:\n+ # On Windows, default to MSVC and use gcc if it wasn't found\n+ # wasn't found. If neither are found, go with whatever\n+ # the default is for distutils -- and probably fail...\n+ if msvc_exists():\n+ compiler_name = 'msvc'\n+ elif gcc_exists():\n+ compiler_name = 'mingw32'\n+ elif compiler_name == 'gcc':\n+ compiler_name = 'mingw32'\n+ else:\n+ # don't know how to force gcc -- look into this.\n+ if compiler_name == 'gcc':\n+ compiler_name = 'unix' \n+ return compiler_name\n+\n+old_argv = []\n+def configure_sys_argv(compiler_name):\n+ # We're gonna play some tricks with argv here to pass info to distutils \n+ # which is really built for command line use. better way??\n+ global old_argv\n+ old_argv = sys.argv[:] \n+ sys.argv = ['','build_ext','--compiler='+compiler_name]\n+\n+def restore_sys_argv():\n+ sys.argv = old_argv\n+\n+def gcc_exists(name = 'gcc'):\n+ \"\"\" Test to make sure gcc is found \n+ \n+ Does this return correct value on win98???\n+ \"\"\"\n+ result = 0\n+ cmd = '%s -v' % name\n+ try:\n+ w,r=os.popen4(cmd)\n+ w.close()\n+ str_result = r.read()\n+ #print str_result\n+ if string.find(str_result,'Reading specs') != -1:\n+ result = 1\n+ except:\n+ # This was needed because the msvc compiler messes with\n+ # the path variable. and will occasionlly mess things up\n+ # so much that gcc is lost in the path. (Occurs in test\n+ # scripts)\n+ result = not os.system(cmd)\n+ return result\n+\n+def msvc_exists():\n+ \"\"\" Determine whether MSVC is available on the machine.\n+ \"\"\"\n+ result = 0\n+ try:\n+ w,r=os.popen4('cl')\n+ w.close()\n+ str_result = r.read()\n+ #print str_result\n+ if string.find(str_result,'Microsoft') != -1:\n+ result = 1\n+ except:\n+ #assume we're ok if devstudio exists\n+ import distutils.msvccompiler\n+ version = distutils.msvccompiler.get_devstudio_versions()\n+ if version:\n+ result = 1\n+ return result\n+\n+if __name__ == \"__main__\":\n+ \"\"\"\n+ import time\n+ t1 = time.time() \n+ dist = dummy_dist() \n+ compiler_obj = create_compiler_instance(dist)\n+ exe_name = compiler_exe_name(compiler_obj)\n+ exe_path = compiler_exe_path(exe_name)\n+ chk_sum = check_sum(exe_path) \n+ \n+ t2 = time.time()\n+ print 'compiler exe:', exe_path\n+ print 'check sum:', chk_sum\n+ print 'time (sec):', t2 - t1\n+ print\n+ \"\"\"\n+ path = get_compiler_dir('gcc')\n+ print 'gcc path:', path\n+ print\n+ try: \n+ path = get_compiler_dir('msvc')\n+ print 'gcc path:', path\n+ except ValueError:\n+ pass \n\\ No newline at end of file\n", "added_lines": 217, "deleted_lines": 0, "source_code": "import os, sys\n\nimport distutils\nfrom distutils.core import Extension, setup\nfrom distutils.command.build_ext import build_ext\nfrom distutils.sysconfig import customize_compiler\nfrom distutils.ccompiler import new_compiler\n\nimport distutils.bcppcompiler\n\n#from scipy_distutils import mingw32_support\n\ndef dummy_dist():\n # create a dummy distribution. It will look at any site configuration files\n # and parse the command line to pick up any user configured stuff. The \n # resulting Distribution object is returned from setup.\n # Setting _setup_stop_after prevents the any commands from actually executing.\n distutils.core._setup_stop_after = \"commandline\"\n dist = setup(name=\"dummy\")\n distutils.core._setup_stop_after = None\n return dist\n\ndef create_compiler_instance(dist): \n # build_ext is in charge of building C/C++ files.\n # We are using it and dist to parse config files, and command line \n # configurations. There may be other ways to handle this, but I'm\n # worried I may miss one of the steps in distutils if I do it my self.\n #ext_builder = build_ext(dist)\n #ext_builder.finalize_options ()\n \n # For some reason the build_ext stuff wasn't picking up the compiler \n # setting, so we grab it manually from the distribution object instead.\n opts = dist.command_options.get('build_ext',None)\n compiler_name = ''\n if opts:\n comp = opts.get('compiler',('',''))\n compiler_name = comp[1]\n \n # Create a new compiler, customize it based on the build settings,\n # and return it. \n if not compiler_name:\n compiler_name = None\n print \"compiler:\", compiler_name\n compiler = new_compiler(compiler=compiler_name)\n customize_compiler(compiler)\n return compiler\n\ndef compiler_exe_name(compiler): \n exe_name = ''\n # this is really ugly... Why aren't the attribute names \n # standardized and used in a consistent way?\n if hasattr(compiler, \"compiler\"):\n # standard unix format\n exe_name = compiler.compiler[0]\n elif hasattr(compiler, \"cc\"):\n exe_name = compiler.cc\n elif compiler.__class__ is distutils.bcppcompiler.BCPPCompiler:\n exe_name = 'brcc32'\n return exe_name\n\ndef compiler_exe_path(exe_name):\n exe_path = None\n if os.path.exists(exe_name):\n exe_path = exe_name\n else:\n path_string = os.environ['PATH']\n path_string = os.path.expandvars(path_string)\n path_string = os.path.expanduser(path_string)\n paths = path_string.split(os.pathsep)\n for path in paths:\n path = os.path.join(path,exe_name)\n if os.path.exists(path):\n exe_path = path\n break \n # needed to catch gcc on mingw32 installations. \n path = path + '.exe' \n if os.path.exists(path):\n exe_path = path\n break\n return exe_path\n\ndef check_sum(file):\n \n import md5\n try:\n f = open(file,'r')\n bytes = f.read(-1)\n except IOError:\n bytes = '' \n chk_sum = md5.md5(bytes)\n return chk_sum.hexdigest()\n\ndef get_compiler_dir(compiler_name):\n \"\"\" Try to figure out the compiler directory based on the\n input compiler name. This is fragile and really should\n be done at the distutils level inside the compiler. I\n think it is only useful on windows at the moment.\n \"\"\"\n compiler_type = choose_compiler(compiler_name)\n #print compiler_type\n configure_sys_argv(compiler_type)\n #print sys.argv\n dist = dummy_dist() \n compiler_obj = create_compiler_instance(dist)\n #print compiler_obj.__class__\n exe_name = compiler_exe_name(compiler_obj)\n exe_path = compiler_exe_path(exe_name)\n if not exe_path:\n raise ValueError, \"The '%s' compiler was not found.\" % compiler_name\n chk_sum = check_sum(exe_path) \n restore_sys_argv()\n \n return 'compiler_'+chk_sum\n\n#----------------------------------------------------------------------------\n# Not needed -- used for testing.\n#----------------------------------------------------------------------------\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n\nold_argv = []\ndef configure_sys_argv(compiler_name):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--compiler='+compiler_name]\n\ndef restore_sys_argv():\n sys.argv = old_argv\n\ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_versions()\n if version:\n result = 1\n return result\n\nif __name__ == \"__main__\":\n \"\"\"\n import time\n t1 = time.time() \n dist = dummy_dist() \n compiler_obj = create_compiler_instance(dist)\n exe_name = compiler_exe_name(compiler_obj)\n exe_path = compiler_exe_path(exe_name)\n chk_sum = check_sum(exe_path) \n \n t2 = time.time()\n print 'compiler exe:', exe_path\n print 'check sum:', chk_sum\n print 'time (sec):', t2 - t1\n print\n \"\"\"\n path = get_compiler_dir('gcc')\n print 'gcc path:', path\n print\n try: \n path = get_compiler_dir('msvc')\n print 'gcc path:', path\n except ValueError:\n pass ", "source_code_before": null, "methods": [ { "name": "dummy_dist", "long_name": "dummy_dist( )", "filename": "find_compiler.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [], "start_line": 13, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "create_compiler_instance", "long_name": "create_compiler_instance( dist )", "filename": "find_compiler.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "dist" ], "start_line": 23, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "compiler_exe_name", "long_name": "compiler_exe_name( compiler )", "filename": "find_compiler.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "compiler" ], "start_line": 48, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "compiler_exe_path", "long_name": "compiler_exe_path( exe_name )", "filename": "find_compiler.py", "nloc": 19, "complexity": 5, "token_count": 113, "parameters": [ "exe_name" ], "start_line": 61, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "check_sum", "long_name": "check_sum( file )", "filename": "find_compiler.py", "nloc": 9, "complexity": 2, "token_count": 46, "parameters": [ "file" ], "start_line": 82, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "get_compiler_dir", "long_name": "get_compiler_dir( compiler_name )", "filename": "find_compiler.py", "nloc": 12, "complexity": 2, "token_count": 62, "parameters": [ "compiler_name" ], "start_line": 93, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "find_compiler.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 119, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name )", "filename": "find_compiler.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "compiler_name" ], "start_line": 143, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "find_compiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 150, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "find_compiler.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 153, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "find_compiler.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 175, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 } ], "methods_before": [], "changed_methods": [ { "name": "compiler_exe_name", "long_name": "compiler_exe_name( compiler )", "filename": "find_compiler.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "compiler" ], "start_line": 48, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "find_compiler.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 175, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "find_compiler.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 153, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "compiler_exe_path", "long_name": "compiler_exe_path( exe_name )", "filename": "find_compiler.py", "nloc": 19, "complexity": 5, "token_count": 113, "parameters": [ "exe_name" ], "start_line": 61, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "create_compiler_instance", "long_name": "create_compiler_instance( dist )", "filename": "find_compiler.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "dist" ], "start_line": 23, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "find_compiler.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 150, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "get_compiler_dir", "long_name": "get_compiler_dir( compiler_name )", "filename": "find_compiler.py", "nloc": 12, "complexity": 2, "token_count": 62, "parameters": [ "compiler_name" ], "start_line": 93, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "check_sum", "long_name": "check_sum( file )", "filename": "find_compiler.py", "nloc": 9, "complexity": 2, "token_count": 46, "parameters": [ "file" ], "start_line": 82, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "dummy_dist", "long_name": "dummy_dist( )", "filename": "find_compiler.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [], "start_line": 13, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "find_compiler.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 119, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name )", "filename": "find_compiler.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "compiler_name" ], "start_line": 143, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "nloc": 143, "complexity": 33, "token_count": 688, "diff_parsed": { "added": [ "import os, sys", "", "import distutils", "from distutils.core import Extension, setup", "from distutils.command.build_ext import build_ext", "from distutils.sysconfig import customize_compiler", "from distutils.ccompiler import new_compiler", "", "import distutils.bcppcompiler", "", "#from scipy_distutils import mingw32_support", "", "def dummy_dist():", " # create a dummy distribution. It will look at any site configuration files", " # and parse the command line to pick up any user configured stuff. The", " # resulting Distribution object is returned from setup.", " # Setting _setup_stop_after prevents the any commands from actually executing.", " distutils.core._setup_stop_after = \"commandline\"", " dist = setup(name=\"dummy\")", " distutils.core._setup_stop_after = None", " return dist", "", "def create_compiler_instance(dist):", " # build_ext is in charge of building C/C++ files.", " # We are using it and dist to parse config files, and command line", " # configurations. There may be other ways to handle this, but I'm", " # worried I may miss one of the steps in distutils if I do it my self.", " #ext_builder = build_ext(dist)", " #ext_builder.finalize_options ()", "", " # For some reason the build_ext stuff wasn't picking up the compiler", " # setting, so we grab it manually from the distribution object instead.", " opts = dist.command_options.get('build_ext',None)", " compiler_name = ''", " if opts:", " comp = opts.get('compiler',('',''))", " compiler_name = comp[1]", "", " # Create a new compiler, customize it based on the build settings,", " # and return it.", " if not compiler_name:", " compiler_name = None", " print \"compiler:\", compiler_name", " compiler = new_compiler(compiler=compiler_name)", " customize_compiler(compiler)", " return compiler", "", "def compiler_exe_name(compiler):", " exe_name = ''", " # this is really ugly... Why aren't the attribute names", " # standardized and used in a consistent way?", " if hasattr(compiler, \"compiler\"):", " # standard unix format", " exe_name = compiler.compiler[0]", " elif hasattr(compiler, \"cc\"):", " exe_name = compiler.cc", " elif compiler.__class__ is distutils.bcppcompiler.BCPPCompiler:", " exe_name = 'brcc32'", " return exe_name", "", "def compiler_exe_path(exe_name):", " exe_path = None", " if os.path.exists(exe_name):", " exe_path = exe_name", " else:", " path_string = os.environ['PATH']", " path_string = os.path.expandvars(path_string)", " path_string = os.path.expanduser(path_string)", " paths = path_string.split(os.pathsep)", " for path in paths:", " path = os.path.join(path,exe_name)", " if os.path.exists(path):", " exe_path = path", " break", " # needed to catch gcc on mingw32 installations.", " path = path + '.exe'", " if os.path.exists(path):", " exe_path = path", " break", " return exe_path", "", "def check_sum(file):", "", " import md5", " try:", " f = open(file,'r')", " bytes = f.read(-1)", " except IOError:", " bytes = ''", " chk_sum = md5.md5(bytes)", " return chk_sum.hexdigest()", "", "def get_compiler_dir(compiler_name):", " \"\"\" Try to figure out the compiler directory based on the", " input compiler name. This is fragile and really should", " be done at the distutils level inside the compiler. I", " think it is only useful on windows at the moment.", " \"\"\"", " compiler_type = choose_compiler(compiler_name)", " #print compiler_type", " configure_sys_argv(compiler_type)", " #print sys.argv", " dist = dummy_dist()", " compiler_obj = create_compiler_instance(dist)", " #print compiler_obj.__class__", " exe_name = compiler_exe_name(compiler_obj)", " exe_path = compiler_exe_path(exe_name)", " if not exe_path:", " raise ValueError, \"The '%s' compiler was not found.\" % compiler_name", " chk_sum = check_sum(exe_path)", " restore_sys_argv()", "", " return 'compiler_'+chk_sum", "", "#----------------------------------------------------------------------------", "# Not needed -- used for testing.", "#----------------------------------------------------------------------------", "", "def choose_compiler(compiler_name=''):", " \"\"\" Try and figure out which compiler is gonna be used on windows.", " On other platforms, it just returns whatever value it is given.", "", " converts 'gcc' to 'mingw32' on win32", " \"\"\"", " if sys.platform == 'win32':", " if not compiler_name:", " # On Windows, default to MSVC and use gcc if it wasn't found", " # wasn't found. If neither are found, go with whatever", " # the default is for distutils -- and probably fail...", " if msvc_exists():", " compiler_name = 'msvc'", " elif gcc_exists():", " compiler_name = 'mingw32'", " elif compiler_name == 'gcc':", " compiler_name = 'mingw32'", " else:", " # don't know how to force gcc -- look into this.", " if compiler_name == 'gcc':", " compiler_name = 'unix'", " return compiler_name", "", "old_argv = []", "def configure_sys_argv(compiler_name):", " # We're gonna play some tricks with argv here to pass info to distutils", " # which is really built for command line use. better way??", " global old_argv", " old_argv = sys.argv[:]", " sys.argv = ['','build_ext','--compiler='+compiler_name]", "", "def restore_sys_argv():", " sys.argv = old_argv", "", "def gcc_exists(name = 'gcc'):", " \"\"\" Test to make sure gcc is found", "", " Does this return correct value on win98???", " \"\"\"", " result = 0", " cmd = '%s -v' % name", " try:", " w,r=os.popen4(cmd)", " w.close()", " str_result = r.read()", " #print str_result", " if string.find(str_result,'Reading specs') != -1:", " result = 1", " except:", " # This was needed because the msvc compiler messes with", " # the path variable. and will occasionlly mess things up", " # so much that gcc is lost in the path. (Occurs in test", " # scripts)", " result = not os.system(cmd)", " return result", "", "def msvc_exists():", " \"\"\" Determine whether MSVC is available on the machine.", " \"\"\"", " result = 0", " try:", " w,r=os.popen4('cl')", " w.close()", " str_result = r.read()", " #print str_result", " if string.find(str_result,'Microsoft') != -1:", " result = 1", " except:", " #assume we're ok if devstudio exists", " import distutils.msvccompiler", " version = distutils.msvccompiler.get_devstudio_versions()", " if version:", " result = 1", " return result", "", "if __name__ == \"__main__\":", " \"\"\"", " import time", " t1 = time.time()", " dist = dummy_dist()", " compiler_obj = create_compiler_instance(dist)", " exe_name = compiler_exe_name(compiler_obj)", " exe_path = compiler_exe_path(exe_name)", " chk_sum = check_sum(exe_path)", "", " t2 = time.time()", " print 'compiler exe:', exe_path", " print 'check sum:', chk_sum", " print 'time (sec):', t2 - t1", " print", " \"\"\"", " path = get_compiler_dir('gcc')", " print 'gcc path:', path", " print", " try:", " path = get_compiler_dir('msvc')", " print 'gcc path:', path", " except ValueError:", " pass" ], "deleted": [] } } ] }, { "hash": "1c55139604560cd5d71eafe30986d03578b2f9b7", "msg": "weave now compiles intermediate files in a compiler specific directory.\nThis prevents the possibility of compilers from different platforms\nfrom looking in the python_intermediate directory and finding an object\nfile built by a different compiler and trying to link it in -- which will\nfail.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2003-01-03T00:02:59+00:00", "author_timezone": 0, "committer_date": "2003-01-03T00:02:59+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "7a8d8ba25ca745cfad7fe0db93159da6f72091ba" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 26, "insertions": 16, "lines": 42, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "weave/build_tools.py", "new_path": "weave/build_tools.py", "filename": "build_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -22,11 +22,12 @@\n import exceptions\n import commands\n \n+import find_compiler\n+\n # If linker is 'gcc', this will convert it to 'g++'\n # necessary to make sure stdc++ is linked in cross-platform way.\n import distutils.sysconfig\n import distutils.dir_util\n-\n old_init_posix = distutils.sysconfig._init_posix\n \n def _init_posix():\n@@ -156,9 +157,12 @@ def build_extension(module_path,compiler_name = '',build_dir = None,\n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n- # dir based on their version. This will add gccX.X to the \n- # path.\n- compiler_dir = get_compiler_dir(compiler_name)\n+ # dir based on their version. This will add an md5 check sum\n+ # of the compiler binary to the directory name to keep objects\n+ # from different compilers in different locations.\n+ \n+ compiler_dir = find_compiler.get_compiler_dir(compiler_name)\n+ print 'cd:',compiler_dir\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n@@ -172,8 +176,10 @@ def build_extension(module_path,compiler_name = '',build_dir = None,\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n- if verbose > 1: verb = 1 \n- else: verb = 0\n+ if verbose > 1:\n+ verb = 1 \n+ else:\n+ verb = 0\n \n t1 = time.time() \n # add module to the needed source code files and build extension\n@@ -218,7 +224,10 @@ def build_extension(module_path,compiler_name = '',build_dir = None,\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n+ print ext.sources\n+ print 'argv:',sys.argv\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n+ print 'setup done'\n finally:\n # restore state\n os.environ = environ \n@@ -235,7 +244,7 @@ def build_extension(module_path,compiler_name = '',build_dir = None,\n \n # restore argv after our trick... \n restore_sys_argv()\n- \n+\n return success\n \n old_argv = []\n@@ -336,25 +345,6 @@ def run_command(command):\n else:\n run_command = commands.getstatusoutput\n \n-def get_compiler_dir(compiler_name):\n- \"\"\" Try to figure out the compiler directory based on the\n- input compiler name. This is fragile and really should\n- be done at the distutils level inside the compiler. I\n- think it is only useful on windows at the moment.\n- \"\"\"\n- if compiler_name is None:\n- compiler_dir = ''\n- elif compiler_name == 'gcc': \n- status, text = run_command(compiler_name + ' --version')\n- try:\n- import re\n- version = re.findall('\\d\\.\\d',text)[0]\n- except IndexError:\n- version = ''\n- compiler_dir = compiler_name + version\n- else: \n- compiler_dir = compiler_name\n- return compiler_dir\n \n def configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n", "added_lines": 16, "deleted_lines": 26, "source_code": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\nimport find_compiler\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n distutils.sysconfig._config_vars['LDSHARED'] = ld \n\ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add an md5 check sum\n # of the compiler binary to the directory name to keep objects\n # from different compilers in different locations.\n \n compiler_dir = find_compiler.get_compiler_dir(compiler_name)\n print 'cd:',compiler_dir\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1:\n verb = 1 \n else:\n verb = 0\n \n t1 = time.time() \n # add module to the needed source code files and build extension\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n #--------------------------------------------------------------------\n # added access to environment variable that user can set to specify\n # where python (and other) include files are located. This is \n # very useful on systems where python is installed by the root, but\n # the user has also installed numerous packages in their own \n # location.\n #--------------------------------------------------------------------\n if os.environ.has_key('PYTHONINCLUDE'):\n path_string = os.environ['PYTHONINCLUDE'] \n if sys.platform == \"win32\":\n extra_include_dirs = path_string.split(';')\n else: \n extra_include_dirs = path_string.split(':')\n include_dirs = kw.get('include_dirs',[])\n kw['include_dirs'] = include_dirs + extra_include_dirs\n\n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n \n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n print ext.sources\n print 'argv:',sys.argv\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n print 'setup done'\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n\n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler (distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, verbose, \n dry_run, force)\n \n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n self.set_executables(compiler='g++ -mno-cygwin -O2 -w',\n compiler_so='g++ -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "source_code_before": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\n\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n distutils.sysconfig._config_vars['LDSHARED'] = ld \n\ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add gccX.X to the \n # path.\n compiler_dir = get_compiler_dir(compiler_name)\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1: verb = 1 \n else: verb = 0\n \n t1 = time.time() \n # add module to the needed source code files and build extension\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n #--------------------------------------------------------------------\n # added access to environment variable that user can set to specify\n # where python (and other) include files are located. This is \n # very useful on systems where python is installed by the root, but\n # the user has also installed numerous packages in their own \n # location.\n #--------------------------------------------------------------------\n if os.environ.has_key('PYTHONINCLUDE'):\n path_string = os.environ['PYTHONINCLUDE'] \n if sys.platform == \"win32\":\n extra_include_dirs = path_string.split(';')\n else: \n extra_include_dirs = path_string.split(':')\n include_dirs = kw.get('include_dirs',[])\n kw['include_dirs'] = include_dirs + extra_include_dirs\n\n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n \n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n \n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\ndef get_compiler_dir(compiler_name):\n \"\"\" Try to figure out the compiler directory based on the\n input compiler name. This is fragile and really should\n be done at the distutils level inside the compiler. I\n think it is only useful on windows at the moment.\n \"\"\"\n if compiler_name is None:\n compiler_dir = ''\n elif compiler_name == 'gcc': \n status, text = run_command(compiler_name + ' --version')\n try:\n import re\n version = re.findall('\\d\\.\\d',text)[0]\n except IndexError:\n version = ''\n compiler_dir = compiler_name + version\n else: \n compiler_dir = compiler_name\n return compiler_dir\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler (distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, verbose, \n dry_run, force)\n \n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n self.set_executables(compiler='g++ -mno-cygwin -O2 -w',\n compiler_so='g++ -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "methods": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 8, "complexity": 2, "token_count": 57, "parameters": [], "start_line": 33, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 66, "complexity": 11, "token_count": 470, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 54, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 195, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 251, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 263, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 266, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 274, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 297, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 319, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_tools.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 339, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 349, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 365, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 22, "complexity": 5, "token_count": 117, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 402, "end_line": 444, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 456, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 466, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 497, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 501, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 8, "complexity": 2, "token_count": 57, "parameters": [], "start_line": 32, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 60, "complexity": 11, "token_count": 452, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 53, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 187, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 242, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 254, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 257, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 265, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 288, "end_line": 308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 310, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_tools.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 330, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_compiler_dir", "long_name": "get_compiler_dir( compiler_name )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 64, "parameters": [ "compiler_name" ], "start_line": 339, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 359, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 375, "end_line": 400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 22, "complexity": 5, "token_count": 117, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 412, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 466, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 476, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 507, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 511, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "get_compiler_dir", "long_name": "get_compiler_dir( compiler_name )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 64, "parameters": [ "compiler_name" ], "start_line": 339, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 66, "complexity": 11, "token_count": 470, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 54, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 195, "top_nesting_level": 0 } ], "nloc": 258, "complexity": 59, "token_count": 1601, "diff_parsed": { "added": [ "import find_compiler", "", " # dir based on their version. This will add an md5 check sum", " # of the compiler binary to the directory name to keep objects", " # from different compilers in different locations.", "", " compiler_dir = find_compiler.get_compiler_dir(compiler_name)", " print 'cd:',compiler_dir", " if verbose > 1:", " verb = 1", " else:", " verb = 0", " print ext.sources", " print 'argv:',sys.argv", " print 'setup done'", "" ], "deleted": [ "", " # dir based on their version. This will add gccX.X to the", " # path.", " compiler_dir = get_compiler_dir(compiler_name)", " if verbose > 1: verb = 1", " else: verb = 0", "", "def get_compiler_dir(compiler_name):", " \"\"\" Try to figure out the compiler directory based on the", " input compiler name. This is fragile and really should", " be done at the distutils level inside the compiler. I", " think it is only useful on windows at the moment.", " \"\"\"", " if compiler_name is None:", " compiler_dir = ''", " elif compiler_name == 'gcc':", " status, text = run_command(compiler_name + ' --version')", " try:", " import re", " version = re.findall('\\d\\.\\d',text)[0]", " except IndexError:", " version = ''", " compiler_dir = compiler_name + version", " else:", " compiler_dir = compiler_name", " return compiler_dir" ] } } ] }, { "hash": "cde60ff9cde753fdddefe99a2632a631207b21bc", "msg": "renamed find_compiler.py to platform_info.py so that it can be used for\nmore generic purposes beyond just getting the compiler information.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2003-01-03T17:53:04+00:00", "author_timezone": 0, "committer_date": "2003-01-03T17:53:04+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "1c55139604560cd5d71eafe30986d03578b2f9b7" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 8, "insertions": 18, "lines": 26, "files": 2, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "weave/build_tools.py", "new_path": "weave/build_tools.py", "filename": "build_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -22,7 +22,7 @@\n import exceptions\n import commands\n \n-import find_compiler\n+import platform_info\n \n # If linker is 'gcc', this will convert it to 'g++'\n # necessary to make sure stdc++ is linked in cross-platform way.\n@@ -42,8 +42,16 @@ def _init_posix():\n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n- distutils.sysconfig._config_vars['LDSHARED'] = ld \n+ \n+ # The Jaguar distributed python 2.2 has -arch i386 in the link line\n+ # which doesn't seem right. It omits all kinds of warnings, so \n+ # remove it.\n+\n+ if (sys.platform == 'darwin'):\n+ ld = ld.replace('-arch i386','')\n \n+ distutils.sysconfig._config_vars['LDSHARED'] = ld \n+ \n distutils.sysconfig._init_posix = _init_posix \n # end force g++\n \n@@ -161,8 +169,7 @@ def build_extension(module_path,compiler_name = '',build_dir = None,\n # of the compiler binary to the directory name to keep objects\n # from different compilers in different locations.\n \n- compiler_dir = find_compiler.get_compiler_dir(compiler_name)\n- print 'cd:',compiler_dir\n+ compiler_dir = platform_info.get_compiler_dir(compiler_name)\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n@@ -224,10 +231,7 @@ def build_extension(module_path,compiler_name = '',build_dir = None,\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n- print ext.sources\n- print 'argv:',sys.argv\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n- print 'setup done'\n finally:\n # restore state\n os.environ = environ \n", "added_lines": 11, "deleted_lines": 7, "source_code": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\nimport platform_info\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n \n # The Jaguar distributed python 2.2 has -arch i386 in the link line\n # which doesn't seem right. It omits all kinds of warnings, so \n # remove it.\n\n if (sys.platform == 'darwin'):\n ld = ld.replace('-arch i386','')\n\n distutils.sysconfig._config_vars['LDSHARED'] = ld \n \ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add an md5 check sum\n # of the compiler binary to the directory name to keep objects\n # from different compilers in different locations.\n \n compiler_dir = platform_info.get_compiler_dir(compiler_name)\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1:\n verb = 1 \n else:\n verb = 0\n \n t1 = time.time() \n # add module to the needed source code files and build extension\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n #--------------------------------------------------------------------\n # added access to environment variable that user can set to specify\n # where python (and other) include files are located. This is \n # very useful on systems where python is installed by the root, but\n # the user has also installed numerous packages in their own \n # location.\n #--------------------------------------------------------------------\n if os.environ.has_key('PYTHONINCLUDE'):\n path_string = os.environ['PYTHONINCLUDE'] \n if sys.platform == \"win32\":\n extra_include_dirs = path_string.split(';')\n else: \n extra_include_dirs = path_string.split(':')\n include_dirs = kw.get('include_dirs',[])\n kw['include_dirs'] = include_dirs + extra_include_dirs\n\n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n \n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n\n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler (distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, verbose, \n dry_run, force)\n \n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n self.set_executables(compiler='g++ -mno-cygwin -O2 -w',\n compiler_so='g++ -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "source_code_before": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\nimport find_compiler\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n distutils.sysconfig._config_vars['LDSHARED'] = ld \n\ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add an md5 check sum\n # of the compiler binary to the directory name to keep objects\n # from different compilers in different locations.\n \n compiler_dir = find_compiler.get_compiler_dir(compiler_name)\n print 'cd:',compiler_dir\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1:\n verb = 1 \n else:\n verb = 0\n \n t1 = time.time() \n # add module to the needed source code files and build extension\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n #--------------------------------------------------------------------\n # added access to environment variable that user can set to specify\n # where python (and other) include files are located. This is \n # very useful on systems where python is installed by the root, but\n # the user has also installed numerous packages in their own \n # location.\n #--------------------------------------------------------------------\n if os.environ.has_key('PYTHONINCLUDE'):\n path_string = os.environ['PYTHONINCLUDE'] \n if sys.platform == \"win32\":\n extra_include_dirs = path_string.split(';')\n else: \n extra_include_dirs = path_string.split(':')\n include_dirs = kw.get('include_dirs',[])\n kw['include_dirs'] = include_dirs + extra_include_dirs\n\n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n \n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n print ext.sources\n print 'argv:',sys.argv\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n print 'setup done'\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n\n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler (distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, verbose, \n dry_run, force)\n \n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n self.set_executables(compiler='g++ -mno-cygwin -O2 -w',\n compiler_so='g++ -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "methods": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 10, "complexity": 3, "token_count": 76, "parameters": [], "start_line": 33, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 62, "complexity": 11, "token_count": 454, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 62, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 191, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 255, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 267, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 270, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 278, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 301, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 323, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_tools.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 343, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 353, "end_line": 367, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 369, "end_line": 394, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 22, "complexity": 5, "token_count": 117, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 406, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 460, "end_line": 468, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 470, "end_line": 496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 501, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 505, "end_line": 507, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 8, "complexity": 2, "token_count": 57, "parameters": [], "start_line": 33, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 66, "complexity": 11, "token_count": 470, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 54, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 195, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 251, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 263, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 266, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 274, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 297, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 319, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_tools.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 339, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 349, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 365, "end_line": 390, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 22, "complexity": 5, "token_count": 117, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 402, "end_line": 444, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 456, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 466, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 497, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 501, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 10, "complexity": 3, "token_count": 76, "parameters": [], "start_line": 33, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 62, "complexity": 11, "token_count": 454, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 62, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 191, "top_nesting_level": 0 } ], "nloc": 256, "complexity": 60, "token_count": 1604, "diff_parsed": { "added": [ "import platform_info", "", " # The Jaguar distributed python 2.2 has -arch i386 in the link line", " # which doesn't seem right. It omits all kinds of warnings, so", " # remove it.", "", " if (sys.platform == 'darwin'):", " ld = ld.replace('-arch i386','')", " distutils.sysconfig._config_vars['LDSHARED'] = ld", "", " compiler_dir = platform_info.get_compiler_dir(compiler_name)" ], "deleted": [ "import find_compiler", " distutils.sysconfig._config_vars['LDSHARED'] = ld", " compiler_dir = find_compiler.get_compiler_dir(compiler_name)", " print 'cd:',compiler_dir", " print ext.sources", " print 'argv:',sys.argv", " print 'setup done'" ] } }, { "old_path": "weave/find_compiler.py", "new_path": "weave/platform_info.py", "filename": "platform_info.py", "extension": "py", "change_type": "RENAME", "diff": "@@ -1,3 +1,10 @@\n+\"\"\" Information about platform and python version and compilers\n+\n+ This information is manly used to build directory names that\n+ keep the object files and shared libaries straight when\n+ multiple platforms share the same file system.\n+\"\"\"\n+\n import os, sys\n \n import distutils\n@@ -40,7 +47,6 @@ def create_compiler_instance(dist):\n # and return it. \n if not compiler_name:\n compiler_name = None\n- print \"compiler:\", compiler_name\n compiler = new_compiler(compiler=compiler_name)\n customize_compiler(compiler)\n return compiler\n", "added_lines": 7, "deleted_lines": 1, "source_code": "\"\"\" Information about platform and python version and compilers\n\n This information is manly used to build directory names that\n keep the object files and shared libaries straight when\n multiple platforms share the same file system.\n\"\"\"\n\nimport os, sys\n\nimport distutils\nfrom distutils.core import Extension, setup\nfrom distutils.command.build_ext import build_ext\nfrom distutils.sysconfig import customize_compiler\nfrom distutils.ccompiler import new_compiler\n\nimport distutils.bcppcompiler\n\n#from scipy_distutils import mingw32_support\n\ndef dummy_dist():\n # create a dummy distribution. It will look at any site configuration files\n # and parse the command line to pick up any user configured stuff. The \n # resulting Distribution object is returned from setup.\n # Setting _setup_stop_after prevents the any commands from actually executing.\n distutils.core._setup_stop_after = \"commandline\"\n dist = setup(name=\"dummy\")\n distutils.core._setup_stop_after = None\n return dist\n\ndef create_compiler_instance(dist): \n # build_ext is in charge of building C/C++ files.\n # We are using it and dist to parse config files, and command line \n # configurations. There may be other ways to handle this, but I'm\n # worried I may miss one of the steps in distutils if I do it my self.\n #ext_builder = build_ext(dist)\n #ext_builder.finalize_options ()\n \n # For some reason the build_ext stuff wasn't picking up the compiler \n # setting, so we grab it manually from the distribution object instead.\n opts = dist.command_options.get('build_ext',None)\n compiler_name = ''\n if opts:\n comp = opts.get('compiler',('',''))\n compiler_name = comp[1]\n \n # Create a new compiler, customize it based on the build settings,\n # and return it. \n if not compiler_name:\n compiler_name = None\n compiler = new_compiler(compiler=compiler_name)\n customize_compiler(compiler)\n return compiler\n\ndef compiler_exe_name(compiler): \n exe_name = ''\n # this is really ugly... Why aren't the attribute names \n # standardized and used in a consistent way?\n if hasattr(compiler, \"compiler\"):\n # standard unix format\n exe_name = compiler.compiler[0]\n elif hasattr(compiler, \"cc\"):\n exe_name = compiler.cc\n elif compiler.__class__ is distutils.bcppcompiler.BCPPCompiler:\n exe_name = 'brcc32'\n return exe_name\n\ndef compiler_exe_path(exe_name):\n exe_path = None\n if os.path.exists(exe_name):\n exe_path = exe_name\n else:\n path_string = os.environ['PATH']\n path_string = os.path.expandvars(path_string)\n path_string = os.path.expanduser(path_string)\n paths = path_string.split(os.pathsep)\n for path in paths:\n path = os.path.join(path,exe_name)\n if os.path.exists(path):\n exe_path = path\n break \n # needed to catch gcc on mingw32 installations. \n path = path + '.exe' \n if os.path.exists(path):\n exe_path = path\n break\n return exe_path\n\ndef check_sum(file):\n \n import md5\n try:\n f = open(file,'r')\n bytes = f.read(-1)\n except IOError:\n bytes = '' \n chk_sum = md5.md5(bytes)\n return chk_sum.hexdigest()\n\ndef get_compiler_dir(compiler_name):\n \"\"\" Try to figure out the compiler directory based on the\n input compiler name. This is fragile and really should\n be done at the distutils level inside the compiler. I\n think it is only useful on windows at the moment.\n \"\"\"\n compiler_type = choose_compiler(compiler_name)\n #print compiler_type\n configure_sys_argv(compiler_type)\n #print sys.argv\n dist = dummy_dist() \n compiler_obj = create_compiler_instance(dist)\n #print compiler_obj.__class__\n exe_name = compiler_exe_name(compiler_obj)\n exe_path = compiler_exe_path(exe_name)\n if not exe_path:\n raise ValueError, \"The '%s' compiler was not found.\" % compiler_name\n chk_sum = check_sum(exe_path) \n restore_sys_argv()\n \n return 'compiler_'+chk_sum\n\n#----------------------------------------------------------------------------\n# Not needed -- used for testing.\n#----------------------------------------------------------------------------\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n\nold_argv = []\ndef configure_sys_argv(compiler_name):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--compiler='+compiler_name]\n\ndef restore_sys_argv():\n sys.argv = old_argv\n\ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_versions()\n if version:\n result = 1\n return result\n\nif __name__ == \"__main__\":\n \"\"\"\n import time\n t1 = time.time() \n dist = dummy_dist() \n compiler_obj = create_compiler_instance(dist)\n exe_name = compiler_exe_name(compiler_obj)\n exe_path = compiler_exe_path(exe_name)\n chk_sum = check_sum(exe_path) \n \n t2 = time.time()\n print 'compiler exe:', exe_path\n print 'check sum:', chk_sum\n print 'time (sec):', t2 - t1\n print\n \"\"\"\n path = get_compiler_dir('gcc')\n print 'gcc path:', path\n print\n try: \n path = get_compiler_dir('msvc')\n print 'gcc path:', path\n except ValueError:\n pass ", "source_code_before": "import os, sys\n\nimport distutils\nfrom distutils.core import Extension, setup\nfrom distutils.command.build_ext import build_ext\nfrom distutils.sysconfig import customize_compiler\nfrom distutils.ccompiler import new_compiler\n\nimport distutils.bcppcompiler\n\n#from scipy_distutils import mingw32_support\n\ndef dummy_dist():\n # create a dummy distribution. It will look at any site configuration files\n # and parse the command line to pick up any user configured stuff. The \n # resulting Distribution object is returned from setup.\n # Setting _setup_stop_after prevents the any commands from actually executing.\n distutils.core._setup_stop_after = \"commandline\"\n dist = setup(name=\"dummy\")\n distutils.core._setup_stop_after = None\n return dist\n\ndef create_compiler_instance(dist): \n # build_ext is in charge of building C/C++ files.\n # We are using it and dist to parse config files, and command line \n # configurations. There may be other ways to handle this, but I'm\n # worried I may miss one of the steps in distutils if I do it my self.\n #ext_builder = build_ext(dist)\n #ext_builder.finalize_options ()\n \n # For some reason the build_ext stuff wasn't picking up the compiler \n # setting, so we grab it manually from the distribution object instead.\n opts = dist.command_options.get('build_ext',None)\n compiler_name = ''\n if opts:\n comp = opts.get('compiler',('',''))\n compiler_name = comp[1]\n \n # Create a new compiler, customize it based on the build settings,\n # and return it. \n if not compiler_name:\n compiler_name = None\n print \"compiler:\", compiler_name\n compiler = new_compiler(compiler=compiler_name)\n customize_compiler(compiler)\n return compiler\n\ndef compiler_exe_name(compiler): \n exe_name = ''\n # this is really ugly... Why aren't the attribute names \n # standardized and used in a consistent way?\n if hasattr(compiler, \"compiler\"):\n # standard unix format\n exe_name = compiler.compiler[0]\n elif hasattr(compiler, \"cc\"):\n exe_name = compiler.cc\n elif compiler.__class__ is distutils.bcppcompiler.BCPPCompiler:\n exe_name = 'brcc32'\n return exe_name\n\ndef compiler_exe_path(exe_name):\n exe_path = None\n if os.path.exists(exe_name):\n exe_path = exe_name\n else:\n path_string = os.environ['PATH']\n path_string = os.path.expandvars(path_string)\n path_string = os.path.expanduser(path_string)\n paths = path_string.split(os.pathsep)\n for path in paths:\n path = os.path.join(path,exe_name)\n if os.path.exists(path):\n exe_path = path\n break \n # needed to catch gcc on mingw32 installations. \n path = path + '.exe' \n if os.path.exists(path):\n exe_path = path\n break\n return exe_path\n\ndef check_sum(file):\n \n import md5\n try:\n f = open(file,'r')\n bytes = f.read(-1)\n except IOError:\n bytes = '' \n chk_sum = md5.md5(bytes)\n return chk_sum.hexdigest()\n\ndef get_compiler_dir(compiler_name):\n \"\"\" Try to figure out the compiler directory based on the\n input compiler name. This is fragile and really should\n be done at the distutils level inside the compiler. I\n think it is only useful on windows at the moment.\n \"\"\"\n compiler_type = choose_compiler(compiler_name)\n #print compiler_type\n configure_sys_argv(compiler_type)\n #print sys.argv\n dist = dummy_dist() \n compiler_obj = create_compiler_instance(dist)\n #print compiler_obj.__class__\n exe_name = compiler_exe_name(compiler_obj)\n exe_path = compiler_exe_path(exe_name)\n if not exe_path:\n raise ValueError, \"The '%s' compiler was not found.\" % compiler_name\n chk_sum = check_sum(exe_path) \n restore_sys_argv()\n \n return 'compiler_'+chk_sum\n\n#----------------------------------------------------------------------------\n# Not needed -- used for testing.\n#----------------------------------------------------------------------------\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n\nold_argv = []\ndef configure_sys_argv(compiler_name):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--compiler='+compiler_name]\n\ndef restore_sys_argv():\n sys.argv = old_argv\n\ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_versions()\n if version:\n result = 1\n return result\n\nif __name__ == \"__main__\":\n \"\"\"\n import time\n t1 = time.time() \n dist = dummy_dist() \n compiler_obj = create_compiler_instance(dist)\n exe_name = compiler_exe_name(compiler_obj)\n exe_path = compiler_exe_path(exe_name)\n chk_sum = check_sum(exe_path) \n \n t2 = time.time()\n print 'compiler exe:', exe_path\n print 'check sum:', chk_sum\n print 'time (sec):', t2 - t1\n print\n \"\"\"\n path = get_compiler_dir('gcc')\n print 'gcc path:', path\n print\n try: \n path = get_compiler_dir('msvc')\n print 'gcc path:', path\n except ValueError:\n pass ", "methods": [ { "name": "dummy_dist", "long_name": "dummy_dist( )", "filename": "platform_info.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [], "start_line": 20, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "create_compiler_instance", "long_name": "create_compiler_instance( dist )", "filename": "platform_info.py", "nloc": 11, "complexity": 3, "token_count": 64, "parameters": [ "dist" ], "start_line": 30, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "compiler_exe_name", "long_name": "compiler_exe_name( compiler )", "filename": "platform_info.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "compiler" ], "start_line": 54, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "compiler_exe_path", "long_name": "compiler_exe_path( exe_name )", "filename": "platform_info.py", "nloc": 19, "complexity": 5, "token_count": 113, "parameters": [ "exe_name" ], "start_line": 67, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "check_sum", "long_name": "check_sum( file )", "filename": "platform_info.py", "nloc": 9, "complexity": 2, "token_count": 46, "parameters": [ "file" ], "start_line": 88, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "get_compiler_dir", "long_name": "get_compiler_dir( compiler_name )", "filename": "platform_info.py", "nloc": 12, "complexity": 2, "token_count": 62, "parameters": [ "compiler_name" ], "start_line": 99, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "platform_info.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 125, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name )", "filename": "platform_info.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "compiler_name" ], "start_line": 149, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "platform_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 156, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "platform_info.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 159, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "platform_info.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 181, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 } ], "methods_before": [ { "name": "dummy_dist", "long_name": "dummy_dist( )", "filename": "platform_info.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [], "start_line": 13, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "create_compiler_instance", "long_name": "create_compiler_instance( dist )", "filename": "platform_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "dist" ], "start_line": 23, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "compiler_exe_name", "long_name": "compiler_exe_name( compiler )", "filename": "platform_info.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "compiler" ], "start_line": 48, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "compiler_exe_path", "long_name": "compiler_exe_path( exe_name )", "filename": "platform_info.py", "nloc": 19, "complexity": 5, "token_count": 113, "parameters": [ "exe_name" ], "start_line": 61, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "check_sum", "long_name": "check_sum( file )", "filename": "platform_info.py", "nloc": 9, "complexity": 2, "token_count": 46, "parameters": [ "file" ], "start_line": 82, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "get_compiler_dir", "long_name": "get_compiler_dir( compiler_name )", "filename": "platform_info.py", "nloc": 12, "complexity": 2, "token_count": 62, "parameters": [ "compiler_name" ], "start_line": 93, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "platform_info.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 119, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name )", "filename": "platform_info.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "compiler_name" ], "start_line": 143, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "platform_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 150, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "platform_info.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 153, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "platform_info.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 175, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "create_compiler_instance", "long_name": "create_compiler_instance( dist )", "filename": "platform_info.py", "nloc": 12, "complexity": 3, "token_count": 68, "parameters": [ "dist" ], "start_line": 23, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 } ], "nloc": 148, "complexity": 33, "token_count": 685, "diff_parsed": { "added": [ "\"\"\" Information about platform and python version and compilers", "", " This information is manly used to build directory names that", " keep the object files and shared libaries straight when", " multiple platforms share the same file system.", "\"\"\"", "" ], "deleted": [ " print \"compiler:\", compiler_name" ] } } ] }, { "hash": "71489f3b664729f240fa034efae1ad752e7d1acd", "msg": "2.3a1 on darwin doesn't have the correct flags set when building extension\nmodules. It is missing -Wno-long-double to supress the output of this\nwarning. CFLAGS has this flag, so I just set OPT to CFLAGS in\ndistutils.sysconfig.config_vars. THis also adds a flag that turns off\npre-compiled headers in c++ builds. I don't know if this will prove an issue\nin the future or not, but it doesn't affect any of the weave tests.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2003-01-03T23:19:50+00:00", "author_timezone": 0, "committer_date": "2003-01-03T23:19:50+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "cde60ff9cde753fdddefe99a2632a631207b21bc" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 4, "insertions": 7, "lines": 11, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "weave/build_tools.py", "new_path": "weave/build_tools.py", "filename": "build_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -43,13 +43,16 @@ def _init_posix():\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n \n- # The Jaguar distributed python 2.2 has -arch i386 in the link line\n- # which doesn't seem right. It omits all kinds of warnings, so \n- # remove it.\n \n if (sys.platform == 'darwin'):\n+ # The Jaguar distributed python 2.2 has -arch i386 in the link line\n+ # which doesn't seem right. It omits all kinds of warnings, so \n+ # remove it.\n ld = ld.replace('-arch i386','')\n-\n+ # 2.3a1 on OS X emits a ton of warnings about long double. OPT\n+ # appears to not have all the needed flags set while CFLAGS does.\n+ cfg_vars = distutils.sysconfig._config_vars\n+ cfg_vars['OPT'] = cfg_vars['CFLAGS'] \n distutils.sysconfig._config_vars['LDSHARED'] = ld \n \n distutils.sysconfig._init_posix = _init_posix \n", "added_lines": 7, "deleted_lines": 4, "source_code": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\nimport platform_info\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n \n\n if (sys.platform == 'darwin'):\n # The Jaguar distributed python 2.2 has -arch i386 in the link line\n # which doesn't seem right. It omits all kinds of warnings, so \n # remove it.\n ld = ld.replace('-arch i386','')\n # 2.3a1 on OS X emits a ton of warnings about long double. OPT\n # appears to not have all the needed flags set while CFLAGS does.\n cfg_vars = distutils.sysconfig._config_vars\n cfg_vars['OPT'] = cfg_vars['CFLAGS'] \n distutils.sysconfig._config_vars['LDSHARED'] = ld \n \ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add an md5 check sum\n # of the compiler binary to the directory name to keep objects\n # from different compilers in different locations.\n \n compiler_dir = platform_info.get_compiler_dir(compiler_name)\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1:\n verb = 1 \n else:\n verb = 0\n \n t1 = time.time() \n # add module to the needed source code files and build extension\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n #--------------------------------------------------------------------\n # added access to environment variable that user can set to specify\n # where python (and other) include files are located. This is \n # very useful on systems where python is installed by the root, but\n # the user has also installed numerous packages in their own \n # location.\n #--------------------------------------------------------------------\n if os.environ.has_key('PYTHONINCLUDE'):\n path_string = os.environ['PYTHONINCLUDE'] \n if sys.platform == \"win32\":\n extra_include_dirs = path_string.split(';')\n else: \n extra_include_dirs = path_string.split(':')\n include_dirs = kw.get('include_dirs',[])\n kw['include_dirs'] = include_dirs + extra_include_dirs\n\n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n \n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n\n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler (distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, verbose, \n dry_run, force)\n \n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n self.set_executables(compiler='g++ -mno-cygwin -O2 -w',\n compiler_so='g++ -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "source_code_before": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\nimport platform_info\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n \n # The Jaguar distributed python 2.2 has -arch i386 in the link line\n # which doesn't seem right. It omits all kinds of warnings, so \n # remove it.\n\n if (sys.platform == 'darwin'):\n ld = ld.replace('-arch i386','')\n\n distutils.sysconfig._config_vars['LDSHARED'] = ld \n \ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add an md5 check sum\n # of the compiler binary to the directory name to keep objects\n # from different compilers in different locations.\n \n compiler_dir = platform_info.get_compiler_dir(compiler_name)\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1:\n verb = 1 \n else:\n verb = 0\n \n t1 = time.time() \n # add module to the needed source code files and build extension\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n #--------------------------------------------------------------------\n # added access to environment variable that user can set to specify\n # where python (and other) include files are located. This is \n # very useful on systems where python is installed by the root, but\n # the user has also installed numerous packages in their own \n # location.\n #--------------------------------------------------------------------\n if os.environ.has_key('PYTHONINCLUDE'):\n path_string = os.environ['PYTHONINCLUDE'] \n if sys.platform == \"win32\":\n extra_include_dirs = path_string.split(';')\n else: \n extra_include_dirs = path_string.split(':')\n include_dirs = kw.get('include_dirs',[])\n kw['include_dirs'] = include_dirs + extra_include_dirs\n\n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n \n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n\n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler (distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, verbose, \n dry_run, force)\n \n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n self.set_executables(compiler='g++ -mno-cygwin -O2 -w',\n compiler_so='g++ -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "methods": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 92, "parameters": [], "start_line": 33, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 62, "complexity": 11, "token_count": 454, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 65, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 191, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 258, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 270, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 273, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 281, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 304, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 326, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_tools.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 346, "end_line": 351, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 356, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 372, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 22, "complexity": 5, "token_count": 117, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 409, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 463, "end_line": 471, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 473, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 504, "end_line": 506, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 508, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 10, "complexity": 3, "token_count": 76, "parameters": [], "start_line": 33, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 62, "complexity": 11, "token_count": 454, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 62, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 191, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 255, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 267, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 270, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 278, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 301, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 323, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_tools.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 343, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 353, "end_line": 367, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 369, "end_line": 394, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 22, "complexity": 5, "token_count": 117, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 406, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 460, "end_line": 468, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 470, "end_line": 496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 501, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 505, "end_line": 507, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 92, "parameters": [], "start_line": 33, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 } ], "nloc": 258, "complexity": 60, "token_count": 1620, "diff_parsed": { "added": [ " # The Jaguar distributed python 2.2 has -arch i386 in the link line", " # which doesn't seem right. It omits all kinds of warnings, so", " # remove it.", " # 2.3a1 on OS X emits a ton of warnings about long double. OPT", " # appears to not have all the needed flags set while CFLAGS does.", " cfg_vars = distutils.sysconfig._config_vars", " cfg_vars['OPT'] = cfg_vars['CFLAGS']" ], "deleted": [ " # The Jaguar distributed python 2.2 has -arch i386 in the link line", " # which doesn't seem right. It omits all kinds of warnings, so", " # remove it.", "" ] } } ] }, { "hash": "fbb9934a9e786a6fe830294cf7368bee2cb65075", "msg": "Fixed bug in test of compiler type that was recently inserted.\n\nSplit blitz tests out so that the individual numeric types are tested separately.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2003-01-04T23:31:45+00:00", "author_timezone": 0, "committer_date": "2003-01-04T23:31:45+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "71489f3b664729f240fa034efae1ad752e7d1acd" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 31, "insertions": 68, "lines": 99, "files": 3, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "weave/catalog.py", "new_path": "weave/catalog.py", "filename": "catalog.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -162,6 +162,11 @@ def default_dir():\n except KeyError:\n temp_dir = `os.getuid()` + '_' + python_name\n path = os.path.join(tempfile.gettempdir(),temp_dir) \n+ \n+ # add a subdirectory for the OS.\n+ # It might be better to do this at a different location so that\n+ # it wasn't only the default directory that gets this behavior. \n+ #path = os.path.join(path,sys.platform)\n else:\n path = os.path.join(tempfile.gettempdir(),\"%s\"%whoami(),python_name)\n \n", "added_lines": 5, "deleted_lines": 0, "source_code": "\"\"\" Track relationships between compiled extension functions & code fragments\n\n catalog keeps track of which compiled(or even standard) functions are \n related to which code fragments. It also stores these relationships\n to disk so they are remembered between Python sessions. When \n \n a = 1\n compiler.inline('printf(\"printed from C: %d\",a);',['a'] )\n \n is called, inline() first looks to see if it has seen the code \n 'printf(\"printed from C\");' before. If not, it calls \n \n catalog.get_functions('printf(\"printed from C: %d\", a);')\n \n which returns a list of all the function objects that have been compiled\n for the code fragment. Multiple functions can occur because the code\n could be compiled for different types for 'a' (although not likely in\n this case). The catalog first looks in its cache and quickly returns\n a list of the functions if possible. If the cache lookup fails, it then\n looks through possibly multiple catalog files on disk and fills its\n cache with all the functions that match the code fragment. \n \n In case where the code fragment hasn't been compiled, inline() compiles\n the code and then adds it to the catalog:\n \n function = \n catalog.add_function('printf(\"printed from C: %d\", a);',function)\n \n add_function() adds function to the front of the cache. function,\n along with the path information to its module, are also stored in a\n persistent catalog for future use by python sessions. \n\"\"\" \n\nimport os,sys,string\nimport pickle\nimport tempfile\n\ntry:\n import dbhash\n import shelve\n dumb = 0\nexcept ImportError:\n import dumb_shelve as shelve\n dumb = 1\n\n#For testing...\n#import dumb_shelve as shelve\n#dumb = 1\n\n#import shelve\n#dumb = 0\n \ndef getmodule(object):\n \"\"\" Discover the name of the module where object was defined.\n \n This is an augmented version of inspect.getmodule that can discover \n the parent module for extension functions.\n \"\"\"\n import inspect\n value = inspect.getmodule(object)\n if value is None:\n #walk trough all modules looking for function\n for name,mod in sys.modules.items():\n # try except used because of some comparison failures\n # in wxPoint code. Need to review this\n try:\n if mod and object in mod.__dict__.values():\n value = mod\n # if it is a built-in module, keep looking to see\n # if a non-builtin also has it. Otherwise quit and\n # consider the module found. (ain't perfect, but will \n # have to do for now).\n if string.find('(built-in)',str(mod)) is -1:\n break\n \n except (TypeError, KeyError):\n pass \n return value\n\ndef expr_to_filename(expr):\n \"\"\" Convert an arbitrary expr string to a valid file name.\n \n The name is based on the md5 check sum for the string and\n Something that was a little more human readable would be \n nice, but the computer doesn't seem to care.\n \"\"\"\n import md5\n base = 'sc_'\n return base + md5.new(expr).hexdigest()\n\ndef unique_file(d,expr):\n \"\"\" Generate a unqiue file name based on expr in directory d\n \n This is meant for use with building extension modules, so\n a file name is considered unique if none of the following\n extension '.cpp','.o','.so','module.so','.py', or '.pyd'\n exists in directory d. The fully qualified path to the\n new name is returned. You'll need to append your own\n extension to it before creating files.\n \"\"\"\n files = os.listdir(d)\n #base = 'scipy_compile'\n base = expr_to_filename(expr)\n for i in range(1000000):\n fname = base + `i`\n if not (fname+'.cpp' in files or\n fname+'.o' in files or\n fname+'.so' in files or\n fname+'module.so' in files or\n fname+'.py' in files or\n fname+'.pyd' in files):\n break\n return os.path.join(d,fname)\n\ndef create_dir(p):\n \"\"\" Create a directory and any necessary intermediate directories.\"\"\"\n if not os.path.exists(p):\n try:\n os.mkdir(p)\n except OSError:\n # perhaps one or more intermediate path components don't exist\n # try to create them\n base,dir = os.path.split(p)\n create_dir(base)\n # don't enclose this one in try/except - we want the user to\n # get failure info\n os.mkdir(p)\n\ndef is_writable(dir):\n dummy = os.path.join(dir, \"dummy\")\n try:\n open(dummy, 'w')\n except IOError:\n return 0\n os.unlink(dummy)\n return 1\n\ndef whoami():\n \"\"\"return a string identifying the user.\"\"\"\n return os.environ.get(\"USER\") or os.environ.get(\"USERNAME\") or \"unknown\"\n\ndef default_dir():\n \"\"\" Return a default location to store compiled files and catalogs.\n \n XX is the Python version number in all paths listed below\n On windows, the default location is the temporary directory\n returned by gettempdir()/pythonXX.\n \n On Unix, ~/.pythonXX_compiled is the default location. If it doesn't\n exist, it is created. The directory is marked rwx------.\n \n If for some reason it isn't possible to build a default directory\n in the user's home, /tmp/_pythonXX_compiled is used. If it \n doesn't exist, it is created. The directory is marked rwx------\n to try and keep people from being able to sneak a bad module\n in on you. \n \"\"\"\n python_name = \"python%d%d_compiled\" % tuple(sys.version_info[:2]) \n if sys.platform != 'win32':\n try:\n path = os.path.join(os.environ['HOME'],'.' + python_name)\n except KeyError:\n temp_dir = `os.getuid()` + '_' + python_name\n path = os.path.join(tempfile.gettempdir(),temp_dir) \n \n # add a subdirectory for the OS.\n # It might be better to do this at a different location so that\n # it wasn't only the default directory that gets this behavior. \n #path = os.path.join(path,sys.platform)\n else:\n path = os.path.join(tempfile.gettempdir(),\"%s\"%whoami(),python_name)\n \n if not os.path.exists(path):\n create_dir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not is_writable(path):\n print 'warning: default directory is not write accessible.'\n print 'default:', path\n return path\n\ndef intermediate_dir():\n \"\"\" Location in temp dir for storing .cpp and .o files during\n builds.\n \"\"\"\n python_name = \"python%d%d_intermediate\" % tuple(sys.version_info[:2]) \n path = os.path.join(tempfile.gettempdir(),\"%s\"%whoami(),python_name)\n if not os.path.exists(path):\n create_dir(path)\n return path\n \ndef default_temp_dir():\n path = os.path.join(default_dir(),'temp')\n if not os.path.exists(path):\n create_dir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not is_writable(path):\n print 'warning: default directory is not write accessible.'\n print 'default:', path\n return path\n\n \ndef os_dependent_catalog_name():\n \"\"\" Generate catalog name dependent on OS and Python version being used.\n \n This allows multiple platforms to have catalog files in the\n same directory without stepping on each other. For now, it \n bases the name of the value returned by sys.platform and the\n version of python being run. If this isn't enough to descriminate\n on some platforms, we can try to add other info. It has \n occured to me that if we get fancy enough to optimize for different\n architectures, then chip type might be added to the catalog name also.\n \"\"\"\n version = '%d%d' % sys.version_info[:2]\n return sys.platform+version+'compiled_catalog'\n \ndef catalog_path(module_path):\n \"\"\" Return the full path name for the catalog file in the given directory.\n \n module_path can either be a file name or a path name. If it is a \n file name, the catalog file name in its parent directory is returned.\n If it is a directory, the catalog file in that directory is returned.\n\n If module_path doesn't exist, None is returned. Note though, that the\n catalog file does *not* have to exist, only its parent. '~', shell\n variables, and relative ('.' and '..') paths are all acceptable.\n \n catalog file names are os dependent (based on sys.platform), so this \n should support multiple platforms sharing the same disk space \n (NFS mounts). See os_dependent_catalog_name() for more info.\n \"\"\"\n module_path = os.path.expanduser(module_path)\n module_path = os.path.expandvars(module_path)\n module_path = os.path.abspath(module_path)\n if not os.path.exists(module_path):\n catalog_file = None\n elif not os.path.isdir(module_path):\n module_path,dummy = os.path.split(module_path)\n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n else: \n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n return catalog_file\n\ndef get_catalog(module_path,mode='r'):\n \"\"\" Return a function catalog (shelve object) from the path module_path\n\n If module_path is a directory, the function catalog returned is\n from that directory. If module_path is an actual module_name,\n then the function catalog returned is from its parent directory.\n mode uses the standard 'c' = create, 'n' = new, 'r' = read, \n 'w' = write file open modes available for anydbm databases.\n \n Well... it should be. Stuck with dumbdbm for now and the modes\n almost don't matter. We do some checking for 'r' mode, but that\n is about it.\n \n See catalog_path() for more information on module_path.\n \"\"\"\n if mode not in ['c','r','w','n']:\n msg = \" mode must be 'c', 'n', 'r', or 'w'. See anydbm for more info\"\n raise ValueError, msg\n catalog_file = catalog_path(module_path)\n try:\n # code reliant on the fact that we are using dumbdbm\n if dumb and mode == 'r' and not os.path.exists(catalog_file+'.dat'):\n sh = None\n else:\n sh = shelve.open(catalog_file,mode)\n except: # not sure how to pin down which error to catch yet\n sh = None\n return sh\n\nclass catalog:\n \"\"\" Stores information about compiled functions both in cache and on disk.\n \n catalog stores (code, list_of_function) pairs so that all the functions\n that have been compiled for code are available for calling (usually in\n inline or blitz).\n \n catalog keeps a dictionary of previously accessed code values cached \n for quick access. It also handles the looking up of functions compiled \n in previously called Python sessions on disk in function catalogs. \n catalog searches the directories in the PYTHONCOMPILED environment \n variable in order loading functions that correspond to the given code \n fragment. A default directory is also searched for catalog functions. \n On unix, the default directory is usually '~/.pythonxx_compiled' where \n xx is the version of Python used. On windows, it is the directory \n returned by temfile.gettempdir(). Functions closer to the front are of \n the variable list are guaranteed to be closer to the front of the \n function list so that they will be called first. See \n get_cataloged_functions() for more info on how the search order is \n traversed.\n \n Catalog also handles storing information about compiled functions to\n a catalog. When writing this information, the first writable catalog\n file in PYTHONCOMPILED path is used. If a writable catalog is not\n found, it is written to the catalog in the default directory. This\n directory should always be writable.\n \"\"\"\n def __init__(self,user_path_list=None):\n \"\"\" Create a catalog for storing/searching for compiled functions. \n \n user_path_list contains directories that should be searched \n first for function catalogs. They will come before the path\n entries in the PYTHONCOMPILED environment varilable.\n \"\"\"\n if type(user_path_list) == type('string'):\n self.user_path_list = [user_path_list]\n elif user_path_list:\n self.user_path_list = user_path_list\n else:\n self.user_path_list = []\n self.cache = {}\n self.module_dir = None\n self.paths_added = 0\n \n def set_module_directory(self,module_dir):\n \"\"\" Set the path that will replace 'MODULE' in catalog searches.\n \n You should call clear_module_directory() when your finished\n working with it.\n \"\"\"\n self.module_dir = module_dir\n def get_module_directory(self):\n \"\"\" Return the path used to replace the 'MODULE' in searches.\n \"\"\"\n return self.module_dir\n def clear_module_directory(self):\n \"\"\" Reset 'MODULE' path to None so that it is ignored in searches. \n \"\"\"\n self.module_dir = None\n \n def get_environ_path(self):\n \"\"\" Return list of paths from 'PYTHONCOMPILED' environment variable.\n \n On Unix the path in PYTHONCOMPILED is a ':' separated list of\n directories. On Windows, a ';' separated list is used. \n \"\"\"\n paths = []\n if os.environ.has_key('PYTHONCOMPILED'):\n path_string = os.environ['PYTHONCOMPILED'] \n if sys.platform == 'win32':\n #probably should also look in registry\n paths = path_string.split(';')\n else: \n paths = path_string.split(':')\n return paths \n\n def build_search_order(self):\n \"\"\" Returns a list of paths that are searched for catalogs. \n \n Values specified in the catalog constructor are searched first,\n then values found in the PYTHONCOMPILED environment variable.\n The directory returned by default_dir() is always returned at\n the end of the list.\n \n There is a 'magic' path name called 'MODULE' that is replaced\n by the directory defined by set_module_directory(). If the\n module directory hasn't been set, 'MODULE' is ignored.\n \"\"\"\n \n paths = self.user_path_list + self.get_environ_path()\n search_order = []\n for path in paths:\n if path == 'MODULE':\n if self.module_dir:\n search_order.append(self.module_dir)\n else:\n search_order.append(path)\n search_order.append(default_dir())\n return search_order\n\n def get_catalog_files(self):\n \"\"\" Returns catalog file list in correct search order.\n \n Some of the catalog files may not currently exists.\n However, all will be valid locations for a catalog\n to be created (if you have write permission).\n \"\"\"\n files = map(catalog_path,self.build_search_order())\n files = filter(lambda x: x is not None,files)\n return files\n\n def get_existing_files(self):\n \"\"\" Returns all existing catalog file list in correct search order.\n \"\"\"\n files = self.get_catalog_files()\n # open every stinking file to check if it exists.\n # This is because anydbm doesn't provide a consistent naming \n # convention across platforms for its files \n existing_files = []\n for file in files:\n if get_catalog(os.path.dirname(file),'r') is not None:\n existing_files.append(file)\n # This is the non-portable (and much faster) old code\n #existing_files = filter(os.path.exists,files)\n return existing_files\n\n def get_writable_file(self,existing_only=0):\n \"\"\" Return the name of the first writable catalog file.\n \n Its parent directory must also be writable. This is so that\n compiled modules can be written to the same directory.\n \"\"\"\n # note: both file and its parent directory must be writeable\n if existing_only:\n files = self.get_existing_files()\n else:\n files = self.get_catalog_files()\n # filter for (file exists and is writable) OR directory is writable\n def file_test(x):\n from os import access, F_OK, W_OK\n return (access(x,F_OK) and access(x,W_OK) or\n access(os.path.dirname(x),W_OK))\n writable = filter(file_test,files)\n if writable:\n file = writable[0]\n else:\n file = None\n return file\n \n def get_writable_dir(self):\n \"\"\" Return the parent directory of first writable catalog file.\n \n The returned directory has write access.\n \"\"\"\n return os.path.dirname(self.get_writable_file())\n \n def unique_module_name(self,code,module_dir=None):\n \"\"\" Return full path to unique file name that in writable location.\n \n The directory for the file is the first writable directory in \n the catalog search path. The unique file name is derived from\n the code fragment. If, module_dir is specified, it is used\n to replace 'MODULE' in the search path.\n \"\"\"\n if module_dir is not None:\n self.set_module_directory(module_dir)\n try:\n d = self.get_writable_dir()\n finally:\n if module_dir is not None:\n self.clear_module_directory()\n return unique_file(d,code)\n\n def path_key(self,code):\n \"\"\" Return key for path information for functions associated with code.\n \"\"\"\n return '__path__' + code\n \n def configure_path(self,cat,code):\n \"\"\" Add the python path for the given code to the sys.path\n \n unconfigure_path() should be called as soon as possible after\n imports associated with code are finished so that sys.path \n is restored to normal.\n \"\"\"\n try:\n paths = cat[self.path_key(code)]\n self.paths_added = len(paths)\n sys.path = paths + sys.path\n except:\n self.paths_added = 0 \n \n def unconfigure_path(self):\n \"\"\" Restores sys.path to normal after calls to configure_path()\n \n Remove the previously added paths from sys.path\n \"\"\"\n sys.path = sys.path[self.paths_added:]\n self.paths_added = 0\n\n def get_cataloged_functions(self,code):\n \"\"\" Load all functions associated with code from catalog search path.\n \n Sometimes there can be trouble loading a function listed in a\n catalog file because the actual module that holds the function \n has been moved or deleted. When this happens, that catalog file\n is \"repaired\", meaning the entire entry for this function is \n removed from the file. This only affects the catalog file that\n has problems -- not the others in the search path.\n \n The \"repair\" behavior may not be needed, but I'll keep it for now.\n \"\"\"\n mode = 'r'\n cat = None\n function_list = []\n for path in self.build_search_order():\n cat = get_catalog(path,mode)\n if cat is not None and cat.has_key(code):\n # set up the python path so that modules for this\n # function can be loaded.\n self.configure_path(cat,code)\n try: \n function_list += cat[code]\n except: #SystemError and ImportError so far seen \n # problems loading a function from the catalog. Try to\n # repair the cause.\n cat.close()\n self.repair_catalog(path,code)\n self.unconfigure_path() \n return function_list\n\n\n def repair_catalog(self,catalog_path,code):\n \"\"\" Remove entry for code from catalog_path\n \n Occasionally catalog entries could get corrupted. An example\n would be when a module that had functions in the catalog was\n deleted or moved on the disk. The best current repair method is \n just to trash the entire catalog entry for this piece of code. \n This may loose function entries that are valid, but thats life.\n \n catalog_path must be writable for repair. If it isn't, the\n function exists with a warning. \n \"\"\"\n writable_cat = None\n if not os.path.exists(catalog_path):\n return\n try:\n writable_cat = get_catalog(catalog_path,'w')\n except:\n print 'warning: unable to repair catalog entry\\n %s\\n in\\n %s' % \\\n (code,catalog_path)\n return \n if writable_cat.has_key(code):\n print 'repairing catalog by removing key'\n del writable_cat[code]\n \n # it is possible that the path key doesn't exist (if the function registered\n # was a built-in function), so we have to check if the path exists before\n # arbitrarily deleting it.\n path_key = self.path_key(code) \n if writable_cat.has_key(path_key):\n del writable_cat[path_key] \n \n def get_functions_fast(self,code):\n \"\"\" Return list of functions for code from the cache.\n \n Return an empty list if the code entry is not found.\n \"\"\"\n return self.cache.get(code,[])\n \n def get_functions(self,code,module_dir=None):\n \"\"\" Return the list of functions associated with this code fragment.\n \n The cache is first searched for the function. If an entry\n in the cache is not found, then catalog files on disk are \n searched for the entry. This is slooooow, but only happens\n once per code object. All the functions found in catalog files\n on a cache miss are loaded into the cache to speed up future calls.\n The search order is as follows:\n \n 1. user specified path (from catalog initialization)\n 2. directories from the PYTHONCOMPILED environment variable\n 3. The temporary directory on your platform.\n\n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n # Fast!! try cache first.\n if self.cache.has_key(code):\n return self.cache[code]\n \n # 2. Slow!! read previously compiled functions from disk.\n try:\n self.set_module_directory(module_dir)\n function_list = self.get_cataloged_functions(code)\n # put function_list in cache to save future lookups.\n if function_list:\n self.cache[code] = function_list\n # return function_list, empty or otherwise.\n finally:\n self.clear_module_directory()\n return function_list\n\n def add_function(self,code,function,module_dir=None):\n \"\"\" Adds a function to the catalog.\n \n The function is added to the cache as well as the first\n writable file catalog found in the search path. If no\n code entry exists in the cache, the on disk catalogs\n are loaded into the cache and function is added to the\n beginning of the function list.\n \n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n\n # 1. put it in the cache.\n if self.cache.has_key(code):\n if function not in self.cache[code]:\n self.cache[code].insert(0,function)\n else:\n # if it is in the cache, then it is also\n # been persisted \n return\n else: \n # Load functions and put this one up front\n self.cache[code] = self.get_functions(code) \n self.fast_cache(code,function)\n # 2. Store the function entry to disk. \n try:\n self.set_module_directory(module_dir)\n self.add_function_persistent(code,function)\n finally:\n self.clear_module_directory()\n \n def add_function_persistent(self,code,function):\n \"\"\" Store the code->function relationship to disk.\n \n Two pieces of information are needed for loading functions\n from disk -- the function pickle (which conveniently stores\n the module name, etc.) and the path to its module's directory.\n The latter is needed so that the function can be loaded no\n matter what the user's Python path is.\n \"\"\" \n # add function to data in first writable catalog\n mode = 'c' # create if doesn't exist, otherwise, use existing\n cat_dir = self.get_writable_dir()\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n cat_dir = default_dir()\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n cat_dir = default_dir() \n cat_file = catalog_path(cat_dir)\n print 'problems with default catalog -- removing'\n import glob\n files = glob.glob(cat_file+'*')\n for f in files:\n os.remove(f)\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n raise ValueError, 'Failed to access a catalog for storing functions' \n # Prabhu was getting some corrupt catalog errors. I'll put a try/except\n # to protect against this, but should really try and track down the issue.\n function_list = [function]\n try:\n function_list = function_list + cat.get(code,[])\n except pickle.UnpicklingError:\n pass\n cat[code] = function_list\n # now add needed path information for loading function\n module = getmodule(function)\n try:\n # built in modules don't have the __file__ extension, so this\n # will fail. Just pass in this case since path additions aren't\n # needed for built-in modules.\n mod_path,f=os.path.split(os.path.abspath(module.__file__))\n pkey = self.path_key(code)\n cat[pkey] = [mod_path] + cat.get(pkey,[])\n except:\n pass\n\n def fast_cache(self,code,function):\n \"\"\" Move function to the front of the cache entry for code\n \n If future calls to the function have the same type signature,\n this will speed up access significantly because the first\n function call is correct.\n \n Note: The cache added to the inline_tools module is significantly\n faster than always calling get_functions, so this isn't\n as necessary as it used to be. Still, it's probably worth\n doing. \n \"\"\"\n try:\n if self.cache[code][0] == function:\n return\n except: # KeyError, IndexError \n pass\n try:\n self.cache[code].remove(function)\n except ValueError:\n pass\n # put new function at the beginning of the list to search.\n self.cache[code].insert(0,function)\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "source_code_before": "\"\"\" Track relationships between compiled extension functions & code fragments\n\n catalog keeps track of which compiled(or even standard) functions are \n related to which code fragments. It also stores these relationships\n to disk so they are remembered between Python sessions. When \n \n a = 1\n compiler.inline('printf(\"printed from C: %d\",a);',['a'] )\n \n is called, inline() first looks to see if it has seen the code \n 'printf(\"printed from C\");' before. If not, it calls \n \n catalog.get_functions('printf(\"printed from C: %d\", a);')\n \n which returns a list of all the function objects that have been compiled\n for the code fragment. Multiple functions can occur because the code\n could be compiled for different types for 'a' (although not likely in\n this case). The catalog first looks in its cache and quickly returns\n a list of the functions if possible. If the cache lookup fails, it then\n looks through possibly multiple catalog files on disk and fills its\n cache with all the functions that match the code fragment. \n \n In case where the code fragment hasn't been compiled, inline() compiles\n the code and then adds it to the catalog:\n \n function = \n catalog.add_function('printf(\"printed from C: %d\", a);',function)\n \n add_function() adds function to the front of the cache. function,\n along with the path information to its module, are also stored in a\n persistent catalog for future use by python sessions. \n\"\"\" \n\nimport os,sys,string\nimport pickle\nimport tempfile\n\ntry:\n import dbhash\n import shelve\n dumb = 0\nexcept ImportError:\n import dumb_shelve as shelve\n dumb = 1\n\n#For testing...\n#import dumb_shelve as shelve\n#dumb = 1\n\n#import shelve\n#dumb = 0\n \ndef getmodule(object):\n \"\"\" Discover the name of the module where object was defined.\n \n This is an augmented version of inspect.getmodule that can discover \n the parent module for extension functions.\n \"\"\"\n import inspect\n value = inspect.getmodule(object)\n if value is None:\n #walk trough all modules looking for function\n for name,mod in sys.modules.items():\n # try except used because of some comparison failures\n # in wxPoint code. Need to review this\n try:\n if mod and object in mod.__dict__.values():\n value = mod\n # if it is a built-in module, keep looking to see\n # if a non-builtin also has it. Otherwise quit and\n # consider the module found. (ain't perfect, but will \n # have to do for now).\n if string.find('(built-in)',str(mod)) is -1:\n break\n \n except (TypeError, KeyError):\n pass \n return value\n\ndef expr_to_filename(expr):\n \"\"\" Convert an arbitrary expr string to a valid file name.\n \n The name is based on the md5 check sum for the string and\n Something that was a little more human readable would be \n nice, but the computer doesn't seem to care.\n \"\"\"\n import md5\n base = 'sc_'\n return base + md5.new(expr).hexdigest()\n\ndef unique_file(d,expr):\n \"\"\" Generate a unqiue file name based on expr in directory d\n \n This is meant for use with building extension modules, so\n a file name is considered unique if none of the following\n extension '.cpp','.o','.so','module.so','.py', or '.pyd'\n exists in directory d. The fully qualified path to the\n new name is returned. You'll need to append your own\n extension to it before creating files.\n \"\"\"\n files = os.listdir(d)\n #base = 'scipy_compile'\n base = expr_to_filename(expr)\n for i in range(1000000):\n fname = base + `i`\n if not (fname+'.cpp' in files or\n fname+'.o' in files or\n fname+'.so' in files or\n fname+'module.so' in files or\n fname+'.py' in files or\n fname+'.pyd' in files):\n break\n return os.path.join(d,fname)\n\ndef create_dir(p):\n \"\"\" Create a directory and any necessary intermediate directories.\"\"\"\n if not os.path.exists(p):\n try:\n os.mkdir(p)\n except OSError:\n # perhaps one or more intermediate path components don't exist\n # try to create them\n base,dir = os.path.split(p)\n create_dir(base)\n # don't enclose this one in try/except - we want the user to\n # get failure info\n os.mkdir(p)\n\ndef is_writable(dir):\n dummy = os.path.join(dir, \"dummy\")\n try:\n open(dummy, 'w')\n except IOError:\n return 0\n os.unlink(dummy)\n return 1\n\ndef whoami():\n \"\"\"return a string identifying the user.\"\"\"\n return os.environ.get(\"USER\") or os.environ.get(\"USERNAME\") or \"unknown\"\n\ndef default_dir():\n \"\"\" Return a default location to store compiled files and catalogs.\n \n XX is the Python version number in all paths listed below\n On windows, the default location is the temporary directory\n returned by gettempdir()/pythonXX.\n \n On Unix, ~/.pythonXX_compiled is the default location. If it doesn't\n exist, it is created. The directory is marked rwx------.\n \n If for some reason it isn't possible to build a default directory\n in the user's home, /tmp/_pythonXX_compiled is used. If it \n doesn't exist, it is created. The directory is marked rwx------\n to try and keep people from being able to sneak a bad module\n in on you. \n \"\"\"\n python_name = \"python%d%d_compiled\" % tuple(sys.version_info[:2]) \n if sys.platform != 'win32':\n try:\n path = os.path.join(os.environ['HOME'],'.' + python_name)\n except KeyError:\n temp_dir = `os.getuid()` + '_' + python_name\n path = os.path.join(tempfile.gettempdir(),temp_dir) \n else:\n path = os.path.join(tempfile.gettempdir(),\"%s\"%whoami(),python_name)\n \n if not os.path.exists(path):\n create_dir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not is_writable(path):\n print 'warning: default directory is not write accessible.'\n print 'default:', path\n return path\n\ndef intermediate_dir():\n \"\"\" Location in temp dir for storing .cpp and .o files during\n builds.\n \"\"\"\n python_name = \"python%d%d_intermediate\" % tuple(sys.version_info[:2]) \n path = os.path.join(tempfile.gettempdir(),\"%s\"%whoami(),python_name)\n if not os.path.exists(path):\n create_dir(path)\n return path\n \ndef default_temp_dir():\n path = os.path.join(default_dir(),'temp')\n if not os.path.exists(path):\n create_dir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not is_writable(path):\n print 'warning: default directory is not write accessible.'\n print 'default:', path\n return path\n\n \ndef os_dependent_catalog_name():\n \"\"\" Generate catalog name dependent on OS and Python version being used.\n \n This allows multiple platforms to have catalog files in the\n same directory without stepping on each other. For now, it \n bases the name of the value returned by sys.platform and the\n version of python being run. If this isn't enough to descriminate\n on some platforms, we can try to add other info. It has \n occured to me that if we get fancy enough to optimize for different\n architectures, then chip type might be added to the catalog name also.\n \"\"\"\n version = '%d%d' % sys.version_info[:2]\n return sys.platform+version+'compiled_catalog'\n \ndef catalog_path(module_path):\n \"\"\" Return the full path name for the catalog file in the given directory.\n \n module_path can either be a file name or a path name. If it is a \n file name, the catalog file name in its parent directory is returned.\n If it is a directory, the catalog file in that directory is returned.\n\n If module_path doesn't exist, None is returned. Note though, that the\n catalog file does *not* have to exist, only its parent. '~', shell\n variables, and relative ('.' and '..') paths are all acceptable.\n \n catalog file names are os dependent (based on sys.platform), so this \n should support multiple platforms sharing the same disk space \n (NFS mounts). See os_dependent_catalog_name() for more info.\n \"\"\"\n module_path = os.path.expanduser(module_path)\n module_path = os.path.expandvars(module_path)\n module_path = os.path.abspath(module_path)\n if not os.path.exists(module_path):\n catalog_file = None\n elif not os.path.isdir(module_path):\n module_path,dummy = os.path.split(module_path)\n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n else: \n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n return catalog_file\n\ndef get_catalog(module_path,mode='r'):\n \"\"\" Return a function catalog (shelve object) from the path module_path\n\n If module_path is a directory, the function catalog returned is\n from that directory. If module_path is an actual module_name,\n then the function catalog returned is from its parent directory.\n mode uses the standard 'c' = create, 'n' = new, 'r' = read, \n 'w' = write file open modes available for anydbm databases.\n \n Well... it should be. Stuck with dumbdbm for now and the modes\n almost don't matter. We do some checking for 'r' mode, but that\n is about it.\n \n See catalog_path() for more information on module_path.\n \"\"\"\n if mode not in ['c','r','w','n']:\n msg = \" mode must be 'c', 'n', 'r', or 'w'. See anydbm for more info\"\n raise ValueError, msg\n catalog_file = catalog_path(module_path)\n try:\n # code reliant on the fact that we are using dumbdbm\n if dumb and mode == 'r' and not os.path.exists(catalog_file+'.dat'):\n sh = None\n else:\n sh = shelve.open(catalog_file,mode)\n except: # not sure how to pin down which error to catch yet\n sh = None\n return sh\n\nclass catalog:\n \"\"\" Stores information about compiled functions both in cache and on disk.\n \n catalog stores (code, list_of_function) pairs so that all the functions\n that have been compiled for code are available for calling (usually in\n inline or blitz).\n \n catalog keeps a dictionary of previously accessed code values cached \n for quick access. It also handles the looking up of functions compiled \n in previously called Python sessions on disk in function catalogs. \n catalog searches the directories in the PYTHONCOMPILED environment \n variable in order loading functions that correspond to the given code \n fragment. A default directory is also searched for catalog functions. \n On unix, the default directory is usually '~/.pythonxx_compiled' where \n xx is the version of Python used. On windows, it is the directory \n returned by temfile.gettempdir(). Functions closer to the front are of \n the variable list are guaranteed to be closer to the front of the \n function list so that they will be called first. See \n get_cataloged_functions() for more info on how the search order is \n traversed.\n \n Catalog also handles storing information about compiled functions to\n a catalog. When writing this information, the first writable catalog\n file in PYTHONCOMPILED path is used. If a writable catalog is not\n found, it is written to the catalog in the default directory. This\n directory should always be writable.\n \"\"\"\n def __init__(self,user_path_list=None):\n \"\"\" Create a catalog for storing/searching for compiled functions. \n \n user_path_list contains directories that should be searched \n first for function catalogs. They will come before the path\n entries in the PYTHONCOMPILED environment varilable.\n \"\"\"\n if type(user_path_list) == type('string'):\n self.user_path_list = [user_path_list]\n elif user_path_list:\n self.user_path_list = user_path_list\n else:\n self.user_path_list = []\n self.cache = {}\n self.module_dir = None\n self.paths_added = 0\n \n def set_module_directory(self,module_dir):\n \"\"\" Set the path that will replace 'MODULE' in catalog searches.\n \n You should call clear_module_directory() when your finished\n working with it.\n \"\"\"\n self.module_dir = module_dir\n def get_module_directory(self):\n \"\"\" Return the path used to replace the 'MODULE' in searches.\n \"\"\"\n return self.module_dir\n def clear_module_directory(self):\n \"\"\" Reset 'MODULE' path to None so that it is ignored in searches. \n \"\"\"\n self.module_dir = None\n \n def get_environ_path(self):\n \"\"\" Return list of paths from 'PYTHONCOMPILED' environment variable.\n \n On Unix the path in PYTHONCOMPILED is a ':' separated list of\n directories. On Windows, a ';' separated list is used. \n \"\"\"\n paths = []\n if os.environ.has_key('PYTHONCOMPILED'):\n path_string = os.environ['PYTHONCOMPILED'] \n if sys.platform == 'win32':\n #probably should also look in registry\n paths = path_string.split(';')\n else: \n paths = path_string.split(':')\n return paths \n\n def build_search_order(self):\n \"\"\" Returns a list of paths that are searched for catalogs. \n \n Values specified in the catalog constructor are searched first,\n then values found in the PYTHONCOMPILED environment variable.\n The directory returned by default_dir() is always returned at\n the end of the list.\n \n There is a 'magic' path name called 'MODULE' that is replaced\n by the directory defined by set_module_directory(). If the\n module directory hasn't been set, 'MODULE' is ignored.\n \"\"\"\n \n paths = self.user_path_list + self.get_environ_path()\n search_order = []\n for path in paths:\n if path == 'MODULE':\n if self.module_dir:\n search_order.append(self.module_dir)\n else:\n search_order.append(path)\n search_order.append(default_dir())\n return search_order\n\n def get_catalog_files(self):\n \"\"\" Returns catalog file list in correct search order.\n \n Some of the catalog files may not currently exists.\n However, all will be valid locations for a catalog\n to be created (if you have write permission).\n \"\"\"\n files = map(catalog_path,self.build_search_order())\n files = filter(lambda x: x is not None,files)\n return files\n\n def get_existing_files(self):\n \"\"\" Returns all existing catalog file list in correct search order.\n \"\"\"\n files = self.get_catalog_files()\n # open every stinking file to check if it exists.\n # This is because anydbm doesn't provide a consistent naming \n # convention across platforms for its files \n existing_files = []\n for file in files:\n if get_catalog(os.path.dirname(file),'r') is not None:\n existing_files.append(file)\n # This is the non-portable (and much faster) old code\n #existing_files = filter(os.path.exists,files)\n return existing_files\n\n def get_writable_file(self,existing_only=0):\n \"\"\" Return the name of the first writable catalog file.\n \n Its parent directory must also be writable. This is so that\n compiled modules can be written to the same directory.\n \"\"\"\n # note: both file and its parent directory must be writeable\n if existing_only:\n files = self.get_existing_files()\n else:\n files = self.get_catalog_files()\n # filter for (file exists and is writable) OR directory is writable\n def file_test(x):\n from os import access, F_OK, W_OK\n return (access(x,F_OK) and access(x,W_OK) or\n access(os.path.dirname(x),W_OK))\n writable = filter(file_test,files)\n if writable:\n file = writable[0]\n else:\n file = None\n return file\n \n def get_writable_dir(self):\n \"\"\" Return the parent directory of first writable catalog file.\n \n The returned directory has write access.\n \"\"\"\n return os.path.dirname(self.get_writable_file())\n \n def unique_module_name(self,code,module_dir=None):\n \"\"\" Return full path to unique file name that in writable location.\n \n The directory for the file is the first writable directory in \n the catalog search path. The unique file name is derived from\n the code fragment. If, module_dir is specified, it is used\n to replace 'MODULE' in the search path.\n \"\"\"\n if module_dir is not None:\n self.set_module_directory(module_dir)\n try:\n d = self.get_writable_dir()\n finally:\n if module_dir is not None:\n self.clear_module_directory()\n return unique_file(d,code)\n\n def path_key(self,code):\n \"\"\" Return key for path information for functions associated with code.\n \"\"\"\n return '__path__' + code\n \n def configure_path(self,cat,code):\n \"\"\" Add the python path for the given code to the sys.path\n \n unconfigure_path() should be called as soon as possible after\n imports associated with code are finished so that sys.path \n is restored to normal.\n \"\"\"\n try:\n paths = cat[self.path_key(code)]\n self.paths_added = len(paths)\n sys.path = paths + sys.path\n except:\n self.paths_added = 0 \n \n def unconfigure_path(self):\n \"\"\" Restores sys.path to normal after calls to configure_path()\n \n Remove the previously added paths from sys.path\n \"\"\"\n sys.path = sys.path[self.paths_added:]\n self.paths_added = 0\n\n def get_cataloged_functions(self,code):\n \"\"\" Load all functions associated with code from catalog search path.\n \n Sometimes there can be trouble loading a function listed in a\n catalog file because the actual module that holds the function \n has been moved or deleted. When this happens, that catalog file\n is \"repaired\", meaning the entire entry for this function is \n removed from the file. This only affects the catalog file that\n has problems -- not the others in the search path.\n \n The \"repair\" behavior may not be needed, but I'll keep it for now.\n \"\"\"\n mode = 'r'\n cat = None\n function_list = []\n for path in self.build_search_order():\n cat = get_catalog(path,mode)\n if cat is not None and cat.has_key(code):\n # set up the python path so that modules for this\n # function can be loaded.\n self.configure_path(cat,code)\n try: \n function_list += cat[code]\n except: #SystemError and ImportError so far seen \n # problems loading a function from the catalog. Try to\n # repair the cause.\n cat.close()\n self.repair_catalog(path,code)\n self.unconfigure_path() \n return function_list\n\n\n def repair_catalog(self,catalog_path,code):\n \"\"\" Remove entry for code from catalog_path\n \n Occasionally catalog entries could get corrupted. An example\n would be when a module that had functions in the catalog was\n deleted or moved on the disk. The best current repair method is \n just to trash the entire catalog entry for this piece of code. \n This may loose function entries that are valid, but thats life.\n \n catalog_path must be writable for repair. If it isn't, the\n function exists with a warning. \n \"\"\"\n writable_cat = None\n if not os.path.exists(catalog_path):\n return\n try:\n writable_cat = get_catalog(catalog_path,'w')\n except:\n print 'warning: unable to repair catalog entry\\n %s\\n in\\n %s' % \\\n (code,catalog_path)\n return \n if writable_cat.has_key(code):\n print 'repairing catalog by removing key'\n del writable_cat[code]\n \n # it is possible that the path key doesn't exist (if the function registered\n # was a built-in function), so we have to check if the path exists before\n # arbitrarily deleting it.\n path_key = self.path_key(code) \n if writable_cat.has_key(path_key):\n del writable_cat[path_key] \n \n def get_functions_fast(self,code):\n \"\"\" Return list of functions for code from the cache.\n \n Return an empty list if the code entry is not found.\n \"\"\"\n return self.cache.get(code,[])\n \n def get_functions(self,code,module_dir=None):\n \"\"\" Return the list of functions associated with this code fragment.\n \n The cache is first searched for the function. If an entry\n in the cache is not found, then catalog files on disk are \n searched for the entry. This is slooooow, but only happens\n once per code object. All the functions found in catalog files\n on a cache miss are loaded into the cache to speed up future calls.\n The search order is as follows:\n \n 1. user specified path (from catalog initialization)\n 2. directories from the PYTHONCOMPILED environment variable\n 3. The temporary directory on your platform.\n\n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n # Fast!! try cache first.\n if self.cache.has_key(code):\n return self.cache[code]\n \n # 2. Slow!! read previously compiled functions from disk.\n try:\n self.set_module_directory(module_dir)\n function_list = self.get_cataloged_functions(code)\n # put function_list in cache to save future lookups.\n if function_list:\n self.cache[code] = function_list\n # return function_list, empty or otherwise.\n finally:\n self.clear_module_directory()\n return function_list\n\n def add_function(self,code,function,module_dir=None):\n \"\"\" Adds a function to the catalog.\n \n The function is added to the cache as well as the first\n writable file catalog found in the search path. If no\n code entry exists in the cache, the on disk catalogs\n are loaded into the cache and function is added to the\n beginning of the function list.\n \n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n\n # 1. put it in the cache.\n if self.cache.has_key(code):\n if function not in self.cache[code]:\n self.cache[code].insert(0,function)\n else:\n # if it is in the cache, then it is also\n # been persisted \n return\n else: \n # Load functions and put this one up front\n self.cache[code] = self.get_functions(code) \n self.fast_cache(code,function)\n # 2. Store the function entry to disk. \n try:\n self.set_module_directory(module_dir)\n self.add_function_persistent(code,function)\n finally:\n self.clear_module_directory()\n \n def add_function_persistent(self,code,function):\n \"\"\" Store the code->function relationship to disk.\n \n Two pieces of information are needed for loading functions\n from disk -- the function pickle (which conveniently stores\n the module name, etc.) and the path to its module's directory.\n The latter is needed so that the function can be loaded no\n matter what the user's Python path is.\n \"\"\" \n # add function to data in first writable catalog\n mode = 'c' # create if doesn't exist, otherwise, use existing\n cat_dir = self.get_writable_dir()\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n cat_dir = default_dir()\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n cat_dir = default_dir() \n cat_file = catalog_path(cat_dir)\n print 'problems with default catalog -- removing'\n import glob\n files = glob.glob(cat_file+'*')\n for f in files:\n os.remove(f)\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n raise ValueError, 'Failed to access a catalog for storing functions' \n # Prabhu was getting some corrupt catalog errors. I'll put a try/except\n # to protect against this, but should really try and track down the issue.\n function_list = [function]\n try:\n function_list = function_list + cat.get(code,[])\n except pickle.UnpicklingError:\n pass\n cat[code] = function_list\n # now add needed path information for loading function\n module = getmodule(function)\n try:\n # built in modules don't have the __file__ extension, so this\n # will fail. Just pass in this case since path additions aren't\n # needed for built-in modules.\n mod_path,f=os.path.split(os.path.abspath(module.__file__))\n pkey = self.path_key(code)\n cat[pkey] = [mod_path] + cat.get(pkey,[])\n except:\n pass\n\n def fast_cache(self,code,function):\n \"\"\" Move function to the front of the cache entry for code\n \n If future calls to the function have the same type signature,\n this will speed up access significantly because the first\n function call is correct.\n \n Note: The cache added to the inline_tools module is significantly\n faster than always calling get_functions, so this isn't\n as necessary as it used to be. Still, it's probably worth\n doing. \n \"\"\"\n try:\n if self.cache[code][0] == function:\n return\n except: # KeyError, IndexError \n pass\n try:\n self.cache[code].remove(function)\n except ValueError:\n pass\n # put new function at the beginning of the list to search.\n self.cache[code].insert(0,function)\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "methods": [ { "name": "getmodule", "long_name": "getmodule( object )", "filename": "catalog.py", "nloc": 13, "complexity": 7, "token_count": 79, "parameters": [ "object" ], "start_line": 53, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expr_to_filename", "long_name": "expr_to_filename( expr )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "expr" ], "start_line": 80, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "unique_file", "long_name": "unique_file( d , expr )", "filename": "catalog.py", "nloc": 13, "complexity": 8, "token_count": 89, "parameters": [ "d", "expr" ], "start_line": 91, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "create_dir", "long_name": "create_dir( p )", "filename": "catalog.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "p" ], "start_line": 115, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "is_writable", "long_name": "is_writable( dir )", "filename": "catalog.py", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [ "dir" ], "start_line": 129, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "whoami", "long_name": "whoami( )", "filename": "catalog.py", "nloc": 2, "complexity": 3, "token_count": 25, "parameters": [], "start_line": 138, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "default_dir", "long_name": "default_dir( )", "filename": "catalog.py", "nloc": 17, "complexity": 5, "token_count": 141, "parameters": [], "start_line": 142, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "intermediate_dir", "long_name": "intermediate_dir( )", "filename": "catalog.py", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [], "start_line": 181, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "default_temp_dir", "long_name": "default_temp_dir( )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 56, "parameters": [], "start_line": 191, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "os_dependent_catalog_name", "long_name": "os_dependent_catalog_name( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 202, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "catalog_path", "long_name": "catalog_path( module_path )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 105, "parameters": [ "module_path" ], "start_line": 216, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "get_catalog", "long_name": "get_catalog( module_path , mode = 'r' )", "filename": "catalog.py", "nloc": 13, "complexity": 6, "token_count": 80, "parameters": [ "module_path", "mode" ], "start_line": 243, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , user_path_list = None )", "filename": "catalog.py", "nloc": 10, "complexity": 3, "token_count": 60, "parameters": [ "self", "user_path_list" ], "start_line": 299, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "set_module_directory", "long_name": "set_module_directory( self , module_dir )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "module_dir" ], "start_line": 316, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_module_directory", "long_name": "get_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 323, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_module_directory", "long_name": "clear_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_environ_path", "long_name": "get_environ_path( self )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 332, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "build_search_order", "long_name": "build_search_order( self )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 62, "parameters": [ "self" ], "start_line": 348, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_catalog_files", "long_name": "get_catalog_files( self )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 372, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_existing_files", "long_name": "get_existing_files( self )", "filename": "catalog.py", "nloc": 7, "complexity": 3, "token_count": 48, "parameters": [ "self" ], "start_line": 383, "end_line": 396, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "get_writable_file.file_test", "long_name": "get_writable_file.file_test( x )", "filename": "catalog.py", "nloc": 4, "complexity": 3, "token_count": 43, "parameters": [ "x" ], "start_line": 410, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "get_writable_file", "long_name": "get_writable_file( self , existing_only = 0 )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 55, "parameters": [ "self", "existing_only" ], "start_line": 398, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_writable_dir", "long_name": "get_writable_dir( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 421, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "unique_module_name", "long_name": "unique_module_name( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "self", "code", "module_dir" ], "start_line": 428, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "path_key", "long_name": "path_key( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "code" ], "start_line": 445, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "configure_path", "long_name": "configure_path( self , cat , code )", "filename": "catalog.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "cat", "code" ], "start_line": 450, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "unconfigure_path", "long_name": "unconfigure_path( self )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 464, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_cataloged_functions", "long_name": "get_cataloged_functions( self , code )", "filename": "catalog.py", "nloc": 15, "complexity": 5, "token_count": 86, "parameters": [ "self", "code" ], "start_line": 472, "end_line": 501, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "repair_catalog", "long_name": "repair_catalog( self , catalog_path , code )", "filename": "catalog.py", "nloc": 16, "complexity": 5, "token_count": 83, "parameters": [ "self", "catalog_path", "code" ], "start_line": 504, "end_line": 534, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_functions_fast", "long_name": "get_functions_fast( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "code" ], "start_line": 536, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_functions", "long_name": "get_functions( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 65, "parameters": [ "self", "code", "module_dir" ], "start_line": 543, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , code , function , module_dir = None )", "filename": "catalog.py", "nloc": 14, "complexity": 4, "token_count": 97, "parameters": [ "self", "code", "function", "module_dir" ], "start_line": 577, "end_line": 608, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "add_function_persistent", "long_name": "add_function_persistent( self , code , function )", "filename": "catalog.py", "nloc": 31, "complexity": 7, "token_count": 194, "parameters": [ "self", "code", "function" ], "start_line": 610, "end_line": 655, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "fast_cache", "long_name": "fast_cache( self , code , function )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 59, "parameters": [ "self", "code", "function" ], "start_line": 657, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 681, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 685, "end_line": 687, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "getmodule", "long_name": "getmodule( object )", "filename": "catalog.py", "nloc": 13, "complexity": 7, "token_count": 79, "parameters": [ "object" ], "start_line": 53, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expr_to_filename", "long_name": "expr_to_filename( expr )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "expr" ], "start_line": 80, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "unique_file", "long_name": "unique_file( d , expr )", "filename": "catalog.py", "nloc": 13, "complexity": 8, "token_count": 89, "parameters": [ "d", "expr" ], "start_line": 91, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "create_dir", "long_name": "create_dir( p )", "filename": "catalog.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "p" ], "start_line": 115, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "is_writable", "long_name": "is_writable( dir )", "filename": "catalog.py", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [ "dir" ], "start_line": 129, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "whoami", "long_name": "whoami( )", "filename": "catalog.py", "nloc": 2, "complexity": 3, "token_count": 25, "parameters": [], "start_line": 138, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "default_dir", "long_name": "default_dir( )", "filename": "catalog.py", "nloc": 17, "complexity": 5, "token_count": 141, "parameters": [], "start_line": 142, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 0 }, { "name": "intermediate_dir", "long_name": "intermediate_dir( )", "filename": "catalog.py", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [], "start_line": 176, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "default_temp_dir", "long_name": "default_temp_dir( )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 56, "parameters": [], "start_line": 186, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "os_dependent_catalog_name", "long_name": "os_dependent_catalog_name( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 197, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "catalog_path", "long_name": "catalog_path( module_path )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 105, "parameters": [ "module_path" ], "start_line": 211, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "get_catalog", "long_name": "get_catalog( module_path , mode = 'r' )", "filename": "catalog.py", "nloc": 13, "complexity": 6, "token_count": 80, "parameters": [ "module_path", "mode" ], "start_line": 238, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , user_path_list = None )", "filename": "catalog.py", "nloc": 10, "complexity": 3, "token_count": 60, "parameters": [ "self", "user_path_list" ], "start_line": 294, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "set_module_directory", "long_name": "set_module_directory( self , module_dir )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "module_dir" ], "start_line": 311, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_module_directory", "long_name": "get_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 318, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_module_directory", "long_name": "clear_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 322, "end_line": 325, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_environ_path", "long_name": "get_environ_path( self )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 327, "end_line": 341, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "build_search_order", "long_name": "build_search_order( self )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 62, "parameters": [ "self" ], "start_line": 343, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_catalog_files", "long_name": "get_catalog_files( self )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 367, "end_line": 376, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_existing_files", "long_name": "get_existing_files( self )", "filename": "catalog.py", "nloc": 7, "complexity": 3, "token_count": 48, "parameters": [ "self" ], "start_line": 378, "end_line": 391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "get_writable_file.file_test", "long_name": "get_writable_file.file_test( x )", "filename": "catalog.py", "nloc": 4, "complexity": 3, "token_count": 43, "parameters": [ "x" ], "start_line": 405, "end_line": 408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "get_writable_file", "long_name": "get_writable_file( self , existing_only = 0 )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 55, "parameters": [ "self", "existing_only" ], "start_line": 393, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_writable_dir", "long_name": "get_writable_dir( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 416, "end_line": 421, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "unique_module_name", "long_name": "unique_module_name( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "self", "code", "module_dir" ], "start_line": 423, "end_line": 438, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "path_key", "long_name": "path_key( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "code" ], "start_line": 440, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "configure_path", "long_name": "configure_path( self , cat , code )", "filename": "catalog.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "cat", "code" ], "start_line": 445, "end_line": 457, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "unconfigure_path", "long_name": "unconfigure_path( self )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 459, "end_line": 465, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_cataloged_functions", "long_name": "get_cataloged_functions( self , code )", "filename": "catalog.py", "nloc": 15, "complexity": 5, "token_count": 86, "parameters": [ "self", "code" ], "start_line": 467, "end_line": 496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "repair_catalog", "long_name": "repair_catalog( self , catalog_path , code )", "filename": "catalog.py", "nloc": 16, "complexity": 5, "token_count": 83, "parameters": [ "self", "catalog_path", "code" ], "start_line": 499, "end_line": 529, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_functions_fast", "long_name": "get_functions_fast( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "code" ], "start_line": 531, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_functions", "long_name": "get_functions( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 65, "parameters": [ "self", "code", "module_dir" ], "start_line": 538, "end_line": 570, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , code , function , module_dir = None )", "filename": "catalog.py", "nloc": 14, "complexity": 4, "token_count": 97, "parameters": [ "self", "code", "function", "module_dir" ], "start_line": 572, "end_line": 603, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "add_function_persistent", "long_name": "add_function_persistent( self , code , function )", "filename": "catalog.py", "nloc": 31, "complexity": 7, "token_count": 194, "parameters": [ "self", "code", "function" ], "start_line": 605, "end_line": 650, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "fast_cache", "long_name": "fast_cache( self , code , function )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 59, "parameters": [ "self", "code", "function" ], "start_line": 652, "end_line": 674, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 676, "end_line": 678, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 680, "end_line": 682, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "default_dir", "long_name": "default_dir( )", "filename": "catalog.py", "nloc": 17, "complexity": 5, "token_count": 141, "parameters": [], "start_line": 142, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 } ], "nloc": 368, "complexity": 108, "token_count": 2034, "diff_parsed": { "added": [ "", " # add a subdirectory for the OS.", " # It might be better to do this at a different location so that", " # it wasn't only the default directory that gets this behavior.", " #path = os.path.join(path,sys.platform)" ], "deleted": [] } }, { "old_path": "weave/platform_info.py", "new_path": "weave/platform_info.py", "filename": "platform_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -128,6 +128,9 @@ def choose_compiler(compiler_name=''):\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n+ if not compiler_name:\n+ compiler_name = ''\n+ \n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n", "added_lines": 3, "deleted_lines": 0, "source_code": "\"\"\" Information about platform and python version and compilers\n\n This information is manly used to build directory names that\n keep the object files and shared libaries straight when\n multiple platforms share the same file system.\n\"\"\"\n\nimport os, sys\n\nimport distutils\nfrom distutils.core import Extension, setup\nfrom distutils.command.build_ext import build_ext\nfrom distutils.sysconfig import customize_compiler\nfrom distutils.ccompiler import new_compiler\n\nimport distutils.bcppcompiler\n\n#from scipy_distutils import mingw32_support\n\ndef dummy_dist():\n # create a dummy distribution. It will look at any site configuration files\n # and parse the command line to pick up any user configured stuff. The \n # resulting Distribution object is returned from setup.\n # Setting _setup_stop_after prevents the any commands from actually executing.\n distutils.core._setup_stop_after = \"commandline\"\n dist = setup(name=\"dummy\")\n distutils.core._setup_stop_after = None\n return dist\n\ndef create_compiler_instance(dist): \n # build_ext is in charge of building C/C++ files.\n # We are using it and dist to parse config files, and command line \n # configurations. There may be other ways to handle this, but I'm\n # worried I may miss one of the steps in distutils if I do it my self.\n #ext_builder = build_ext(dist)\n #ext_builder.finalize_options ()\n \n # For some reason the build_ext stuff wasn't picking up the compiler \n # setting, so we grab it manually from the distribution object instead.\n opts = dist.command_options.get('build_ext',None)\n compiler_name = ''\n if opts:\n comp = opts.get('compiler',('',''))\n compiler_name = comp[1]\n \n # Create a new compiler, customize it based on the build settings,\n # and return it. \n if not compiler_name:\n compiler_name = None\n compiler = new_compiler(compiler=compiler_name)\n customize_compiler(compiler)\n return compiler\n\ndef compiler_exe_name(compiler): \n exe_name = ''\n # this is really ugly... Why aren't the attribute names \n # standardized and used in a consistent way?\n if hasattr(compiler, \"compiler\"):\n # standard unix format\n exe_name = compiler.compiler[0]\n elif hasattr(compiler, \"cc\"):\n exe_name = compiler.cc\n elif compiler.__class__ is distutils.bcppcompiler.BCPPCompiler:\n exe_name = 'brcc32'\n return exe_name\n\ndef compiler_exe_path(exe_name):\n exe_path = None\n if os.path.exists(exe_name):\n exe_path = exe_name\n else:\n path_string = os.environ['PATH']\n path_string = os.path.expandvars(path_string)\n path_string = os.path.expanduser(path_string)\n paths = path_string.split(os.pathsep)\n for path in paths:\n path = os.path.join(path,exe_name)\n if os.path.exists(path):\n exe_path = path\n break \n # needed to catch gcc on mingw32 installations. \n path = path + '.exe' \n if os.path.exists(path):\n exe_path = path\n break\n return exe_path\n\ndef check_sum(file):\n \n import md5\n try:\n f = open(file,'r')\n bytes = f.read(-1)\n except IOError:\n bytes = '' \n chk_sum = md5.md5(bytes)\n return chk_sum.hexdigest()\n\ndef get_compiler_dir(compiler_name):\n \"\"\" Try to figure out the compiler directory based on the\n input compiler name. This is fragile and really should\n be done at the distutils level inside the compiler. I\n think it is only useful on windows at the moment.\n \"\"\"\n compiler_type = choose_compiler(compiler_name)\n #print compiler_type\n configure_sys_argv(compiler_type)\n #print sys.argv\n dist = dummy_dist() \n compiler_obj = create_compiler_instance(dist)\n #print compiler_obj.__class__\n exe_name = compiler_exe_name(compiler_obj)\n exe_path = compiler_exe_path(exe_name)\n if not exe_path:\n raise ValueError, \"The '%s' compiler was not found.\" % compiler_name\n chk_sum = check_sum(exe_path) \n restore_sys_argv()\n \n return 'compiler_'+chk_sum\n\n#----------------------------------------------------------------------------\n# Not needed -- used for testing.\n#----------------------------------------------------------------------------\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if not compiler_name:\n compiler_name = ''\n \n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n\nold_argv = []\ndef configure_sys_argv(compiler_name):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--compiler='+compiler_name]\n\ndef restore_sys_argv():\n sys.argv = old_argv\n\ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_versions()\n if version:\n result = 1\n return result\n\nif __name__ == \"__main__\":\n \"\"\"\n import time\n t1 = time.time() \n dist = dummy_dist() \n compiler_obj = create_compiler_instance(dist)\n exe_name = compiler_exe_name(compiler_obj)\n exe_path = compiler_exe_path(exe_name)\n chk_sum = check_sum(exe_path) \n \n t2 = time.time()\n print 'compiler exe:', exe_path\n print 'check sum:', chk_sum\n print 'time (sec):', t2 - t1\n print\n \"\"\"\n path = get_compiler_dir('gcc')\n print 'gcc path:', path\n print\n try: \n path = get_compiler_dir('msvc')\n print 'gcc path:', path\n except ValueError:\n pass ", "source_code_before": "\"\"\" Information about platform and python version and compilers\n\n This information is manly used to build directory names that\n keep the object files and shared libaries straight when\n multiple platforms share the same file system.\n\"\"\"\n\nimport os, sys\n\nimport distutils\nfrom distutils.core import Extension, setup\nfrom distutils.command.build_ext import build_ext\nfrom distutils.sysconfig import customize_compiler\nfrom distutils.ccompiler import new_compiler\n\nimport distutils.bcppcompiler\n\n#from scipy_distutils import mingw32_support\n\ndef dummy_dist():\n # create a dummy distribution. It will look at any site configuration files\n # and parse the command line to pick up any user configured stuff. The \n # resulting Distribution object is returned from setup.\n # Setting _setup_stop_after prevents the any commands from actually executing.\n distutils.core._setup_stop_after = \"commandline\"\n dist = setup(name=\"dummy\")\n distutils.core._setup_stop_after = None\n return dist\n\ndef create_compiler_instance(dist): \n # build_ext is in charge of building C/C++ files.\n # We are using it and dist to parse config files, and command line \n # configurations. There may be other ways to handle this, but I'm\n # worried I may miss one of the steps in distutils if I do it my self.\n #ext_builder = build_ext(dist)\n #ext_builder.finalize_options ()\n \n # For some reason the build_ext stuff wasn't picking up the compiler \n # setting, so we grab it manually from the distribution object instead.\n opts = dist.command_options.get('build_ext',None)\n compiler_name = ''\n if opts:\n comp = opts.get('compiler',('',''))\n compiler_name = comp[1]\n \n # Create a new compiler, customize it based on the build settings,\n # and return it. \n if not compiler_name:\n compiler_name = None\n compiler = new_compiler(compiler=compiler_name)\n customize_compiler(compiler)\n return compiler\n\ndef compiler_exe_name(compiler): \n exe_name = ''\n # this is really ugly... Why aren't the attribute names \n # standardized and used in a consistent way?\n if hasattr(compiler, \"compiler\"):\n # standard unix format\n exe_name = compiler.compiler[0]\n elif hasattr(compiler, \"cc\"):\n exe_name = compiler.cc\n elif compiler.__class__ is distutils.bcppcompiler.BCPPCompiler:\n exe_name = 'brcc32'\n return exe_name\n\ndef compiler_exe_path(exe_name):\n exe_path = None\n if os.path.exists(exe_name):\n exe_path = exe_name\n else:\n path_string = os.environ['PATH']\n path_string = os.path.expandvars(path_string)\n path_string = os.path.expanduser(path_string)\n paths = path_string.split(os.pathsep)\n for path in paths:\n path = os.path.join(path,exe_name)\n if os.path.exists(path):\n exe_path = path\n break \n # needed to catch gcc on mingw32 installations. \n path = path + '.exe' \n if os.path.exists(path):\n exe_path = path\n break\n return exe_path\n\ndef check_sum(file):\n \n import md5\n try:\n f = open(file,'r')\n bytes = f.read(-1)\n except IOError:\n bytes = '' \n chk_sum = md5.md5(bytes)\n return chk_sum.hexdigest()\n\ndef get_compiler_dir(compiler_name):\n \"\"\" Try to figure out the compiler directory based on the\n input compiler name. This is fragile and really should\n be done at the distutils level inside the compiler. I\n think it is only useful on windows at the moment.\n \"\"\"\n compiler_type = choose_compiler(compiler_name)\n #print compiler_type\n configure_sys_argv(compiler_type)\n #print sys.argv\n dist = dummy_dist() \n compiler_obj = create_compiler_instance(dist)\n #print compiler_obj.__class__\n exe_name = compiler_exe_name(compiler_obj)\n exe_path = compiler_exe_path(exe_name)\n if not exe_path:\n raise ValueError, \"The '%s' compiler was not found.\" % compiler_name\n chk_sum = check_sum(exe_path) \n restore_sys_argv()\n \n return 'compiler_'+chk_sum\n\n#----------------------------------------------------------------------------\n# Not needed -- used for testing.\n#----------------------------------------------------------------------------\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n\nold_argv = []\ndef configure_sys_argv(compiler_name):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--compiler='+compiler_name]\n\ndef restore_sys_argv():\n sys.argv = old_argv\n\ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_versions()\n if version:\n result = 1\n return result\n\nif __name__ == \"__main__\":\n \"\"\"\n import time\n t1 = time.time() \n dist = dummy_dist() \n compiler_obj = create_compiler_instance(dist)\n exe_name = compiler_exe_name(compiler_obj)\n exe_path = compiler_exe_path(exe_name)\n chk_sum = check_sum(exe_path) \n \n t2 = time.time()\n print 'compiler exe:', exe_path\n print 'check sum:', chk_sum\n print 'time (sec):', t2 - t1\n print\n \"\"\"\n path = get_compiler_dir('gcc')\n print 'gcc path:', path\n print\n try: \n path = get_compiler_dir('msvc')\n print 'gcc path:', path\n except ValueError:\n pass ", "methods": [ { "name": "dummy_dist", "long_name": "dummy_dist( )", "filename": "platform_info.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [], "start_line": 20, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "create_compiler_instance", "long_name": "create_compiler_instance( dist )", "filename": "platform_info.py", "nloc": 11, "complexity": 3, "token_count": 64, "parameters": [ "dist" ], "start_line": 30, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "compiler_exe_name", "long_name": "compiler_exe_name( compiler )", "filename": "platform_info.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "compiler" ], "start_line": 54, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "compiler_exe_path", "long_name": "compiler_exe_path( exe_name )", "filename": "platform_info.py", "nloc": 19, "complexity": 5, "token_count": 113, "parameters": [ "exe_name" ], "start_line": 67, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "check_sum", "long_name": "check_sum( file )", "filename": "platform_info.py", "nloc": 9, "complexity": 2, "token_count": 46, "parameters": [ "file" ], "start_line": 88, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "get_compiler_dir", "long_name": "get_compiler_dir( compiler_name )", "filename": "platform_info.py", "nloc": 12, "complexity": 2, "token_count": 62, "parameters": [ "compiler_name" ], "start_line": 99, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "platform_info.py", "nloc": 15, "complexity": 8, "token_count": 62, "parameters": [ "compiler_name" ], "start_line": 125, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name )", "filename": "platform_info.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "compiler_name" ], "start_line": 152, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "platform_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 159, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "platform_info.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 162, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "platform_info.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 184, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 } ], "methods_before": [ { "name": "dummy_dist", "long_name": "dummy_dist( )", "filename": "platform_info.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [], "start_line": 20, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "create_compiler_instance", "long_name": "create_compiler_instance( dist )", "filename": "platform_info.py", "nloc": 11, "complexity": 3, "token_count": 64, "parameters": [ "dist" ], "start_line": 30, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "compiler_exe_name", "long_name": "compiler_exe_name( compiler )", "filename": "platform_info.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "compiler" ], "start_line": 54, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "compiler_exe_path", "long_name": "compiler_exe_path( exe_name )", "filename": "platform_info.py", "nloc": 19, "complexity": 5, "token_count": 113, "parameters": [ "exe_name" ], "start_line": 67, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "check_sum", "long_name": "check_sum( file )", "filename": "platform_info.py", "nloc": 9, "complexity": 2, "token_count": 46, "parameters": [ "file" ], "start_line": 88, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "get_compiler_dir", "long_name": "get_compiler_dir( compiler_name )", "filename": "platform_info.py", "nloc": 12, "complexity": 2, "token_count": 62, "parameters": [ "compiler_name" ], "start_line": 99, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "platform_info.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 125, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name )", "filename": "platform_info.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "compiler_name" ], "start_line": 149, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "platform_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 156, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "platform_info.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 159, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "platform_info.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 181, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "platform_info.py", "nloc": 15, "complexity": 8, "token_count": 62, "parameters": [ "compiler_name" ], "start_line": 125, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 } ], "nloc": 150, "complexity": 34, "token_count": 692, "diff_parsed": { "added": [ " if not compiler_name:", " compiler_name = ''", "" ], "deleted": [] } }, { "old_path": "weave/tests/test_blitz_tools.py", "new_path": "weave/tests/test_blitz_tools.py", "filename": "test_blitz_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -98,7 +98,7 @@ def generic_test(self,expr,arg_dict,type,size,mod_location):\n raise AssertionError \n return standard,compiled\n \n- def generic_2d(self,expr):\n+ def generic_2d(self,expr,typ):\n \"\"\" The complex testing is pretty lame...\n \"\"\"\n mod_location = empty_temp_dir()\n@@ -106,48 +106,77 @@ def generic_2d(self,expr):\n ast = parser.suite(expr)\n arg_list = harvest_variables(ast.tolist())\n #print arg_list\n- all_types = [Float32,Float64,Complex32,Complex64]\n all_sizes = [(10,10), (50,50), (100,100), (500,500), (1000,1000)]\n print '\\nExpression:', expr\n- for typ in all_types:\n- for size in all_sizes:\n- result = zeros(size,typ)\n- arg_dict = {}\n- for arg in arg_list:\n- arg_dict[arg] = RandomArray.normal(0,1,size).astype(typ)\n- arg_dict[arg].savespace(1)\n- # set imag part of complex values to non-zero value\n- try: arg_dict[arg].imag = arg_dict[arg].real\n- except: pass \n- print 'Run:', size,typ\n- standard,compiled = self.generic_test(expr,arg_dict,type,size,\n- mod_location)\n- try:\n- speed_up = standard/compiled\n- except:\n- speed_up = -1.\n- print \"1st run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\\n- \"%3.4f\" % (standard,compiled,speed_up) \n- standard,compiled = self.generic_test(expr,arg_dict,type,size,\n- mod_location)\n- try:\n- speed_up = standard/compiled\n- except:\n- speed_up = -1. \n- print \"2nd run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\\n- \"%3.4f\" % (standard,compiled,speed_up)\n+ for size in all_sizes:\n+ result = zeros(size,typ)\n+ arg_dict = {}\n+ for arg in arg_list:\n+ arg_dict[arg] = RandomArray.normal(0,1,size).astype(typ)\n+ arg_dict[arg].savespace(1)\n+ # set imag part of complex values to non-zero value\n+ try: arg_dict[arg].imag = arg_dict[arg].real\n+ except: pass \n+ print 'Run:', size,typ\n+ standard,compiled = self.generic_test(expr,arg_dict,type,size,\n+ mod_location)\n+ try:\n+ speed_up = standard/compiled\n+ except:\n+ speed_up = -1.\n+ print \"1st run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\\n+ \"%3.4f\" % (standard,compiled,speed_up) \n+ standard,compiled = self.generic_test(expr,arg_dict,type,size,\n+ mod_location)\n+ try:\n+ speed_up = standard/compiled\n+ except:\n+ speed_up = -1. \n+ print \"2nd run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\\n+ \"%3.4f\" % (standard,compiled,speed_up)\n cleanup_temp_dir(mod_location) \n #def check_simple_2d(self):\n # \"\"\" result = a + b\"\"\" \n # expr = \"result = a + b\"\n # self.generic_2d(expr)\n- def check_5point_avg_2d(self):\n+ def check_5point_avg_2d_float(self):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n- self.generic_2d(expr)\n+ self.generic_2d(expr,Float32)\n+ def check_5point_avg_2d_double(self):\n+ \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n+ + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n+ \"\"\" \n+ expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n+ \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n+ self.generic_2d(expr,Float64)\n+ def check_5point_avg_2d_complex_float(self):\n+ \"\"\" Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. It will not adversely affect 99.99 percent of weave \n+ \n+ result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n+ + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n+ \n+ Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. The reason is that \n+ 5. is a double and b is a complex32. blitz doesn't know \n+ how to handle complex32/double. See:\n+ http://www.oonumerics.org/MailArchives/blitz-support/msg00541.php\n+ Unfortunately, the fix isn't trivial. Instead of fixing it, I\n+ prefer to wait until we replace blitz++ with Pat Miller's code \n+ that doesn't rely on blitz..\n+ \"\"\" \n+ expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n+ \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n+ self.generic_2d(expr,Complex32)\n+ def check_5point_avg_2d_complex_double(self):\n+ \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n+ + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n+ \"\"\" \n+ expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n+ \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n+ self.generic_2d(expr,Complex64)\n \n def test_suite(level=1):\n suites = []\n", "added_lines": 60, "deleted_lines": 31, "source_code": "import unittest\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # scipy_base.fastumath not available \nimport RandomArray\nimport os\nimport time\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path,restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport blitz_tools\nfrom ast_tools import *\nfrom weave_test_utils import *\nrestore_path()\n\nclass test_ast_to_blitz_expr(unittest.TestCase):\n\n def generic_test(self,expr,desired):\n import parser\n ast = parser.suite(expr)\n ast_list = ast.tolist()\n actual = blitz_tools.ast_to_blitz_expr(ast_list)\n actual = remove_whitespace(actual)\n desired = remove_whitespace(desired)\n print_assert_equal(expr,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"convert simple expr to blitz\n \n a[:1:2] = b[:1+i+2:]\n \"\"\"\n expr = \"a[:1:2] = b[:1+i+2:]\" \n desired = \"a(blitz::Range(_beg,1-1,2))=\"\\\n \"b(blitz::Range(_beg,1+i+2-1));\"\n self.generic_test(expr,desired)\n\n def check_fdtd_expr(self):\n \"\"\" convert fdtd equation to blitz.\n ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:] \n + cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,:])\n - cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1]);\n Note: This really should have \"\\\" at the end of each line\n to indicate continuation. \n \"\"\"\n expr = \"ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,:])\"\\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n desired = 'ex(_all,blitz::Range(1,_end),blitz::Range(1,_end))='\\\n ' ca_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n ' *ex(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '+cb_y_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '*(hz(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n ' -hz(_all,blitz::Range(_beg,Nhz(1)-1-1),_all))'\\\n ' -cb_z_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '*(hy(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '-hy(_all,blitz::Range(1,_end),blitz::Range(_beg,Nhy(2)-1-1)));'\n self.generic_test(expr,desired)\n\nclass test_blitz(unittest.TestCase):\n \"\"\"* These are long running tests...\n \n I'd like to benchmark these things somehow.\n *\"\"\"\n def generic_test(self,expr,arg_dict,type,size,mod_location):\n clean_result = array(arg_dict['result'],copy=1)\n t1 = time.time()\n exec expr in globals(),arg_dict\n t2 = time.time()\n standard = t2 - t1\n desired = arg_dict['result']\n arg_dict['result'] = clean_result\n t1 = time.time()\n old_env = os.environ.get('PYTHONCOMPILED','')\n os.environ['PYTHONCOMPILED'] = mod_location\n blitz_tools.blitz(expr,arg_dict,{},verbose=0) #,\n #extra_compile_args = ['-O3','-malign-double','-funroll-loops'])\n os.environ['PYTHONCOMPILED'] = old_env\n t2 = time.time()\n compiled = t2 - t1\n actual = arg_dict['result']\n # this really should give more info...\n try:\n # this isn't very stringent. Need to tighten this up and\n # learn where failures are occuring.\n assert(allclose(abs(actual.flat),abs(desired.flat),1e-4,1e-6))\n except:\n diff = actual-desired\n print diff[:4,:4]\n print diff[:4,-4:]\n print diff[-4:,:4]\n print diff[-4:,-4:]\n print sum(abs(diff.flat)) \n raise AssertionError \n return standard,compiled\n \n def generic_2d(self,expr,typ):\n \"\"\" The complex testing is pretty lame...\n \"\"\"\n mod_location = empty_temp_dir()\n import parser\n ast = parser.suite(expr)\n arg_list = harvest_variables(ast.tolist())\n #print arg_list\n all_sizes = [(10,10), (50,50), (100,100), (500,500), (1000,1000)]\n print '\\nExpression:', expr\n for size in all_sizes:\n result = zeros(size,typ)\n arg_dict = {}\n for arg in arg_list:\n arg_dict[arg] = RandomArray.normal(0,1,size).astype(typ)\n arg_dict[arg].savespace(1)\n # set imag part of complex values to non-zero value\n try: arg_dict[arg].imag = arg_dict[arg].real\n except: pass \n print 'Run:', size,typ\n standard,compiled = self.generic_test(expr,arg_dict,type,size,\n mod_location)\n try:\n speed_up = standard/compiled\n except:\n speed_up = -1.\n print \"1st run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\\n \"%3.4f\" % (standard,compiled,speed_up) \n standard,compiled = self.generic_test(expr,arg_dict,type,size,\n mod_location)\n try:\n speed_up = standard/compiled\n except:\n speed_up = -1. \n print \"2nd run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\\n \"%3.4f\" % (standard,compiled,speed_up)\n cleanup_temp_dir(mod_location) \n #def check_simple_2d(self):\n # \"\"\" result = a + b\"\"\" \n # expr = \"result = a + b\"\n # self.generic_2d(expr)\n def check_5point_avg_2d_float(self):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Float32)\n def check_5point_avg_2d_double(self):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Float64)\n def check_5point_avg_2d_complex_float(self):\n \"\"\" Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. It will not adversely affect 99.99 percent of weave \n \n result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \n Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. The reason is that \n 5. is a double and b is a complex32. blitz doesn't know \n how to handle complex32/double. See:\n http://www.oonumerics.org/MailArchives/blitz-support/msg00541.php\n Unfortunately, the fix isn't trivial. Instead of fixing it, I\n prefer to wait until we replace blitz++ with Pat Miller's code \n that doesn't rely on blitz..\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Complex32)\n def check_5point_avg_2d_complex_double(self):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Complex64)\n \ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_ast_to_blitz_expr,'check_') )\n if level >= 10:\n suites.append( unittest.makeSuite(test_blitz,'check_') ) \n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test(10)\n", "source_code_before": "import unittest\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # scipy_base.fastumath not available \nimport RandomArray\nimport os\nimport time\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path,restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport blitz_tools\nfrom ast_tools import *\nfrom weave_test_utils import *\nrestore_path()\n\nclass test_ast_to_blitz_expr(unittest.TestCase):\n\n def generic_test(self,expr,desired):\n import parser\n ast = parser.suite(expr)\n ast_list = ast.tolist()\n actual = blitz_tools.ast_to_blitz_expr(ast_list)\n actual = remove_whitespace(actual)\n desired = remove_whitespace(desired)\n print_assert_equal(expr,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"convert simple expr to blitz\n \n a[:1:2] = b[:1+i+2:]\n \"\"\"\n expr = \"a[:1:2] = b[:1+i+2:]\" \n desired = \"a(blitz::Range(_beg,1-1,2))=\"\\\n \"b(blitz::Range(_beg,1+i+2-1));\"\n self.generic_test(expr,desired)\n\n def check_fdtd_expr(self):\n \"\"\" convert fdtd equation to blitz.\n ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:] \n + cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,:])\n - cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1]);\n Note: This really should have \"\\\" at the end of each line\n to indicate continuation. \n \"\"\"\n expr = \"ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,:])\"\\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n desired = 'ex(_all,blitz::Range(1,_end),blitz::Range(1,_end))='\\\n ' ca_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n ' *ex(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '+cb_y_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '*(hz(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n ' -hz(_all,blitz::Range(_beg,Nhz(1)-1-1),_all))'\\\n ' -cb_z_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '*(hy(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '-hy(_all,blitz::Range(1,_end),blitz::Range(_beg,Nhy(2)-1-1)));'\n self.generic_test(expr,desired)\n\nclass test_blitz(unittest.TestCase):\n \"\"\"* These are long running tests...\n \n I'd like to benchmark these things somehow.\n *\"\"\"\n def generic_test(self,expr,arg_dict,type,size,mod_location):\n clean_result = array(arg_dict['result'],copy=1)\n t1 = time.time()\n exec expr in globals(),arg_dict\n t2 = time.time()\n standard = t2 - t1\n desired = arg_dict['result']\n arg_dict['result'] = clean_result\n t1 = time.time()\n old_env = os.environ.get('PYTHONCOMPILED','')\n os.environ['PYTHONCOMPILED'] = mod_location\n blitz_tools.blitz(expr,arg_dict,{},verbose=0) #,\n #extra_compile_args = ['-O3','-malign-double','-funroll-loops'])\n os.environ['PYTHONCOMPILED'] = old_env\n t2 = time.time()\n compiled = t2 - t1\n actual = arg_dict['result']\n # this really should give more info...\n try:\n # this isn't very stringent. Need to tighten this up and\n # learn where failures are occuring.\n assert(allclose(abs(actual.flat),abs(desired.flat),1e-4,1e-6))\n except:\n diff = actual-desired\n print diff[:4,:4]\n print diff[:4,-4:]\n print diff[-4:,:4]\n print diff[-4:,-4:]\n print sum(abs(diff.flat)) \n raise AssertionError \n return standard,compiled\n \n def generic_2d(self,expr):\n \"\"\" The complex testing is pretty lame...\n \"\"\"\n mod_location = empty_temp_dir()\n import parser\n ast = parser.suite(expr)\n arg_list = harvest_variables(ast.tolist())\n #print arg_list\n all_types = [Float32,Float64,Complex32,Complex64]\n all_sizes = [(10,10), (50,50), (100,100), (500,500), (1000,1000)]\n print '\\nExpression:', expr\n for typ in all_types:\n for size in all_sizes:\n result = zeros(size,typ)\n arg_dict = {}\n for arg in arg_list:\n arg_dict[arg] = RandomArray.normal(0,1,size).astype(typ)\n arg_dict[arg].savespace(1)\n # set imag part of complex values to non-zero value\n try: arg_dict[arg].imag = arg_dict[arg].real\n except: pass \n print 'Run:', size,typ\n standard,compiled = self.generic_test(expr,arg_dict,type,size,\n mod_location)\n try:\n speed_up = standard/compiled\n except:\n speed_up = -1.\n print \"1st run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\\n \"%3.4f\" % (standard,compiled,speed_up) \n standard,compiled = self.generic_test(expr,arg_dict,type,size,\n mod_location)\n try:\n speed_up = standard/compiled\n except:\n speed_up = -1. \n print \"2nd run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\\n \"%3.4f\" % (standard,compiled,speed_up)\n cleanup_temp_dir(mod_location) \n #def check_simple_2d(self):\n # \"\"\" result = a + b\"\"\" \n # expr = \"result = a + b\"\n # self.generic_2d(expr)\n def check_5point_avg_2d(self):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr)\n \ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_ast_to_blitz_expr,'check_') )\n if level >= 10:\n suites.append( unittest.makeSuite(test_blitz,'check_') ) \n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test(10)\n", "methods": [ { "name": "generic_test", "long_name": "generic_test( self , expr , desired )", "filename": "test_blitz_tools.py", "nloc": 8, "complexity": 1, "token_count": 54, "parameters": [ "self", "expr", "desired" ], "start_line": 23, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_simple_expr", "long_name": "check_simple_expr( self )", "filename": "test_blitz_tools.py", "nloc": 5, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 32, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_fdtd_expr", "long_name": "check_fdtd_expr( self )", "filename": "test_blitz_tools.py", "nloc": 14, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 42, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , expr , arg_dict , type , size , mod_location )", "filename": "test_blitz_tools.py", "nloc": 27, "complexity": 2, "token_count": 227, "parameters": [ "self", "expr", "arg_dict", "type", "size", "mod_location" ], "start_line": 69, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "generic_2d", "long_name": "generic_2d( self , expr , typ )", "filename": "test_blitz_tools.py", "nloc": 33, "complexity": 6, "token_count": 239, "parameters": [ "self", "expr", "typ" ], "start_line": 101, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d_float", "long_name": "check_5point_avg_2d_float( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 142, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d_double", "long_name": "check_5point_avg_2d_double( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 149, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d_complex_float", "long_name": "check_5point_avg_2d_complex_float( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 156, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d_complex_double", "long_name": "check_5point_avg_2d_complex_double( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 173, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_blitz_tools.py", "nloc": 8, "complexity": 3, "token_count": 57, "parameters": [ "level" ], "start_line": 181, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_blitz_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 190, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "generic_test", "long_name": "generic_test( self , expr , desired )", "filename": "test_blitz_tools.py", "nloc": 8, "complexity": 1, "token_count": 54, "parameters": [ "self", "expr", "desired" ], "start_line": 23, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_simple_expr", "long_name": "check_simple_expr( self )", "filename": "test_blitz_tools.py", "nloc": 5, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 32, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_fdtd_expr", "long_name": "check_fdtd_expr( self )", "filename": "test_blitz_tools.py", "nloc": 14, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 42, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , expr , arg_dict , type , size , mod_location )", "filename": "test_blitz_tools.py", "nloc": 27, "complexity": 2, "token_count": 227, "parameters": [ "self", "expr", "arg_dict", "type", "size", "mod_location" ], "start_line": 69, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "generic_2d", "long_name": "generic_2d( self , expr )", "filename": "test_blitz_tools.py", "nloc": 35, "complexity": 7, "token_count": 253, "parameters": [ "self", "expr" ], "start_line": 101, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d", "long_name": "check_5point_avg_2d( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 144, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_blitz_tools.py", "nloc": 8, "complexity": 3, "token_count": 57, "parameters": [ "level" ], "start_line": 152, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_blitz_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 161, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_5point_avg_2d_complex_float", "long_name": "check_5point_avg_2d_complex_float( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 156, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d_double", "long_name": "check_5point_avg_2d_double( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 149, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d_float", "long_name": "check_5point_avg_2d_float( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 142, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "generic_2d", "long_name": "generic_2d( self , expr )", "filename": "test_blitz_tools.py", "nloc": 35, "complexity": 7, "token_count": 253, "parameters": [ "self", "expr" ], "start_line": 101, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d", "long_name": "check_5point_avg_2d( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 144, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d_complex_double", "long_name": "check_5point_avg_2d_complex_double( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 173, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "generic_2d", "long_name": "generic_2d( self , expr , typ )", "filename": "test_blitz_tools.py", "nloc": 33, "complexity": 6, "token_count": 239, "parameters": [ "self", "expr", "typ" ], "start_line": 101, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 } ], "nloc": 140, "complexity": 19, "token_count": 834, "diff_parsed": { "added": [ " def generic_2d(self,expr,typ):", " for size in all_sizes:", " result = zeros(size,typ)", " arg_dict = {}", " for arg in arg_list:", " arg_dict[arg] = RandomArray.normal(0,1,size).astype(typ)", " arg_dict[arg].savespace(1)", " # set imag part of complex values to non-zero value", " try: arg_dict[arg].imag = arg_dict[arg].real", " except: pass", " print 'Run:', size,typ", " standard,compiled = self.generic_test(expr,arg_dict,type,size,", " mod_location)", " try:", " speed_up = standard/compiled", " except:", " speed_up = -1.", " print \"1st run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\", " \"%3.4f\" % (standard,compiled,speed_up)", " standard,compiled = self.generic_test(expr,arg_dict,type,size,", " mod_location)", " try:", " speed_up = standard/compiled", " except:", " speed_up = -1.", " print \"2nd run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\", " \"%3.4f\" % (standard,compiled,speed_up)", " def check_5point_avg_2d_float(self):", " self.generic_2d(expr,Float32)", " def check_5point_avg_2d_double(self):", " \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]", " + b[1:-1,2:] + b[1:-1,:-2]) / 5.", " \"\"\"", " expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\", " \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"", " self.generic_2d(expr,Float64)", " def check_5point_avg_2d_complex_float(self):", " \"\"\" Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. It will not adversely affect 99.99 percent of weave", "", " result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]", " + b[1:-1,2:] + b[1:-1,:-2]) / 5.", "", " Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. The reason is that", " 5. is a double and b is a complex32. blitz doesn't know", " how to handle complex32/double. See:", " http://www.oonumerics.org/MailArchives/blitz-support/msg00541.php", " Unfortunately, the fix isn't trivial. Instead of fixing it, I", " prefer to wait until we replace blitz++ with Pat Miller's code", " that doesn't rely on blitz..", " \"\"\"", " expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\", " \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"", " self.generic_2d(expr,Complex32)", " def check_5point_avg_2d_complex_double(self):", " \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]", " + b[1:-1,2:] + b[1:-1,:-2]) / 5.", " \"\"\"", " expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\", " \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"", " self.generic_2d(expr,Complex64)" ], "deleted": [ " def generic_2d(self,expr):", " all_types = [Float32,Float64,Complex32,Complex64]", " for typ in all_types:", " for size in all_sizes:", " result = zeros(size,typ)", " arg_dict = {}", " for arg in arg_list:", " arg_dict[arg] = RandomArray.normal(0,1,size).astype(typ)", " arg_dict[arg].savespace(1)", " # set imag part of complex values to non-zero value", " try: arg_dict[arg].imag = arg_dict[arg].real", " except: pass", " print 'Run:', size,typ", " standard,compiled = self.generic_test(expr,arg_dict,type,size,", " mod_location)", " try:", " speed_up = standard/compiled", " except:", " speed_up = -1.", " print \"1st run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\", " \"%3.4f\" % (standard,compiled,speed_up)", " standard,compiled = self.generic_test(expr,arg_dict,type,size,", " mod_location)", " try:", " speed_up = standard/compiled", " except:", " speed_up = -1.", " print \"2nd run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\", " \"%3.4f\" % (standard,compiled,speed_up)", " def check_5point_avg_2d(self):", " self.generic_2d(expr)" ] } } ] }, { "hash": "cdaf91ed9ac5583774ed958b797720db40b1c716", "msg": "sgi compiler class clean up. Added optimization hooks for MIPSpro compilers.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-01-05T20:15:03+00:00", "author_timezone": 0, "committer_date": "2003-01-05T20:15:03+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "fbb9934a9e786a6fe830294cf7368bee2cb65075" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 16, "insertions": 103, "lines": 119, "files": 2, "dmm_unit_size": 0.4186046511627907, "dmm_unit_complexity": 0.046511627906976744, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -771,7 +771,7 @@ class mips_fortran_compiler(fortran_compiler_base):\n \n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n- lib_ranlib = '' # XXX: should we use `ar -s' here?\n+ lib_ranlib = ''\n \n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n@@ -783,32 +783,46 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n \n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n- self.f77_opt = ' -O3 '\n+\n \n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n- self.f90_opt = ' ' \n \n- self.f90_fixed_switch = ' -fixedform '\n \n- self.ver_cmd = self.f77_compiler + ' -version '\n+ self.f90_fixed_switch = ' -fixedform '\n+ self.ver_cmd = self.f90_compiler + ' -version '\n \n- #self.libraries = ['fortran', 'ftn', 'm']\n- # -lfortran is redundant with MIPSPro 7.30\n- self.libraries = ['ftn', 'm']\n- self.library_dirs = self.find_lib_dir()\n+ self.f90_opt = self.get_opt()\n+ self.f77_opt = self.get_opt('f77')\n \n+ def get_opt(self,mode='f90'):\n+ import cpuinfo\n+ cpu = cpuinfo.cpuinfo()\n+ opt = ' -O3 '\n+ if self.get_version():\n+ r = None\n+ if cpu.is_r10000(): r = 10000\n+ elif cpu.is_r12000(): r = 12000\n+ elif cpu.is_r8000(): r = 8000\n+ elif cpu.is_r5000(): r = 5000\n+ elif cpu.is_r4000(): r = 4000\n+ if r is not None:\n+ if mode=='f77':\n+ opt = opt + ' r%s ' % (r)\n+ else:\n+ opt = opt + ' -r%s ' % (r)\n+ for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n+ if getattr(cpu,'is_IP%s'%a)():\n+ opt=opt+' -TARG:platform=IP%s ' % a\n+ break\n+ return opt\n \n def build_module_switch(self,module_dirs):\n res = ''\n return res \n- def find_lib_dir(self):\n- library_dirs = []\n- return library_dirs\n- def get_runtime_library_dirs(self):\n-\treturn self.find_lib_dir() \n- def get_extra_link_args(self):\n-\treturn []\n+\n+ def get_linker_so(self):\n+ return [self.f90_compiler,'-shared']\n \n class hpux_fortran_compiler(fortran_compiler_base):\n \n", "added_lines": 30, "deleted_lines": 16, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Sun|SGI|Intel|Itanium|NAG|Compaq|Digital|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,build_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,build_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.f90_fixed_switch = ' -ffixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Sun|SGI|Intel|Itanium|NAG|Compaq|Digital|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,build_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,build_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.f90_fixed_switch = ' -ffixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = '' # XXX: should we use `ar -s' here?\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n self.f90_opt = ' ' \n\n self.f90_fixed_switch = ' -fixedform '\n\n self.ver_cmd = self.f77_compiler + ' -version '\n\n #self.libraries = ['fortran', 'ftn', 'm']\n # -lfortran is redundant with MIPSPro 7.30\n self.libraries = ['ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 116, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 137, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 181, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 219, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 240, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 310, "end_line": 315, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 325, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 363, "end_line": 388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 390, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 422, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 429, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 434, "end_line": 456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 460, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 465, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 472, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 477, "end_line": 478, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 480, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 168, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 501, "end_line": 544, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 546, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 556, "end_line": 557, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 559, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 584, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 586, "end_line": 587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 588, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 590, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 592, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 599, "end_line": 600, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 33, "complexity": 5, "token_count": 195, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 608, "end_line": 652, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 654, "end_line": 659, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 661, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 123, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 695, "end_line": 734, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 736, "end_line": 741, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 743, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 763, "end_line": 764, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 766, "end_line": 767, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 96, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 776, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self , mode = 'f90' )", "filename": "build_flib.py", "nloc": 21, "complexity": 11, "token_count": 143, "parameters": [ "self", "mode" ], "start_line": 798, "end_line": 818, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 820, "end_line": 822, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 824, "end_line": 825, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 832, "end_line": 853, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 855, "end_line": 873, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 881, "end_line": 912, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 45, "complexity": 21, "token_count": 254, "parameters": [ "self" ], "start_line": 914, "end_line": 960, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 962, "end_line": 979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 981, "end_line": 988, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 990, "end_line": 998, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1000, "end_line": 1001, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1003, "end_line": 1004, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1014, "end_line": 1043, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1045, "end_line": 1059, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1061, "end_line": 1062, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1072, "end_line": 1075, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1083, "end_line": 1104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1106, "end_line": 1108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1110, "end_line": 1111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1125, "end_line": 1153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1159, "end_line": 1160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1173, "end_line": 1204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1206, "end_line": 1207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 104, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1215, "end_line": 1239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1241, "end_line": 1244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1246, "end_line": 1247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1264, "end_line": 1289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1291, "end_line": 1293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1297, "end_line": 1305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 116, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 137, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 181, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 219, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 240, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 310, "end_line": 315, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 325, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 363, "end_line": 388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 390, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 422, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 429, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 434, "end_line": 456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 460, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 465, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 472, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 477, "end_line": 478, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 480, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 168, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 501, "end_line": 544, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 546, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 556, "end_line": 557, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 559, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 584, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 586, "end_line": 587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 588, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 590, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 592, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 599, "end_line": 600, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 33, "complexity": 5, "token_count": 195, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 608, "end_line": 652, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 654, "end_line": 659, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 661, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 123, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 695, "end_line": 734, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 736, "end_line": 741, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 743, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 763, "end_line": 764, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 766, "end_line": 767, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 776, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 802, "end_line": 804, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 805, "end_line": 807, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 808, "end_line": 809, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 810, "end_line": 811, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 818, "end_line": 839, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 841, "end_line": 859, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 867, "end_line": 898, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 45, "complexity": 21, "token_count": 254, "parameters": [ "self" ], "start_line": 900, "end_line": 946, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 948, "end_line": 965, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 967, "end_line": 974, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 976, "end_line": 984, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 986, "end_line": 987, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 989, "end_line": 990, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1000, "end_line": 1029, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1031, "end_line": 1045, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1047, "end_line": 1048, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1058, "end_line": 1061, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1069, "end_line": 1090, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1092, "end_line": 1094, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1096, "end_line": 1097, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1111, "end_line": 1139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1145, "end_line": 1146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1159, "end_line": 1190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1192, "end_line": 1193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 104, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1201, "end_line": 1225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1227, "end_line": 1230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1232, "end_line": 1233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1250, "end_line": 1275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1277, "end_line": 1279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1283, "end_line": 1291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 96, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 776, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 824, "end_line": 825, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 805, "end_line": 807, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self , mode = 'f90' )", "filename": "build_flib.py", "nloc": 21, "complexity": 11, "token_count": 143, "parameters": [ "self", "mode" ], "start_line": 798, "end_line": 818, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 810, "end_line": 811, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 808, "end_line": 809, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "nloc": 953, "complexity": 244, "token_count": 5601, "diff_parsed": { "added": [ " lib_ranlib = ''", "", " self.f90_fixed_switch = ' -fixedform '", " self.ver_cmd = self.f90_compiler + ' -version '", " self.f90_opt = self.get_opt()", " self.f77_opt = self.get_opt('f77')", " def get_opt(self,mode='f90'):", " import cpuinfo", " cpu = cpuinfo.cpuinfo()", " opt = ' -O3 '", " if self.get_version():", " r = None", " if cpu.is_r10000(): r = 10000", " elif cpu.is_r12000(): r = 12000", " elif cpu.is_r8000(): r = 8000", " elif cpu.is_r5000(): r = 5000", " elif cpu.is_r4000(): r = 4000", " if r is not None:", " if mode=='f77':", " opt = opt + ' r%s ' % (r)", " else:", " opt = opt + ' -r%s ' % (r)", " for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():", " if getattr(cpu,'is_IP%s'%a)():", " opt=opt+' -TARG:platform=IP%s ' % a", " break", " return opt", "", " def get_linker_so(self):", " return [self.f90_compiler,'-shared']" ], "deleted": [ " lib_ranlib = '' # XXX: should we use `ar -s' here?", " self.f77_opt = ' -O3 '", " self.f90_opt = ' '", " self.f90_fixed_switch = ' -fixedform '", " self.ver_cmd = self.f77_compiler + ' -version '", " #self.libraries = ['fortran', 'ftn', 'm']", " # -lfortran is redundant with MIPSPro 7.30", " self.libraries = ['ftn', 'm']", " self.library_dirs = self.find_lib_dir()", " def find_lib_dir(self):", " library_dirs = []", " return library_dirs", " def get_runtime_library_dirs(self):", "\treturn self.find_lib_dir()", " def get_extra_link_args(self):", "\treturn []" ] } }, { "old_path": "scipy_distutils/command/cpuinfo.py", "new_path": "scipy_distutils/command/cpuinfo.py", "filename": "cpuinfo.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -158,8 +158,81 @@ def _has_sse2(self):\n def _has_3dnow(self):\n return re.match(r'.*?\\b3dnow\\b',self.info[0]['flags']) is not None\n \n+class irix_cpuinfo(cpuinfo_base):\n+\n+ info = None\n+ \n+ def __init__(self):\n+ if self.info is not None:\n+ return\n+ info = []\n+ try:\n+ import commands\n+ status,output = commands.getstatusoutput('sysconf')\n+ if status not in [0,256]:\n+ return\n+ for line in output.split('\\n'):\n+ name_value = map(string.strip,string.split(line,' ',1))\n+ if len(name_value)!=2:\n+ continue\n+ name,value = name_value\n+ if not info:\n+ info.append({})\n+ info[-1][name] = value\n+ except:\n+ print sys.exc_value,'(ignoring)'\n+ self.__class__.info = info\n+\n+ #print info\n+ def _not_impl(self): pass\n+\n+ def _is_singleCPU(self):\n+ return self.info[0].get('NUM_PROCESSORS') == '1'\n+\n+ def __cputype(self,n):\n+ return self.info[0].get('PROCESSORS').split()[0].lower() == 'r%s' % (n)\n+ def _is_r2000(self): return self.__cputype(2000)\n+ def _is_r3000(self): return self.__cputype(3000)\n+ def _is_r3900(self): return self.__cputype(3900)\n+ def _is_r4000(self): return self.__cputype(4000)\n+ def _is_r4100(self): return self.__cputype(4100)\n+ def _is_r4300(self): return self.__cputype(4300)\n+ def _is_r4400(self): return self.__cputype(4400)\n+ def _is_r4600(self): return self.__cputype(4600)\n+ def _is_r4650(self): return self.__cputype(4650)\n+ def _is_r5000(self): return self.__cputype(5000)\n+ def _is_r6000(self): return self.__cputype(6000)\n+ def _is_r8000(self): return self.__cputype(8000)\n+ def _is_r10000(self): return self.__cputype(10000)\n+ def _is_r12000(self): return self.__cputype(12000)\n+ def _is_rorion(self): return self.__cputype('orion')\n+\n+ def get_ip(self):\n+ try: return self.info[0].get('MACHINE')\n+ except: pass\n+ def __machine(self,n):\n+ return self.info[0].get('MACHINE').lower() == 'ip%s' % (n)\n+ def _is_IP19(self): return self.__machine(19)\n+ def _is_IP20(self): return self.__machine(20)\n+ def _is_IP21(self): return self.__machine(21)\n+ def _is_IP22(self): return self.__machine(22)\n+ def _is_IP22_4k(self): return self.__machine(22) and self._is_r4000()\n+ def _is_IP22_5k(self): return self.__machine(22) and self._is_r5000()\n+ def _is_IP24(self): return self.__machine(24)\n+ def _is_IP25(self): return self.__machine(25)\n+ def _is_IP26(self): return self.__machine(26)\n+ def _is_IP27(self): return self.__machine(27)\n+ def _is_IP28(self): return self.__machine(28)\n+ def _is_IP30(self): return self.__machine(30)\n+ def _is_IP32(self): return self.__machine(32)\n+ def _is_IP32_5k(self): return self.__machine(32) and self._is_r5000()\n+ def _is_IP32_10k(self): return self.__machine(32) and self._is_r10000()\n+\n+\n if sys.platform[:5] == 'linux': # variations: linux2,linux-i386 (any others?)\n cpuinfo = linux_cpuinfo\n+elif sys.platform[:4] == 'irix':\n+ cpuinfo = irix_cpuinfo\n #XXX: other OS's. Eg. use _winreg on Win32. Or os.uname on unices.\n else:\n cpuinfo = cpuinfo_base\n", "added_lines": 73, "deleted_lines": 0, "source_code": "#!/usr/bin/env python\n\"\"\"\ncpuinfo\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNote: This should be merged into proc at some point. Perhaps proc should\nbe returning classes like this instead of using dictionaries.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Revision$\n$Date$\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id$\"\n\n__all__ = ['cpuinfo']\n\nimport sys,string,re,types\n\nclass cpuinfo_base:\n \"\"\"Holds CPU information and provides methods for requiring\n the availability of various CPU features.\n \"\"\"\n\n def _try_call(self,func):\n try:\n return func()\n except:\n pass\n\n def __getattr__(self,name):\n if name[0]!='_':\n if hasattr(self,'_'+name):\n attr = getattr(self,'_'+name)\n if type(attr) is types.MethodType:\n return lambda func=self._try_call,attr=attr : func(attr)\n else:\n return lambda : None\n raise AttributeError,name \n\n\nclass linux_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n for line in open('/proc/cpuinfo').readlines():\n name_value = map(string.strip,string.split(line,':',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info or info[-1].has_key(name): # next processor\n info.append({})\n info[-1][name] = value\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n # Athlon\n\n def _is_AMD(self):\n return self.info[0]['vendor_id']=='AuthenticAMD'\n\n def _is_AthlonK6(self):\n return re.match(r'.*?AMD-K6',self.info[0]['model name']) is not None\n\n def _is_AthlonK7(self):\n return re.match(r'.*?AMD-K7',self.info[0]['model name']) is not None\n\n # Alpha\n\n def _is_Alpha(self):\n return self.info[0]['cpu']=='Alpha'\n\n def _is_EV4(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV4'\n\n def _is_EV5(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV5'\n\n def _is_EV56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV56'\n\n def _is_PCA56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'PCA56'\n\n # Intel\n\n #XXX\n _is_i386 = _not_impl\n\n def _is_Intel(self):\n return self.info[0]['vendor_id']=='GenuineIntel'\n\n def _is_i486(self):\n return self.info[0]['cpu']=='i486'\n\n def _is_i586(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '5'\n\n def _is_i686(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '6'\n\n def _is_Celeron(self):\n return re.match(r'.*?Celeron',\n self.info[0]['model name']) is not None\n\n def _is_Pentium(self):\n return re.match(r'.*?Pentium',\n self.info[0]['model name']) is not None\n\n def _is_PentiumII(self):\n return re.match(r'.*?Pentium II\\b',\n self.info[0]['model name']) is not None\n\n _is_PentiumPro = _not_impl\n\n def _is_PentiumIII(self):\n return re.match(r'.*?Pentium III\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumIV(self):\n return re.match(r'.*?Pentium IV\\b',\n self.info[0]['model name']) is not None\n\n # Varia\n\n def _is_singleCPU(self):\n return len(self.info) == 1\n\n def _has_fdiv_bug(self):\n return self.info[0]['fdiv_bug']=='yes'\n\n def _has_f00f_bug(self):\n return self.info[0]['f00f_bug']=='yes'\n\n def _has_mmx(self):\n return re.match(r'.*?\\bmmx\\b',self.info[0]['flags']) is not None\n\n def _has_sse(self):\n return re.match(r'.*?\\bsse\\b',self.info[0]['flags']) is not None\n\n def _has_sse2(self):\n return re.match(r'.*?\\bsse2\\b',self.info[0]['flags']) is not None\n\n def _has_3dnow(self):\n return re.match(r'.*?\\b3dnow\\b',self.info[0]['flags']) is not None\n\nclass irix_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('sysconf')\n if status not in [0,256]:\n return\n for line in output.split('\\n'):\n name_value = map(string.strip,string.split(line,' ',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info:\n info.append({})\n info[-1][name] = value\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n #print info\n def _not_impl(self): pass\n\n def _is_singleCPU(self):\n return self.info[0].get('NUM_PROCESSORS') == '1'\n\n def __cputype(self,n):\n return self.info[0].get('PROCESSORS').split()[0].lower() == 'r%s' % (n)\n def _is_r2000(self): return self.__cputype(2000)\n def _is_r3000(self): return self.__cputype(3000)\n def _is_r3900(self): return self.__cputype(3900)\n def _is_r4000(self): return self.__cputype(4000)\n def _is_r4100(self): return self.__cputype(4100)\n def _is_r4300(self): return self.__cputype(4300)\n def _is_r4400(self): return self.__cputype(4400)\n def _is_r4600(self): return self.__cputype(4600)\n def _is_r4650(self): return self.__cputype(4650)\n def _is_r5000(self): return self.__cputype(5000)\n def _is_r6000(self): return self.__cputype(6000)\n def _is_r8000(self): return self.__cputype(8000)\n def _is_r10000(self): return self.__cputype(10000)\n def _is_r12000(self): return self.__cputype(12000)\n def _is_rorion(self): return self.__cputype('orion')\n\n def get_ip(self):\n try: return self.info[0].get('MACHINE')\n except: pass\n def __machine(self,n):\n return self.info[0].get('MACHINE').lower() == 'ip%s' % (n)\n def _is_IP19(self): return self.__machine(19)\n def _is_IP20(self): return self.__machine(20)\n def _is_IP21(self): return self.__machine(21)\n def _is_IP22(self): return self.__machine(22)\n def _is_IP22_4k(self): return self.__machine(22) and self._is_r4000()\n def _is_IP22_5k(self): return self.__machine(22) and self._is_r5000()\n def _is_IP24(self): return self.__machine(24)\n def _is_IP25(self): return self.__machine(25)\n def _is_IP26(self): return self.__machine(26)\n def _is_IP27(self): return self.__machine(27)\n def _is_IP28(self): return self.__machine(28)\n def _is_IP30(self): return self.__machine(30)\n def _is_IP32(self): return self.__machine(32)\n def _is_IP32_5k(self): return self.__machine(32) and self._is_r5000()\n def _is_IP32_10k(self): return self.__machine(32) and self._is_r10000()\n\n\nif sys.platform[:5] == 'linux': # variations: linux2,linux-i386 (any others?)\n cpuinfo = linux_cpuinfo\nelif sys.platform[:4] == 'irix':\n cpuinfo = irix_cpuinfo\n#XXX: other OS's. Eg. use _winreg on Win32. Or os.uname on unices.\nelse:\n cpuinfo = cpuinfo_base\n\n\n\"\"\"\nlaptop:\n[{'cache size': '256 KB', 'cpu MHz': '399.129', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '6', 'cpuid level': '2', 'model name': 'Mobile Pentium II', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '796.26', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '13', 'flags': 'fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsr'}]\n\nkev:\n[{'cache size': '512 KB', 'cpu MHz': '350.799', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '5', 'cpuid level': '2', 'model name': 'Pentium II (Deschutes)', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '699.59', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '3', 'flags': 'fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr'}, {'cache size': '512 KB', 'cpu MHz': '350.799', 'processor': '1', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '5', 'cpuid level': '2', 'model name': 'Pentium II (Deschutes)', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '701.23', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '3', 'flags': 'fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr'}]\n\nath:\n[{'cache size': '512 KB', 'cpu MHz': '503.542', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '1', 'cpuid level': '1', 'model name': 'AMD-K7(tm) Processor', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '1002.70', 'vendor_id': 'AuthenticAMD', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '2', 'flags': 'fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat mmx syscall mmxext 3dnowext 3dnow'}]\n\nfiasco:\n[{'max. addr. space #': '127', 'cpu': 'Alpha', 'cpu serial number': 'Linux_is_Great!', 'kernel unaligned acc': '0 (pc=0,va=0)', 'system revision': '0', 'system variation': 'LX164', 'cycle frequency [Hz]': '533185472', 'system serial number': 'MILO-2.0.35-c5.', 'timer frequency [Hz]': '1024.00', 'cpu model': 'EV56', 'platform string': 'N/A', 'cpu revision': '0', 'BogoMIPS': '530.57', 'cpus detected': '0', 'phys. address bits': '40', 'user unaligned acc': '1340 (pc=2000000ec90,va=20001156da4)', 'page size [bytes]': '8192', 'system type': 'EB164', 'cpu variation': '0'}]\n\"\"\"\n\nif __name__ == \"__main__\":\n cpu = cpuinfo()\n\n cpu.is_blaa()\n cpu.is_Intel()\n cpu.is_Alpha()\n\n print 'CPU information:',\n for name in dir(cpuinfo):\n if name[0]=='_' and name[1]!='_' and getattr(cpu,name[1:])():\n print name[1:],\n print\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\ncpuinfo\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNote: This should be merged into proc at some point. Perhaps proc should\nbe returning classes like this instead of using dictionaries.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Revision$\n$Date$\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id$\"\n\n__all__ = ['cpuinfo']\n\nimport sys,string,re,types\n\nclass cpuinfo_base:\n \"\"\"Holds CPU information and provides methods for requiring\n the availability of various CPU features.\n \"\"\"\n\n def _try_call(self,func):\n try:\n return func()\n except:\n pass\n\n def __getattr__(self,name):\n if name[0]!='_':\n if hasattr(self,'_'+name):\n attr = getattr(self,'_'+name)\n if type(attr) is types.MethodType:\n return lambda func=self._try_call,attr=attr : func(attr)\n else:\n return lambda : None\n raise AttributeError,name \n\n\nclass linux_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n for line in open('/proc/cpuinfo').readlines():\n name_value = map(string.strip,string.split(line,':',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info or info[-1].has_key(name): # next processor\n info.append({})\n info[-1][name] = value\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n # Athlon\n\n def _is_AMD(self):\n return self.info[0]['vendor_id']=='AuthenticAMD'\n\n def _is_AthlonK6(self):\n return re.match(r'.*?AMD-K6',self.info[0]['model name']) is not None\n\n def _is_AthlonK7(self):\n return re.match(r'.*?AMD-K7',self.info[0]['model name']) is not None\n\n # Alpha\n\n def _is_Alpha(self):\n return self.info[0]['cpu']=='Alpha'\n\n def _is_EV4(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV4'\n\n def _is_EV5(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV5'\n\n def _is_EV56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV56'\n\n def _is_PCA56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'PCA56'\n\n # Intel\n\n #XXX\n _is_i386 = _not_impl\n\n def _is_Intel(self):\n return self.info[0]['vendor_id']=='GenuineIntel'\n\n def _is_i486(self):\n return self.info[0]['cpu']=='i486'\n\n def _is_i586(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '5'\n\n def _is_i686(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '6'\n\n def _is_Celeron(self):\n return re.match(r'.*?Celeron',\n self.info[0]['model name']) is not None\n\n def _is_Pentium(self):\n return re.match(r'.*?Pentium',\n self.info[0]['model name']) is not None\n\n def _is_PentiumII(self):\n return re.match(r'.*?Pentium II\\b',\n self.info[0]['model name']) is not None\n\n _is_PentiumPro = _not_impl\n\n def _is_PentiumIII(self):\n return re.match(r'.*?Pentium III\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumIV(self):\n return re.match(r'.*?Pentium IV\\b',\n self.info[0]['model name']) is not None\n\n # Varia\n\n def _is_singleCPU(self):\n return len(self.info) == 1\n\n def _has_fdiv_bug(self):\n return self.info[0]['fdiv_bug']=='yes'\n\n def _has_f00f_bug(self):\n return self.info[0]['f00f_bug']=='yes'\n\n def _has_mmx(self):\n return re.match(r'.*?\\bmmx\\b',self.info[0]['flags']) is not None\n\n def _has_sse(self):\n return re.match(r'.*?\\bsse\\b',self.info[0]['flags']) is not None\n\n def _has_sse2(self):\n return re.match(r'.*?\\bsse2\\b',self.info[0]['flags']) is not None\n\n def _has_3dnow(self):\n return re.match(r'.*?\\b3dnow\\b',self.info[0]['flags']) is not None\n\nif sys.platform[:5] == 'linux': # variations: linux2,linux-i386 (any others?)\n cpuinfo = linux_cpuinfo\n#XXX: other OS's. Eg. use _winreg on Win32. Or os.uname on unices.\nelse:\n cpuinfo = cpuinfo_base\n\n\n\"\"\"\nlaptop:\n[{'cache size': '256 KB', 'cpu MHz': '399.129', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '6', 'cpuid level': '2', 'model name': 'Mobile Pentium II', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '796.26', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '13', 'flags': 'fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsr'}]\n\nkev:\n[{'cache size': '512 KB', 'cpu MHz': '350.799', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '5', 'cpuid level': '2', 'model name': 'Pentium II (Deschutes)', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '699.59', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '3', 'flags': 'fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr'}, {'cache size': '512 KB', 'cpu MHz': '350.799', 'processor': '1', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '5', 'cpuid level': '2', 'model name': 'Pentium II (Deschutes)', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '701.23', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '3', 'flags': 'fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr'}]\n\nath:\n[{'cache size': '512 KB', 'cpu MHz': '503.542', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '1', 'cpuid level': '1', 'model name': 'AMD-K7(tm) Processor', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '1002.70', 'vendor_id': 'AuthenticAMD', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '2', 'flags': 'fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat mmx syscall mmxext 3dnowext 3dnow'}]\n\nfiasco:\n[{'max. addr. space #': '127', 'cpu': 'Alpha', 'cpu serial number': 'Linux_is_Great!', 'kernel unaligned acc': '0 (pc=0,va=0)', 'system revision': '0', 'system variation': 'LX164', 'cycle frequency [Hz]': '533185472', 'system serial number': 'MILO-2.0.35-c5.', 'timer frequency [Hz]': '1024.00', 'cpu model': 'EV56', 'platform string': 'N/A', 'cpu revision': '0', 'BogoMIPS': '530.57', 'cpus detected': '0', 'phys. address bits': '40', 'user unaligned acc': '1340 (pc=2000000ec90,va=20001156da4)', 'page size [bytes]': '8192', 'system type': 'EB164', 'cpu variation': '0'}]\n\"\"\"\n\nif __name__ == \"__main__\":\n cpu = cpuinfo()\n\n cpu.is_blaa()\n cpu.is_Intel()\n cpu.is_Alpha()\n\n print 'CPU information:',\n for name in dir(cpuinfo):\n if name[0]=='_' and name[1]!='_' and getattr(cpu,name[1:])():\n print name[1:],\n print\n", "methods": [ { "name": "_try_call", "long_name": "_try_call( self , func )", "filename": "cpuinfo.py", "nloc": 5, "complexity": 2, "token_count": 16, "parameters": [ "self", "func" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 4, "token_count": 71, "parameters": [ "self", "name" ], "start_line": 37, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 16, "complexity": 7, "token_count": 112, "parameters": [ "self" ], "start_line": 52, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 73, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6", "long_name": "_is_AthlonK6( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK7", "long_name": "_is_AthlonK7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 79, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Alpha", "long_name": "_is_Alpha( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 84, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV4", "long_name": "_is_EV4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 87, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV5", "long_name": "_is_EV5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 90, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV56", "long_name": "_is_EV56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 93, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PCA56", "long_name": "_is_PCA56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 96, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 104, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 107, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 110, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 113, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Celeron", "long_name": "_is_Celeron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 116, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 120, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 130, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 134, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 140, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_fdiv_bug", "long_name": "_has_fdiv_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 143, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_f00f_bug", "long_name": "_has_f00f_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 149, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 152, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 155, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 158, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 20, "complexity": 7, "token_count": 122, "parameters": [ "self" ], "start_line": 165, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 189, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__cputype", "long_name": "__cputype( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 36, "parameters": [ "self", "n" ], "start_line": 192, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_ip", "long_name": "get_ip( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 210, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 29, "parameters": [ "self", "n" ], "start_line": 213, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "_try_call", "long_name": "_try_call( self , func )", "filename": "cpuinfo.py", "nloc": 5, "complexity": 2, "token_count": 16, "parameters": [ "self", "func" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 4, "token_count": 71, "parameters": [ "self", "name" ], "start_line": 37, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 16, "complexity": 7, "token_count": 112, "parameters": [ "self" ], "start_line": 52, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 73, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6", "long_name": "_is_AthlonK6( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK7", "long_name": "_is_AthlonK7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 79, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Alpha", "long_name": "_is_Alpha( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 84, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV4", "long_name": "_is_EV4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 87, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV5", "long_name": "_is_EV5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 90, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV56", "long_name": "_is_EV56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 93, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PCA56", "long_name": "_is_PCA56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 96, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 104, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 107, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 110, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 113, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Celeron", "long_name": "_is_Celeron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 116, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 120, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 130, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 134, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 140, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_fdiv_bug", "long_name": "_has_fdiv_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 143, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_f00f_bug", "long_name": "_has_f00f_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 149, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 152, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 155, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 158, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "get_ip", "long_name": "get_ip( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 210, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__cputype", "long_name": "__cputype( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 36, "parameters": [ "self", "n" ], "start_line": 192, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 29, "parameters": [ "self", "n" ], "start_line": 213, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 189, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 20, "complexity": 7, "token_count": 122, "parameters": [ "self" ], "start_line": 165, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 } ], "nloc": 203, "complexity": 55, "token_count": 1578, "diff_parsed": { "added": [ "class irix_cpuinfo(cpuinfo_base):", "", " info = None", "", " def __init__(self):", " if self.info is not None:", " return", " info = []", " try:", " import commands", " status,output = commands.getstatusoutput('sysconf')", " if status not in [0,256]:", " return", " for line in output.split('\\n'):", " name_value = map(string.strip,string.split(line,' ',1))", " if len(name_value)!=2:", " continue", " name,value = name_value", " if not info:", " info.append({})", " info[-1][name] = value", " except:", " print sys.exc_value,'(ignoring)'", " self.__class__.info = info", "", " #print info", " def _not_impl(self): pass", "", " def _is_singleCPU(self):", " return self.info[0].get('NUM_PROCESSORS') == '1'", "", " def __cputype(self,n):", " return self.info[0].get('PROCESSORS').split()[0].lower() == 'r%s' % (n)", " def _is_r2000(self): return self.__cputype(2000)", " def _is_r3000(self): return self.__cputype(3000)", " def _is_r3900(self): return self.__cputype(3900)", " def _is_r4000(self): return self.__cputype(4000)", " def _is_r4100(self): return self.__cputype(4100)", " def _is_r4300(self): return self.__cputype(4300)", " def _is_r4400(self): return self.__cputype(4400)", " def _is_r4600(self): return self.__cputype(4600)", " def _is_r4650(self): return self.__cputype(4650)", " def _is_r5000(self): return self.__cputype(5000)", " def _is_r6000(self): return self.__cputype(6000)", " def _is_r8000(self): return self.__cputype(8000)", " def _is_r10000(self): return self.__cputype(10000)", " def _is_r12000(self): return self.__cputype(12000)", " def _is_rorion(self): return self.__cputype('orion')", "", " def get_ip(self):", " try: return self.info[0].get('MACHINE')", " except: pass", " def __machine(self,n):", " return self.info[0].get('MACHINE').lower() == 'ip%s' % (n)", " def _is_IP19(self): return self.__machine(19)", " def _is_IP20(self): return self.__machine(20)", " def _is_IP21(self): return self.__machine(21)", " def _is_IP22(self): return self.__machine(22)", " def _is_IP22_4k(self): return self.__machine(22) and self._is_r4000()", " def _is_IP22_5k(self): return self.__machine(22) and self._is_r5000()", " def _is_IP24(self): return self.__machine(24)", " def _is_IP25(self): return self.__machine(25)", " def _is_IP26(self): return self.__machine(26)", " def _is_IP27(self): return self.__machine(27)", " def _is_IP28(self): return self.__machine(28)", " def _is_IP30(self): return self.__machine(30)", " def _is_IP32(self): return self.__machine(32)", " def _is_IP32_5k(self): return self.__machine(32) and self._is_r5000()", " def _is_IP32_10k(self): return self.__machine(32) and self._is_r10000()", "", "", "elif sys.platform[:4] == 'irix':", " cpuinfo = irix_cpuinfo" ], "deleted": [] } } ] }, { "hash": "414f3b3d68a6095a605c006af043b9da8b129c1b", "msg": "Impl. cpuinfo for darwin platform. Fixed gnu compiler support on darwin (no need for -lg2c) and impl. optimization hooks for this platform. Clean up code. A note: currently Fortran compilers are used with architecture/machine dependent optimization flags. We need a switch that turns off architecture/machine dependent optimization flags (but keeping generic optimization flags) when building distributable scipy binaries.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-01-06T23:40:40+00:00", "author_timezone": 0, "committer_date": "2003-01-06T23:40:40+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "cdaf91ed9ac5583774ed958b797720db40b1c716" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 20, "insertions": 92, "lines": 112, "files": 2, "dmm_unit_size": 0.10714285714285714, "dmm_unit_complexity": 0.10714285714285714, "dmm_unit_interfacing": 0.9642857142857143, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -597,7 +597,21 @@ def get_linker_so(self):\n \"\"\"\n \n def __str__(self):\n- return \"%s %s\" % (self.vendor, self.get_version())\n+ s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n+ s.extend([' F77=%r' % (self.f77_compiler),\n+ ' F77FLAGS=%r' % (self.f77_switches),\n+ ' F77OPT=%r' % (self.f77_opt)])\n+ if hasattr(self,'f90_compiler'):\n+ s.extend([' F90=%r' % (self.f90_compiler),\n+ ' F90FLAGS=%r' % (self.f90_switches),\n+ ' F90OPT=%r' % (self.f90_opt),\n+ ' F90FIXED=%r' % (self.f90_fixed_switch)])\n+ if self.libraries:\n+ s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n+ if self.library_dirs:\n+ s.append(' LIBDIRS=%r' % \\\n+ ' '.join(['-L%s'%n for n in self.library_dirs]))\n+ return string.join(s,'\\n')\n \n \n class absoft_fortran_compiler(fortran_compiler_base):\n@@ -897,6 +911,8 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n+ elif sys.platform == 'darwin':\n+ pass\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n@@ -918,6 +934,17 @@ def get_opt(self):\n \n # only check for more optimization if g77 can handle it.\n if self.get_version():\n+ if sys.platform=='darwin':\n+ if cpu.is_ppc():\n+ opt = opt + ' -arch ppc '\n+ elif cpu.is_i386():\n+ opt = opt + ' -arch i386 '\n+ for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n+ '403 505 801 821 823 860'.split():\n+ if getattr(cpu,'is_ppc%s'%a)():\n+ opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n+ break \n+ return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n@@ -929,6 +956,10 @@ def get_opt(self):\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n+ elif cpu.is_AthlonK6_2():\n+ opt = opt + ' -march=k6-2 '\n+ elif cpu.is_AthlonK6_3():\n+ opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n@@ -956,7 +987,7 @@ def get_opt(self):\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n- opt = opt + ' -malign-double -fomit-frame-pointer ' \n+ opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n@@ -981,9 +1012,8 @@ def find_lib_directories(self):\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n- if ((sys.platform != 'win32') and\n- (sys.platform != 'cygwin') and\n- (os.uname()[0] != 'Darwin')):\n+ # Darwin g77 cannot be used as a linker.\n+ if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n \n", "added_lines": 35, "deleted_lines": 5, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Sun|SGI|Intel|Itanium|NAG|Compaq|Digital|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,build_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,build_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n s.extend([' F77=%r' % (self.f77_compiler),\n ' F77FLAGS=%r' % (self.f77_switches),\n ' F77OPT=%r' % (self.f77_opt)])\n if hasattr(self,'f90_compiler'):\n s.extend([' F90=%r' % (self.f90_compiler),\n ' F90FLAGS=%r' % (self.f90_switches),\n ' F90OPT=%r' % (self.f90_opt),\n ' F90FIXED=%r' % (self.f90_fixed_switch)])\n if self.libraries:\n s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n if self.library_dirs:\n s.append(' LIBDIRS=%r' % \\\n ' '.join(['-L%s'%n for n in self.library_dirs]))\n return string.join(s,'\\n')\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.f90_fixed_switch = ' -ffixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n elif sys.platform == 'darwin':\n pass\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Digital\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Sun|SGI|Intel|Itanium|NAG|Compaq|Digital|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,build_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,build_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -Q100'\n self.f77_switches = '-N22 -N90 -N110'\n self.f77_opt = '-O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n else:\n self.f90_switches = '-YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\n\n self.f90_fixed_switch = ' -ffixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -pic -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_compiler = f90c\n self.f90_switches = ' -pic'\n self.f90_opt = ' -fast -dalign -xtarget=generic -R/opt/SUNWspro/lib'\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod\n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n def get_extra_link_args(self):\n return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler]\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir and \\\n os.path.isfile(os.path.join(gcc_lib_dir[0],'libg2c-pic.a')):\n g2c = 'g2c-pic'\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer ' \n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n if ((sys.platform != 'win32') and\n (sys.platform != 'cygwin') and\n (os.uname()[0] != 'Darwin')):\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n\n#http://www.compaq.com/fortran\nclass digital_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Digital'\n ver_match = r'DIGITAL Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n debug = ' '\n\n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nall_compilers = [absoft_fortran_compiler,\n mips_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n digital_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 116, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 137, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 181, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 219, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 240, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 310, "end_line": 315, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 325, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 363, "end_line": 388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 390, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 422, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 429, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 434, "end_line": 456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 460, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 465, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 472, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 477, "end_line": 478, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 480, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 168, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 501, "end_line": 544, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 546, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 556, "end_line": 557, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 559, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 584, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 586, "end_line": 587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 588, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 590, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 592, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 6, "token_count": 164, "parameters": [ "self" ], "start_line": 599, "end_line": 614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 33, "complexity": 5, "token_count": 195, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 622, "end_line": 666, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 668, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 675, "end_line": 676, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 123, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 709, "end_line": 748, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 750, "end_line": 755, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 757, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 777, "end_line": 778, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 780, "end_line": 781, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 96, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 790, "end_line": 810, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self , mode = 'f90' )", "filename": "build_flib.py", "nloc": 21, "complexity": 11, "token_count": 143, "parameters": [ "self", "mode" ], "start_line": 812, "end_line": 832, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 834, "end_line": 836, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 838, "end_line": 839, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 846, "end_line": 867, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 869, "end_line": 887, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 26, "complexity": 8, "token_count": 164, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 895, "end_line": 928, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 60, "complexity": 28, "token_count": 346, "parameters": [ "self" ], "start_line": 930, "end_line": 991, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 993, "end_line": 1010, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1012, "end_line": 1018, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 1020, "end_line": 1028, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1030, "end_line": 1031, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1033, "end_line": 1034, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1044, "end_line": 1073, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1075, "end_line": 1089, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1091, "end_line": 1092, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1102, "end_line": 1105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1113, "end_line": 1134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1136, "end_line": 1138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1140, "end_line": 1141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1155, "end_line": 1183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1189, "end_line": 1190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1203, "end_line": 1234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1236, "end_line": 1237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 104, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1245, "end_line": 1269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1271, "end_line": 1274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1276, "end_line": 1277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1294, "end_line": 1319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1321, "end_line": 1323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1327, "end_line": 1335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 82, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 116, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 20, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 137, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 165, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 181, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 219, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 240, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 266, "end_line": 301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 310, "end_line": 315, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 325, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 363, "end_line": 388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 390, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 422, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 429, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 147, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 434, "end_line": 456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 460, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 465, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 472, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "module_dirs" ], "start_line": 477, "end_line": 478, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 480, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 168, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 501, "end_line": 544, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 546, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 556, "end_line": 557, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 559, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 584, "end_line": 585, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 586, "end_line": 587, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 588, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 590, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 592, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 599, "end_line": 600, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 33, "complexity": 5, "token_count": 195, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 608, "end_line": 652, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 654, "end_line": 659, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 661, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 123, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 695, "end_line": 734, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 27, "parameters": [ "self", "module_dirs" ], "start_line": 736, "end_line": 741, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 743, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 763, "end_line": 764, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 766, "end_line": 767, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 96, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 776, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self , mode = 'f90' )", "filename": "build_flib.py", "nloc": 21, "complexity": 11, "token_count": 143, "parameters": [ "self", "mode" ], "start_line": 798, "end_line": 818, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [ "self", "module_dirs" ], "start_line": 820, "end_line": 822, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 824, "end_line": 825, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 832, "end_line": 853, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 855, "end_line": 873, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 881, "end_line": 912, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 45, "complexity": 21, "token_count": 254, "parameters": [ "self" ], "start_line": 914, "end_line": 960, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 962, "end_line": 979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "self" ], "start_line": 981, "end_line": 988, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 990, "end_line": 998, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1000, "end_line": 1001, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1003, "end_line": 1004, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1014, "end_line": 1043, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1045, "end_line": 1059, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1061, "end_line": 1062, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1072, "end_line": 1075, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1083, "end_line": 1104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1106, "end_line": 1108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1110, "end_line": 1111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1125, "end_line": 1153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1159, "end_line": 1160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1173, "end_line": 1204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1206, "end_line": 1207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 104, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1215, "end_line": 1239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1241, "end_line": 1244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1246, "end_line": 1247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1264, "end_line": 1289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1291, "end_line": 1293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1297, "end_line": 1305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 26, "complexity": 8, "token_count": 164, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 895, "end_line": 928, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1012, "end_line": 1018, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 6, "token_count": 164, "parameters": [ "self" ], "start_line": 599, "end_line": 614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 60, "complexity": 28, "token_count": 346, "parameters": [ "self" ], "start_line": 930, "end_line": 991, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 62, "top_nesting_level": 1 } ], "nloc": 982, "complexity": 255, "token_count": 5828, "diff_parsed": { "added": [ " s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]", " s.extend([' F77=%r' % (self.f77_compiler),", " ' F77FLAGS=%r' % (self.f77_switches),", " ' F77OPT=%r' % (self.f77_opt)])", " if hasattr(self,'f90_compiler'):", " s.extend([' F90=%r' % (self.f90_compiler),", " ' F90FLAGS=%r' % (self.f90_switches),", " ' F90OPT=%r' % (self.f90_opt),", " ' F90FIXED=%r' % (self.f90_fixed_switch)])", " if self.libraries:", " s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))", " if self.library_dirs:", " s.append(' LIBDIRS=%r' % \\", " ' '.join(['-L%s'%n for n in self.library_dirs]))", " return string.join(s,'\\n')", " elif sys.platform == 'darwin':", " pass", " if sys.platform=='darwin':", " if cpu.is_ppc():", " opt = opt + ' -arch ppc '", " elif cpu.is_i386():", " opt = opt + ' -arch i386 '", " for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\", " '403 505 801 821 823 860'.split():", " if getattr(cpu,'is_ppc%s'%a)():", " opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)", " break", " return opt", " elif cpu.is_AthlonK6_2():", " opt = opt + ' -march=k6-2 '", " elif cpu.is_AthlonK6_3():", " opt = opt + ' -march=k6-3 '", " opt = opt + ' -malign-double -fomit-frame-pointer '", " # Darwin g77 cannot be used as a linker.", " if sys.platform not in ['win32','cygwin','darwin']:" ], "deleted": [ " return \"%s %s\" % (self.vendor, self.get_version())", " opt = opt + ' -malign-double -fomit-frame-pointer '", " if ((sys.platform != 'win32') and", " (sys.platform != 'cygwin') and", " (os.uname()[0] != 'Darwin')):" ] } }, { "old_path": "scipy_distutils/command/cpuinfo.py", "new_path": "scipy_distutils/command/cpuinfo.py", "filename": "cpuinfo.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -73,6 +73,12 @@ def _not_impl(self): pass\n def _is_AMD(self):\n return self.info[0]['vendor_id']=='AuthenticAMD'\n \n+ def _is_AthlonK6_2(self):\n+ return self._is_AMD() and self.info[0]['model'] == '2'\n+\n+ def _is_AthlonK6_3(self):\n+ return self._is_AMD() and self.info[0]['model'] == '3'\n+\n def _is_AthlonK6(self):\n return re.match(r'.*?AMD-K6',self.info[0]['model name']) is not None\n \n@@ -228,30 +234,66 @@ def _is_IP32(self): return self.__machine(32)\n def _is_IP32_5k(self): return self.__machine(32) and self._is_r5000()\n def _is_IP32_10k(self): return self.__machine(32) and self._is_r10000()\n \n+class darwin_cpuinfo(cpuinfo_base):\n+\n+ info = None\n+ \n+ def __init__(self):\n+ if self.info is not None:\n+ return\n+ info = []\n+ try:\n+ import commands\n+ status,output = commands.getstatusoutput('arch')\n+ if not status:\n+ if not info: info.append({})\n+ info[-1]['arch'] = string.strip(output)\n+ status,output = commands.getstatusoutput('machine')\n+ if not status:\n+ if not info: info.append({})\n+ info[-1]['machine'] = string.strip(output)\n+ except:\n+ print sys.exc_value,'(ignoring)'\n+ self.__class__.info = info\n+\n+ def _not_impl(self): pass\n+\n+ def _is_i386(self):\n+ return self.info[0]['arch']=='i386'\n+ def _is_ppc(self):\n+ return self.info[0]['arch']=='ppc'\n+\n+ def __machine(self,n):\n+ return self.info[0]['machine'] == 'ppc%s'%n\n+ def _is_ppc601(self): return self.__machine(601)\n+ def _is_ppc602(self): return self.__machine(602)\n+ def _is_ppc603(self): return self.__machine(603)\n+ def _is_ppc603e(self): return self.__machine('603e')\n+ def _is_ppc604(self): return self.__machine(604)\n+ def _is_ppc604e(self): return self.__machine('604e')\n+ def _is_ppc620(self): return self.__machine(620)\n+ def _is_ppc630(self): return self.__machine(630)\n+ def _is_ppc740(self): return self.__machine(740)\n+ def _is_ppc7400(self): return self.__machine(7400)\n+ def _is_ppc7450(self): return self.__machine(7450)\n+ def _is_ppc750(self): return self.__machine(750)\n+ def _is_ppc403(self): return self.__machine(403)\n+ def _is_ppc505(self): return self.__machine(505)\n+ def _is_ppc801(self): return self.__machine(801)\n+ def _is_ppc821(self): return self.__machine(821)\n+ def _is_ppc823(self): return self.__machine(823)\n+ def _is_ppc860(self): return self.__machine(860)\n \n if sys.platform[:5] == 'linux': # variations: linux2,linux-i386 (any others?)\n cpuinfo = linux_cpuinfo\n elif sys.platform[:4] == 'irix':\n cpuinfo = irix_cpuinfo\n+elif sys.platform == 'darwin':\n+ cpuinfo = darwin_cpuinfo\n #XXX: other OS's. Eg. use _winreg on Win32. Or os.uname on unices.\n else:\n cpuinfo = cpuinfo_base\n \n-\n-\"\"\"\n-laptop:\n-[{'cache size': '256 KB', 'cpu MHz': '399.129', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '6', 'cpuid level': '2', 'model name': 'Mobile Pentium II', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '796.26', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '13', 'flags': 'fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsr'}]\n-\n-kev:\n-[{'cache size': '512 KB', 'cpu MHz': '350.799', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '5', 'cpuid level': '2', 'model name': 'Pentium II (Deschutes)', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '699.59', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '3', 'flags': 'fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr'}, {'cache size': '512 KB', 'cpu MHz': '350.799', 'processor': '1', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '5', 'cpuid level': '2', 'model name': 'Pentium II (Deschutes)', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '701.23', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '3', 'flags': 'fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr'}]\n-\n-ath:\n-[{'cache size': '512 KB', 'cpu MHz': '503.542', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '1', 'cpuid level': '1', 'model name': 'AMD-K7(tm) Processor', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '1002.70', 'vendor_id': 'AuthenticAMD', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '2', 'flags': 'fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat mmx syscall mmxext 3dnowext 3dnow'}]\n-\n-fiasco:\n-[{'max. addr. space #': '127', 'cpu': 'Alpha', 'cpu serial number': 'Linux_is_Great!', 'kernel unaligned acc': '0 (pc=0,va=0)', 'system revision': '0', 'system variation': 'LX164', 'cycle frequency [Hz]': '533185472', 'system serial number': 'MILO-2.0.35-c5.', 'timer frequency [Hz]': '1024.00', 'cpu model': 'EV56', 'platform string': 'N/A', 'cpu revision': '0', 'BogoMIPS': '530.57', 'cpus detected': '0', 'phys. address bits': '40', 'user unaligned acc': '1340 (pc=2000000ec90,va=20001156da4)', 'page size [bytes]': '8192', 'system type': 'EB164', 'cpu variation': '0'}]\n-\"\"\"\n-\n if __name__ == \"__main__\":\n cpu = cpuinfo()\n \n", "added_lines": 57, "deleted_lines": 15, "source_code": "#!/usr/bin/env python\n\"\"\"\ncpuinfo\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNote: This should be merged into proc at some point. Perhaps proc should\nbe returning classes like this instead of using dictionaries.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Revision$\n$Date$\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id$\"\n\n__all__ = ['cpuinfo']\n\nimport sys,string,re,types\n\nclass cpuinfo_base:\n \"\"\"Holds CPU information and provides methods for requiring\n the availability of various CPU features.\n \"\"\"\n\n def _try_call(self,func):\n try:\n return func()\n except:\n pass\n\n def __getattr__(self,name):\n if name[0]!='_':\n if hasattr(self,'_'+name):\n attr = getattr(self,'_'+name)\n if type(attr) is types.MethodType:\n return lambda func=self._try_call,attr=attr : func(attr)\n else:\n return lambda : None\n raise AttributeError,name \n\n\nclass linux_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n for line in open('/proc/cpuinfo').readlines():\n name_value = map(string.strip,string.split(line,':',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info or info[-1].has_key(name): # next processor\n info.append({})\n info[-1][name] = value\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n # Athlon\n\n def _is_AMD(self):\n return self.info[0]['vendor_id']=='AuthenticAMD'\n\n def _is_AthlonK6_2(self):\n return self._is_AMD() and self.info[0]['model'] == '2'\n\n def _is_AthlonK6_3(self):\n return self._is_AMD() and self.info[0]['model'] == '3'\n\n def _is_AthlonK6(self):\n return re.match(r'.*?AMD-K6',self.info[0]['model name']) is not None\n\n def _is_AthlonK7(self):\n return re.match(r'.*?AMD-K7',self.info[0]['model name']) is not None\n\n # Alpha\n\n def _is_Alpha(self):\n return self.info[0]['cpu']=='Alpha'\n\n def _is_EV4(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV4'\n\n def _is_EV5(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV5'\n\n def _is_EV56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV56'\n\n def _is_PCA56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'PCA56'\n\n # Intel\n\n #XXX\n _is_i386 = _not_impl\n\n def _is_Intel(self):\n return self.info[0]['vendor_id']=='GenuineIntel'\n\n def _is_i486(self):\n return self.info[0]['cpu']=='i486'\n\n def _is_i586(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '5'\n\n def _is_i686(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '6'\n\n def _is_Celeron(self):\n return re.match(r'.*?Celeron',\n self.info[0]['model name']) is not None\n\n def _is_Pentium(self):\n return re.match(r'.*?Pentium',\n self.info[0]['model name']) is not None\n\n def _is_PentiumII(self):\n return re.match(r'.*?Pentium II\\b',\n self.info[0]['model name']) is not None\n\n _is_PentiumPro = _not_impl\n\n def _is_PentiumIII(self):\n return re.match(r'.*?Pentium III\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumIV(self):\n return re.match(r'.*?Pentium IV\\b',\n self.info[0]['model name']) is not None\n\n # Varia\n\n def _is_singleCPU(self):\n return len(self.info) == 1\n\n def _has_fdiv_bug(self):\n return self.info[0]['fdiv_bug']=='yes'\n\n def _has_f00f_bug(self):\n return self.info[0]['f00f_bug']=='yes'\n\n def _has_mmx(self):\n return re.match(r'.*?\\bmmx\\b',self.info[0]['flags']) is not None\n\n def _has_sse(self):\n return re.match(r'.*?\\bsse\\b',self.info[0]['flags']) is not None\n\n def _has_sse2(self):\n return re.match(r'.*?\\bsse2\\b',self.info[0]['flags']) is not None\n\n def _has_3dnow(self):\n return re.match(r'.*?\\b3dnow\\b',self.info[0]['flags']) is not None\n\nclass irix_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('sysconf')\n if status not in [0,256]:\n return\n for line in output.split('\\n'):\n name_value = map(string.strip,string.split(line,' ',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info:\n info.append({})\n info[-1][name] = value\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n #print info\n def _not_impl(self): pass\n\n def _is_singleCPU(self):\n return self.info[0].get('NUM_PROCESSORS') == '1'\n\n def __cputype(self,n):\n return self.info[0].get('PROCESSORS').split()[0].lower() == 'r%s' % (n)\n def _is_r2000(self): return self.__cputype(2000)\n def _is_r3000(self): return self.__cputype(3000)\n def _is_r3900(self): return self.__cputype(3900)\n def _is_r4000(self): return self.__cputype(4000)\n def _is_r4100(self): return self.__cputype(4100)\n def _is_r4300(self): return self.__cputype(4300)\n def _is_r4400(self): return self.__cputype(4400)\n def _is_r4600(self): return self.__cputype(4600)\n def _is_r4650(self): return self.__cputype(4650)\n def _is_r5000(self): return self.__cputype(5000)\n def _is_r6000(self): return self.__cputype(6000)\n def _is_r8000(self): return self.__cputype(8000)\n def _is_r10000(self): return self.__cputype(10000)\n def _is_r12000(self): return self.__cputype(12000)\n def _is_rorion(self): return self.__cputype('orion')\n\n def get_ip(self):\n try: return self.info[0].get('MACHINE')\n except: pass\n def __machine(self,n):\n return self.info[0].get('MACHINE').lower() == 'ip%s' % (n)\n def _is_IP19(self): return self.__machine(19)\n def _is_IP20(self): return self.__machine(20)\n def _is_IP21(self): return self.__machine(21)\n def _is_IP22(self): return self.__machine(22)\n def _is_IP22_4k(self): return self.__machine(22) and self._is_r4000()\n def _is_IP22_5k(self): return self.__machine(22) and self._is_r5000()\n def _is_IP24(self): return self.__machine(24)\n def _is_IP25(self): return self.__machine(25)\n def _is_IP26(self): return self.__machine(26)\n def _is_IP27(self): return self.__machine(27)\n def _is_IP28(self): return self.__machine(28)\n def _is_IP30(self): return self.__machine(30)\n def _is_IP32(self): return self.__machine(32)\n def _is_IP32_5k(self): return self.__machine(32) and self._is_r5000()\n def _is_IP32_10k(self): return self.__machine(32) and self._is_r10000()\n\nclass darwin_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('arch')\n if not status:\n if not info: info.append({})\n info[-1]['arch'] = string.strip(output)\n status,output = commands.getstatusoutput('machine')\n if not status:\n if not info: info.append({})\n info[-1]['machine'] = string.strip(output)\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n def _is_i386(self):\n return self.info[0]['arch']=='i386'\n def _is_ppc(self):\n return self.info[0]['arch']=='ppc'\n\n def __machine(self,n):\n return self.info[0]['machine'] == 'ppc%s'%n\n def _is_ppc601(self): return self.__machine(601)\n def _is_ppc602(self): return self.__machine(602)\n def _is_ppc603(self): return self.__machine(603)\n def _is_ppc603e(self): return self.__machine('603e')\n def _is_ppc604(self): return self.__machine(604)\n def _is_ppc604e(self): return self.__machine('604e')\n def _is_ppc620(self): return self.__machine(620)\n def _is_ppc630(self): return self.__machine(630)\n def _is_ppc740(self): return self.__machine(740)\n def _is_ppc7400(self): return self.__machine(7400)\n def _is_ppc7450(self): return self.__machine(7450)\n def _is_ppc750(self): return self.__machine(750)\n def _is_ppc403(self): return self.__machine(403)\n def _is_ppc505(self): return self.__machine(505)\n def _is_ppc801(self): return self.__machine(801)\n def _is_ppc821(self): return self.__machine(821)\n def _is_ppc823(self): return self.__machine(823)\n def _is_ppc860(self): return self.__machine(860)\n\nif sys.platform[:5] == 'linux': # variations: linux2,linux-i386 (any others?)\n cpuinfo = linux_cpuinfo\nelif sys.platform[:4] == 'irix':\n cpuinfo = irix_cpuinfo\nelif sys.platform == 'darwin':\n cpuinfo = darwin_cpuinfo\n#XXX: other OS's. Eg. use _winreg on Win32. Or os.uname on unices.\nelse:\n cpuinfo = cpuinfo_base\n\nif __name__ == \"__main__\":\n cpu = cpuinfo()\n\n cpu.is_blaa()\n cpu.is_Intel()\n cpu.is_Alpha()\n\n print 'CPU information:',\n for name in dir(cpuinfo):\n if name[0]=='_' and name[1]!='_' and getattr(cpu,name[1:])():\n print name[1:],\n print\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\ncpuinfo\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNote: This should be merged into proc at some point. Perhaps proc should\nbe returning classes like this instead of using dictionaries.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Revision$\n$Date$\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id$\"\n\n__all__ = ['cpuinfo']\n\nimport sys,string,re,types\n\nclass cpuinfo_base:\n \"\"\"Holds CPU information and provides methods for requiring\n the availability of various CPU features.\n \"\"\"\n\n def _try_call(self,func):\n try:\n return func()\n except:\n pass\n\n def __getattr__(self,name):\n if name[0]!='_':\n if hasattr(self,'_'+name):\n attr = getattr(self,'_'+name)\n if type(attr) is types.MethodType:\n return lambda func=self._try_call,attr=attr : func(attr)\n else:\n return lambda : None\n raise AttributeError,name \n\n\nclass linux_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n for line in open('/proc/cpuinfo').readlines():\n name_value = map(string.strip,string.split(line,':',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info or info[-1].has_key(name): # next processor\n info.append({})\n info[-1][name] = value\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n # Athlon\n\n def _is_AMD(self):\n return self.info[0]['vendor_id']=='AuthenticAMD'\n\n def _is_AthlonK6(self):\n return re.match(r'.*?AMD-K6',self.info[0]['model name']) is not None\n\n def _is_AthlonK7(self):\n return re.match(r'.*?AMD-K7',self.info[0]['model name']) is not None\n\n # Alpha\n\n def _is_Alpha(self):\n return self.info[0]['cpu']=='Alpha'\n\n def _is_EV4(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV4'\n\n def _is_EV5(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV5'\n\n def _is_EV56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV56'\n\n def _is_PCA56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'PCA56'\n\n # Intel\n\n #XXX\n _is_i386 = _not_impl\n\n def _is_Intel(self):\n return self.info[0]['vendor_id']=='GenuineIntel'\n\n def _is_i486(self):\n return self.info[0]['cpu']=='i486'\n\n def _is_i586(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '5'\n\n def _is_i686(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '6'\n\n def _is_Celeron(self):\n return re.match(r'.*?Celeron',\n self.info[0]['model name']) is not None\n\n def _is_Pentium(self):\n return re.match(r'.*?Pentium',\n self.info[0]['model name']) is not None\n\n def _is_PentiumII(self):\n return re.match(r'.*?Pentium II\\b',\n self.info[0]['model name']) is not None\n\n _is_PentiumPro = _not_impl\n\n def _is_PentiumIII(self):\n return re.match(r'.*?Pentium III\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumIV(self):\n return re.match(r'.*?Pentium IV\\b',\n self.info[0]['model name']) is not None\n\n # Varia\n\n def _is_singleCPU(self):\n return len(self.info) == 1\n\n def _has_fdiv_bug(self):\n return self.info[0]['fdiv_bug']=='yes'\n\n def _has_f00f_bug(self):\n return self.info[0]['f00f_bug']=='yes'\n\n def _has_mmx(self):\n return re.match(r'.*?\\bmmx\\b',self.info[0]['flags']) is not None\n\n def _has_sse(self):\n return re.match(r'.*?\\bsse\\b',self.info[0]['flags']) is not None\n\n def _has_sse2(self):\n return re.match(r'.*?\\bsse2\\b',self.info[0]['flags']) is not None\n\n def _has_3dnow(self):\n return re.match(r'.*?\\b3dnow\\b',self.info[0]['flags']) is not None\n\nclass irix_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('sysconf')\n if status not in [0,256]:\n return\n for line in output.split('\\n'):\n name_value = map(string.strip,string.split(line,' ',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info:\n info.append({})\n info[-1][name] = value\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n #print info\n def _not_impl(self): pass\n\n def _is_singleCPU(self):\n return self.info[0].get('NUM_PROCESSORS') == '1'\n\n def __cputype(self,n):\n return self.info[0].get('PROCESSORS').split()[0].lower() == 'r%s' % (n)\n def _is_r2000(self): return self.__cputype(2000)\n def _is_r3000(self): return self.__cputype(3000)\n def _is_r3900(self): return self.__cputype(3900)\n def _is_r4000(self): return self.__cputype(4000)\n def _is_r4100(self): return self.__cputype(4100)\n def _is_r4300(self): return self.__cputype(4300)\n def _is_r4400(self): return self.__cputype(4400)\n def _is_r4600(self): return self.__cputype(4600)\n def _is_r4650(self): return self.__cputype(4650)\n def _is_r5000(self): return self.__cputype(5000)\n def _is_r6000(self): return self.__cputype(6000)\n def _is_r8000(self): return self.__cputype(8000)\n def _is_r10000(self): return self.__cputype(10000)\n def _is_r12000(self): return self.__cputype(12000)\n def _is_rorion(self): return self.__cputype('orion')\n\n def get_ip(self):\n try: return self.info[0].get('MACHINE')\n except: pass\n def __machine(self,n):\n return self.info[0].get('MACHINE').lower() == 'ip%s' % (n)\n def _is_IP19(self): return self.__machine(19)\n def _is_IP20(self): return self.__machine(20)\n def _is_IP21(self): return self.__machine(21)\n def _is_IP22(self): return self.__machine(22)\n def _is_IP22_4k(self): return self.__machine(22) and self._is_r4000()\n def _is_IP22_5k(self): return self.__machine(22) and self._is_r5000()\n def _is_IP24(self): return self.__machine(24)\n def _is_IP25(self): return self.__machine(25)\n def _is_IP26(self): return self.__machine(26)\n def _is_IP27(self): return self.__machine(27)\n def _is_IP28(self): return self.__machine(28)\n def _is_IP30(self): return self.__machine(30)\n def _is_IP32(self): return self.__machine(32)\n def _is_IP32_5k(self): return self.__machine(32) and self._is_r5000()\n def _is_IP32_10k(self): return self.__machine(32) and self._is_r10000()\n\n\nif sys.platform[:5] == 'linux': # variations: linux2,linux-i386 (any others?)\n cpuinfo = linux_cpuinfo\nelif sys.platform[:4] == 'irix':\n cpuinfo = irix_cpuinfo\n#XXX: other OS's. Eg. use _winreg on Win32. Or os.uname on unices.\nelse:\n cpuinfo = cpuinfo_base\n\n\n\"\"\"\nlaptop:\n[{'cache size': '256 KB', 'cpu MHz': '399.129', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '6', 'cpuid level': '2', 'model name': 'Mobile Pentium II', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '796.26', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '13', 'flags': 'fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsr'}]\n\nkev:\n[{'cache size': '512 KB', 'cpu MHz': '350.799', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '5', 'cpuid level': '2', 'model name': 'Pentium II (Deschutes)', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '699.59', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '3', 'flags': 'fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr'}, {'cache size': '512 KB', 'cpu MHz': '350.799', 'processor': '1', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '5', 'cpuid level': '2', 'model name': 'Pentium II (Deschutes)', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '701.23', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '3', 'flags': 'fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr'}]\n\nath:\n[{'cache size': '512 KB', 'cpu MHz': '503.542', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '1', 'cpuid level': '1', 'model name': 'AMD-K7(tm) Processor', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '1002.70', 'vendor_id': 'AuthenticAMD', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '2', 'flags': 'fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat mmx syscall mmxext 3dnowext 3dnow'}]\n\nfiasco:\n[{'max. addr. space #': '127', 'cpu': 'Alpha', 'cpu serial number': 'Linux_is_Great!', 'kernel unaligned acc': '0 (pc=0,va=0)', 'system revision': '0', 'system variation': 'LX164', 'cycle frequency [Hz]': '533185472', 'system serial number': 'MILO-2.0.35-c5.', 'timer frequency [Hz]': '1024.00', 'cpu model': 'EV56', 'platform string': 'N/A', 'cpu revision': '0', 'BogoMIPS': '530.57', 'cpus detected': '0', 'phys. address bits': '40', 'user unaligned acc': '1340 (pc=2000000ec90,va=20001156da4)', 'page size [bytes]': '8192', 'system type': 'EB164', 'cpu variation': '0'}]\n\"\"\"\n\nif __name__ == \"__main__\":\n cpu = cpuinfo()\n\n cpu.is_blaa()\n cpu.is_Intel()\n cpu.is_Alpha()\n\n print 'CPU information:',\n for name in dir(cpuinfo):\n if name[0]=='_' and name[1]!='_' and getattr(cpu,name[1:])():\n print name[1:],\n print\n", "methods": [ { "name": "_try_call", "long_name": "_try_call( self , func )", "filename": "cpuinfo.py", "nloc": 5, "complexity": 2, "token_count": 16, "parameters": [ "self", "func" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 4, "token_count": 71, "parameters": [ "self", "name" ], "start_line": 37, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 16, "complexity": 7, "token_count": 112, "parameters": [ "self" ], "start_line": 52, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 73, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_2", "long_name": "_is_AthlonK6_2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_3", "long_name": "_is_AthlonK6_3( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 79, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6", "long_name": "_is_AthlonK6( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 82, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK7", "long_name": "_is_AthlonK7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 85, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Alpha", "long_name": "_is_Alpha( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 90, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV4", "long_name": "_is_EV4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 93, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV5", "long_name": "_is_EV5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 96, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV56", "long_name": "_is_EV56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 99, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PCA56", "long_name": "_is_PCA56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 102, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 110, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 113, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 116, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 119, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Celeron", "long_name": "_is_Celeron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 122, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 126, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 130, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 136, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 140, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_fdiv_bug", "long_name": "_has_fdiv_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 149, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_f00f_bug", "long_name": "_has_f00f_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 152, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 155, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 158, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 161, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 164, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 20, "complexity": 7, "token_count": 122, "parameters": [ "self" ], "start_line": 171, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 195, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__cputype", "long_name": "__cputype( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 36, "parameters": [ "self", "n" ], "start_line": 198, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_ip", "long_name": "get_ip( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 216, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 29, "parameters": [ "self", "n" ], "start_line": 219, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 17, "complexity": 7, "token_count": 117, "parameters": [ "self" ], "start_line": 241, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 261, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ppc", "long_name": "_is_ppc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 263, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "n" ], "start_line": 266, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "_try_call", "long_name": "_try_call( self , func )", "filename": "cpuinfo.py", "nloc": 5, "complexity": 2, "token_count": 16, "parameters": [ "self", "func" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 4, "token_count": 71, "parameters": [ "self", "name" ], "start_line": 37, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 16, "complexity": 7, "token_count": 112, "parameters": [ "self" ], "start_line": 52, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 73, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6", "long_name": "_is_AthlonK6( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK7", "long_name": "_is_AthlonK7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 79, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Alpha", "long_name": "_is_Alpha( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 84, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV4", "long_name": "_is_EV4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 87, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV5", "long_name": "_is_EV5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 90, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV56", "long_name": "_is_EV56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 93, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PCA56", "long_name": "_is_PCA56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 96, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 104, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 107, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 110, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 113, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Celeron", "long_name": "_is_Celeron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 116, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 120, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 130, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 134, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 140, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_fdiv_bug", "long_name": "_has_fdiv_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 143, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_f00f_bug", "long_name": "_has_f00f_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 149, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 152, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 155, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 158, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 20, "complexity": 7, "token_count": 122, "parameters": [ "self" ], "start_line": 165, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 189, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__cputype", "long_name": "__cputype( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 36, "parameters": [ "self", "n" ], "start_line": 192, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_ip", "long_name": "get_ip( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 210, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 29, "parameters": [ "self", "n" ], "start_line": 213, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 261, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "n" ], "start_line": 266, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_2", "long_name": "_is_AthlonK6_2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_3", "long_name": "_is_AthlonK6_3( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 79, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ppc", "long_name": "_is_ppc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 263, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 17, "complexity": 7, "token_count": 117, "parameters": [ "self" ], "start_line": 241, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 } ], "nloc": 240, "complexity": 69, "token_count": 2061, "diff_parsed": { "added": [ " def _is_AthlonK6_2(self):", " return self._is_AMD() and self.info[0]['model'] == '2'", "", " def _is_AthlonK6_3(self):", " return self._is_AMD() and self.info[0]['model'] == '3'", "", "class darwin_cpuinfo(cpuinfo_base):", "", " info = None", "", " def __init__(self):", " if self.info is not None:", " return", " info = []", " try:", " import commands", " status,output = commands.getstatusoutput('arch')", " if not status:", " if not info: info.append({})", " info[-1]['arch'] = string.strip(output)", " status,output = commands.getstatusoutput('machine')", " if not status:", " if not info: info.append({})", " info[-1]['machine'] = string.strip(output)", " except:", " print sys.exc_value,'(ignoring)'", " self.__class__.info = info", "", " def _not_impl(self): pass", "", " def _is_i386(self):", " return self.info[0]['arch']=='i386'", " def _is_ppc(self):", " return self.info[0]['arch']=='ppc'", "", " def __machine(self,n):", " return self.info[0]['machine'] == 'ppc%s'%n", " def _is_ppc601(self): return self.__machine(601)", " def _is_ppc602(self): return self.__machine(602)", " def _is_ppc603(self): return self.__machine(603)", " def _is_ppc603e(self): return self.__machine('603e')", " def _is_ppc604(self): return self.__machine(604)", " def _is_ppc604e(self): return self.__machine('604e')", " def _is_ppc620(self): return self.__machine(620)", " def _is_ppc630(self): return self.__machine(630)", " def _is_ppc740(self): return self.__machine(740)", " def _is_ppc7400(self): return self.__machine(7400)", " def _is_ppc7450(self): return self.__machine(7450)", " def _is_ppc750(self): return self.__machine(750)", " def _is_ppc403(self): return self.__machine(403)", " def _is_ppc505(self): return self.__machine(505)", " def _is_ppc801(self): return self.__machine(801)", " def _is_ppc821(self): return self.__machine(821)", " def _is_ppc823(self): return self.__machine(823)", " def _is_ppc860(self): return self.__machine(860)", "elif sys.platform == 'darwin':", " cpuinfo = darwin_cpuinfo" ], "deleted": [ "", "\"\"\"", "laptop:", "[{'cache size': '256 KB', 'cpu MHz': '399.129', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '6', 'cpuid level': '2', 'model name': 'Mobile Pentium II', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '796.26', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '13', 'flags': 'fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsr'}]", "", "kev:", "[{'cache size': '512 KB', 'cpu MHz': '350.799', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '5', 'cpuid level': '2', 'model name': 'Pentium II (Deschutes)', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '699.59', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '3', 'flags': 'fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr'}, {'cache size': '512 KB', 'cpu MHz': '350.799', 'processor': '1', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '5', 'cpuid level': '2', 'model name': 'Pentium II (Deschutes)', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '701.23', 'vendor_id': 'GenuineIntel', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '3', 'flags': 'fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr'}]", "", "ath:", "[{'cache size': '512 KB', 'cpu MHz': '503.542', 'processor': '0', 'fdiv_bug': 'no', 'coma_bug': 'no', 'model': '1', 'cpuid level': '1', 'model name': 'AMD-K7(tm) Processor', 'fpu_exception': 'yes', 'hlt_bug': 'no', 'bogomips': '1002.70', 'vendor_id': 'AuthenticAMD', 'fpu': 'yes', 'wp': 'yes', 'cpu family': '6', 'f00f_bug': 'no', 'stepping': '2', 'flags': 'fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat mmx syscall mmxext 3dnowext 3dnow'}]", "", "fiasco:", "[{'max. addr. space #': '127', 'cpu': 'Alpha', 'cpu serial number': 'Linux_is_Great!', 'kernel unaligned acc': '0 (pc=0,va=0)', 'system revision': '0', 'system variation': 'LX164', 'cycle frequency [Hz]': '533185472', 'system serial number': 'MILO-2.0.35-c5.', 'timer frequency [Hz]': '1024.00', 'cpu model': 'EV56', 'platform string': 'N/A', 'cpu revision': '0', 'BogoMIPS': '530.57', 'cpus detected': '0', 'phys. address bits': '40', 'user unaligned acc': '1340 (pc=2000000ec90,va=20001156da4)', 'page size [bytes]': '8192', 'system type': 'EB164', 'cpu variation': '0'}]", "\"\"\"", "" ] } } ] }, { "hash": "58ac35e75714079b0aeb2a63b378dde612e8d6c6", "msg": "Fixed test_special to test over 100 of the functions. Other tests need to be fixed. Added Pade routine to find Pade approximation. More tutorial additions.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-01-09T09:30:09+00:00", "author_timezone": 0, "committer_date": "2003-01-09T09:30:09+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "414f3b3d68a6095a605c006af043b9da8b129c1b" ], "project_name": "repo_copy", "project_path": "/tmp/tmpeg1njtem/repo_copy", "deletions": 1, "insertions": 4, "lines": 5, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_test/testing.py", "new_path": "scipy_test/testing.py", "filename": "testing.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -7,7 +7,7 @@\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n- from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64\n+ from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray\n import scipy_base.fastumath as math\n except ImportError:\n pass\n@@ -381,6 +381,7 @@ def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \n __all__.append('assert_array_equal')\n def assert_array_equal(x,y,err_msg=''):\n+ x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n@@ -394,6 +395,8 @@ def assert_array_equal(x,y,err_msg=''):\n \n __all__.append('assert_array_almost_equal')\n def assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n+ x = asarray(x)\n+ y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n", "added_lines": 4, "deleted_lines": 1, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\n__all__.append('set_package_path')\ndef set_package_path():\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n del sys.path[0]\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(1)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i//test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n del sys.path[0]\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(1)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i