Add Python::has_minimum_version
This commit is contained in:
@ -75,24 +75,20 @@ using namespace LAMMPS_NS;
|
|||||||
|
|
||||||
kimProperty::kimProperty(LAMMPS *lmp) : Pointers(lmp)
|
kimProperty::kimProperty(LAMMPS *lmp) : Pointers(lmp)
|
||||||
{
|
{
|
||||||
#if LMP_PYTHON
|
|
||||||
#if PY_MAJOR_VERSION != 3
|
|
||||||
error->all(FLERR, "Invalid Python version.\n"
|
|
||||||
"The kim-property Python package requires Python "
|
|
||||||
"3 >= 3.6 support.");
|
|
||||||
#endif
|
|
||||||
// one-time initialization of Python interpreter
|
// one-time initialization of Python interpreter
|
||||||
python->init();
|
python->init();
|
||||||
#else
|
|
||||||
error->all(FLERR, "Error Python support missing! Compile with PYTHON "
|
if (!python->has_minimum_version(3, 6)) {
|
||||||
"package installed!");
|
error->all(FLERR, "Invalid Python version.\n"
|
||||||
#endif // LMP_PYTHON
|
"The kim-property Python package requires Python "
|
||||||
|
"3 >= 3.6 support.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void kimProperty::command(int narg, char **arg)
|
void kimProperty::command(int narg, char **arg)
|
||||||
{
|
{
|
||||||
#if LMP_PYTHON
|
#if LMP_PYTHON
|
||||||
#if PY_MAJOR_VERSION == 3
|
#if PY_MAJOR_VERSION >= 3
|
||||||
if (narg < 2)
|
if (narg < 2)
|
||||||
error->all(FLERR, "Invalid `kim_property` command.");
|
error->all(FLERR, "Invalid `kim_property` command.");
|
||||||
|
|
||||||
|
|||||||
@ -535,3 +535,10 @@ void PythonImpl::deallocate(int i)
|
|||||||
delete [] pfuncs[i].ovarname;
|
delete [] pfuncs[i].ovarname;
|
||||||
delete [] pfuncs[i].longstr;
|
delete [] pfuncs[i].longstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
bool PythonImpl::has_minimum_version(int major, int minor)
|
||||||
|
{
|
||||||
|
return (PY_MAJOR_VERSION == major && PY_MINOR_VERSION >= minor) || (PY_MAJOR_VERSION > major);
|
||||||
|
}
|
||||||
|
|||||||
@ -32,6 +32,7 @@ class PythonImpl : protected Pointers, public PythonInterface {
|
|||||||
char *long_string(int);
|
char *long_string(int);
|
||||||
int execute_string(char *);
|
int execute_string(char *);
|
||||||
int execute_file(char *);
|
int execute_file(char *);
|
||||||
|
bool has_minimum_version(int major, int minor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int ninput,noutput,length_longstr;
|
int ninput,noutput,length_longstr;
|
||||||
|
|||||||
@ -117,3 +117,11 @@ int Python::execute_file(char *fname)
|
|||||||
init();
|
init();
|
||||||
return impl->execute_file(fname);
|
return impl->execute_file(fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
bool Python::has_minimum_version(int major, int minor)
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
return impl->has_minimum_version(major, minor);
|
||||||
|
}
|
||||||
|
|||||||
@ -28,6 +28,7 @@ public:
|
|||||||
virtual char * long_string(int ifunc) = 0;
|
virtual char * long_string(int ifunc) = 0;
|
||||||
virtual int execute_string(char *) = 0;
|
virtual int execute_string(char *) = 0;
|
||||||
virtual int execute_file(char *) = 0;
|
virtual int execute_file(char *) = 0;
|
||||||
|
virtual bool has_minimum_version(int major, int minor) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Python : protected Pointers {
|
class Python : protected Pointers {
|
||||||
@ -42,6 +43,7 @@ public:
|
|||||||
char * long_string(int ifunc);
|
char * long_string(int ifunc);
|
||||||
int execute_string(char *);
|
int execute_string(char *);
|
||||||
int execute_file(char *);
|
int execute_file(char *);
|
||||||
|
bool has_minimum_version(int major, int minor);
|
||||||
|
|
||||||
bool is_enabled() const;
|
bool is_enabled() const;
|
||||||
void init();
|
void init();
|
||||||
|
|||||||
Reference in New Issue
Block a user