Merge pull request #2517 from wiredfool/single_version

RFC: Specify Version in one place
This commit is contained in:
wiredfool 2017-06-29 13:17:02 +01:00 committed by GitHub
commit dc04930699
6 changed files with 25 additions and 8 deletions

View File

@ -56,7 +56,10 @@ try:
from . import _imaging as core from . import _imaging as core
if PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None): if PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None):
raise ImportError("The _imaging extension was built for another " raise ImportError("The _imaging extension was built for another "
"version of Pillow or PIL") "version of Pillow or PIL: Core Version: %s"
"Pillow Version: %s" %
(getattr(core, 'PILLOW_VERSION', None),
PILLOW_VERSION))
except ImportError as v: except ImportError as v:
core = _imaging_not_installed() core = _imaging_not_installed()

View File

@ -11,8 +11,10 @@
# ;-) # ;-)
VERSION = '1.1.7' # PIL version from . import version
PILLOW_VERSION = '4.2.0.dev0' # Pillow
VERSION = '1.1.7' # PIL Version
PILLOW_VERSION = version.__version__
__version__ = PILLOW_VERSION __version__ = PILLOW_VERSION

2
PIL/version.py Normal file
View File

@ -0,0 +1,2 @@
# Master version for Pillow
__version__ = '4.2.0.dev0'

View File

@ -71,8 +71,6 @@
* See the README file for information on usage and redistribution. * See the README file for information on usage and redistribution.
*/ */
#define PILLOW_VERSION "4.2.0.dev0"
#include "Python.h" #include "Python.h"
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
@ -3417,6 +3415,7 @@ static PyMethodDef functions[] = {
static int static int
setup_module(PyObject* m) { setup_module(PyObject* m) {
PyObject* d = PyModule_GetDict(m); PyObject* d = PyModule_GetDict(m);
const char* version = (char*)PILLOW_VERSION;
/* Ready object types */ /* Ready object types */
if (PyType_Ready(&Imaging_Type) < 0) if (PyType_Ready(&Imaging_Type) < 0)
@ -3461,7 +3460,7 @@ setup_module(PyObject* m) {
} }
#endif #endif
PyDict_SetItemString(d, "PILLOW_VERSION", PyUnicode_FromString(PILLOW_VERSION)); PyDict_SetItemString(d, "PILLOW_VERSION", PyUnicode_FromString(version));
return 0; return 0;
} }

View File

@ -1,4 +1,4 @@
version: 4.2.pre.{build} version: '{build}'
clone_folder: c:\pillow clone_folder: c:\pillow
init: init:
- ECHO %PYTHON% - ECHO %PYTHON%

View File

@ -98,6 +98,12 @@ def _read(file):
return fp.read() return fp.read()
def get_version():
version_file = 'PIL/version.py'
with open(version_file, 'r') as f:
exec(compile(f.read(), version_file, 'exec'))
return locals()['__version__']
try: try:
import _tkinter import _tkinter
except (ImportError, OSError): except (ImportError, OSError):
@ -105,7 +111,7 @@ except (ImportError, OSError):
_tkinter = None _tkinter = None
NAME = 'Pillow' NAME = 'Pillow'
PILLOW_VERSION = '4.2.0.dev0' PILLOW_VERSION = get_version()
JPEG_ROOT = None JPEG_ROOT = None
JPEG2K_ROOT = None JPEG2K_ROOT = None
ZLIB_ROOT = None ZLIB_ROOT = None
@ -585,6 +591,11 @@ class pil_build_ext(build_ext):
if struct.unpack("h", "\0\1".encode('ascii'))[0] == 1: if struct.unpack("h", "\0\1".encode('ascii'))[0] == 1:
defs.append(("WORDS_BIGENDIAN", None)) defs.append(("WORDS_BIGENDIAN", None))
if sys.platform == "win32":
defs.append(("PILLOW_VERSION", '"\\"%s\\""'%PILLOW_VERSION))
else:
defs.append(("PILLOW_VERSION", '"%s"'%PILLOW_VERSION))
exts = [(Extension("PIL._imaging", exts = [(Extension("PIL._imaging",
files, files,
libraries=libs, libraries=libs,