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