Changed the way we check and enable Cython usage
* Cython is disable by default in dist tarballs (checking if Makefile exists) * Cython is enabled by default in git version * Only blacklist Cython in py3 (it is broken only there) * Now respect two env vars: DISABLE_CYTHON or ENABLE_CYTHON * Always use LooseVersion for checking Cython version
This commit is contained in:
parent
03f2f286e2
commit
1a3fa101e1
29
INSTALL
29
INSTALL
|
@ -3,7 +3,7 @@
|
|||
===============
|
||||
|
||||
* Python 2.6 or higher (http://www.python.org/)
|
||||
- Tested with Python 2.6 / 2.7 / 3.2 / 3.3
|
||||
- Tested with Python 2.6 / 2.7 / 3.2 / 3.3 / 3.4
|
||||
|
||||
* Cython 0.19 or higher (http://cython.org/)
|
||||
- Tested with Cython 0.19.1
|
||||
|
@ -26,27 +26,24 @@
|
|||
======================
|
||||
|
||||
Once EFL is built and installed in your desired destination, proceed with
|
||||
building the wrapper. The setup script can be forced to use purely C
|
||||
sources by setting the environment variable DISABLE_CYTHON to 1.
|
||||
building the wrapper.
|
||||
|
||||
Distribution tarballs include pre-generated C source files, so
|
||||
cython usage is disabled by default, while is enabled in development git
|
||||
versions. You can always force the usage of cython using two environment
|
||||
variables: DISABLE_CYTHON or ENABLE_CYTHON
|
||||
|
||||
|
||||
* BUILDING WITH GCC/G++ (Linux, OS X, etc.)
|
||||
|
||||
python setup.py build
|
||||
|
||||
* BUILDING WITH Visual Studio (Windows)
|
||||
|
||||
python setup.py build
|
||||
|
||||
* BUILDING WITH MINGW (Windows)
|
||||
|
||||
python setup.py build -c mingw32
|
||||
|
||||
* FORCING C SOURCES FOR BUILD
|
||||
* FORCE C SOURCES FOR BUILD
|
||||
|
||||
env DISABLE_CYTHON=1 python setup.py build
|
||||
|
||||
|
||||
* FORCE THE USAGE OF CYTHON
|
||||
|
||||
env ENABLE_CYTHON=1 python setup.py build
|
||||
|
||||
|
||||
|
||||
3. CLEANUP
|
||||
==========
|
||||
|
|
4
Makefile
4
Makefile
|
@ -5,6 +5,10 @@
|
|||
# want to type less or do not want to learn the python
|
||||
# setup syntax.
|
||||
#
|
||||
# NOTE: This file is also used to discriminate when we are building from
|
||||
# stable tarballs (in this case we disable cython by default) or from git
|
||||
# sources as the Makefile is not distributed.
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# make <cmd> to build using the default python interpreter
|
||||
|
|
119
setup.py
119
setup.py
|
@ -18,7 +18,7 @@ VERSION = "%d.%d" % (vers[0], vers[1] if vers[2] < 99 else vers[1] + 1)
|
|||
|
||||
# dependencies
|
||||
CYTHON_MIN_VERSION = "0.19"
|
||||
CYTHON_BLACKLIST = ("0.21.1", "0.21.2")
|
||||
CYTHON_BLACKLIST = ("0.21.1", "0.21.2") # only used if py3
|
||||
EFL_MIN_VER = RELEASE
|
||||
ELM_MIN_VER = RELEASE
|
||||
|
||||
|
@ -100,59 +100,7 @@ def pkg_config(name, require, min_vers=None):
|
|||
name, ver, min_vers))
|
||||
|
||||
|
||||
# === cython or pre-generated c files ===
|
||||
if os.getenv("DISABLE_CYTHON"):
|
||||
module_suffix = ".c"
|
||||
|
||||
def cythonize(modules, *args, **kwargs):
|
||||
return modules
|
||||
else:
|
||||
try:
|
||||
from Cython.Build import cythonize
|
||||
import Cython.Compiler.Options
|
||||
except ImportError:
|
||||
if not os.path.exists(os.path.join(script_path, "efl/eo/efl.eo.c")):
|
||||
raise SystemExit("Requires Cython >= %s (http://cython.org/)" % (
|
||||
CYTHON_MIN_VERSION))
|
||||
module_suffix = ".c"
|
||||
|
||||
def cythonize(modules, *args, **kwargs):
|
||||
return modules
|
||||
else:
|
||||
module_suffix = ".pyx"
|
||||
try:
|
||||
try:
|
||||
assert StrictVersion(Cython.__version__) >= \
|
||||
StrictVersion(CYTHON_MIN_VERSION)
|
||||
except ValueError:
|
||||
print("""
|
||||
Your Cython version string (%s) is weird. We'll attempt to
|
||||
check that it's higher than the minimum required: %s, but
|
||||
this is unreliable.\n
|
||||
If you run into any problems during or after installation it
|
||||
may be caused by version of Cython that's too old.""" % (
|
||||
Cython.__version__, CYTHON_MIN_VERSION
|
||||
)
|
||||
)
|
||||
assert LooseVersion(Cython.__version__) >= \
|
||||
LooseVersion(CYTHON_MIN_VERSION)
|
||||
except AssertionError:
|
||||
raise SystemExit("Requires Cython >= %s (http://cython.org/)" % (
|
||||
CYTHON_MIN_VERSION))
|
||||
|
||||
# Cython PyMethod_New() is broken! blacklisted
|
||||
if Cython.__version__ in CYTHON_BLACKLIST:
|
||||
raise SystemExit("Cython %s is broken! Use another release." %
|
||||
Cython.__version__)
|
||||
|
||||
# Stop compilation on first error
|
||||
Cython.Compiler.Options.fast_fail = True
|
||||
# Generates HTML files with annotated source
|
||||
Cython.Compiler.Options.annotate = False
|
||||
# Set to False to disable docstrings
|
||||
Cython.Compiler.Options.docstrings = True
|
||||
|
||||
|
||||
# === setup.py clean_generated_files command ===
|
||||
class CleanGenerated(Command):
|
||||
description = "Clean C and html files generated by Cython"
|
||||
user_options = []
|
||||
|
@ -177,6 +125,18 @@ class CleanGenerated(Command):
|
|||
os.remove(dbus_ml_path)
|
||||
|
||||
|
||||
# === use cython or pre-generated C files ===
|
||||
USE_CYTHON = False
|
||||
if os.getenv("DISABLE_CYTHON") is not None:
|
||||
USE_CYTHON = False
|
||||
elif os.getenv("ENABLE_CYTHON") is not None:
|
||||
USE_CYTHON = True
|
||||
elif not os.path.exists(os.path.join(script_path, "efl/eo/efl.eo.c")):
|
||||
USE_CYTHON = True
|
||||
elif os.path.exists(os.path.join(script_path, "Makefile")):
|
||||
USE_CYTHON = True
|
||||
|
||||
|
||||
ext_modules = []
|
||||
py_modules = []
|
||||
packages = ["efl"]
|
||||
|
@ -194,10 +154,36 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
|
|||
|
||||
# === Cython ===
|
||||
sys.stdout.write("Checking for Cython: ")
|
||||
if module_suffix == ".c":
|
||||
sys.stdout.write("no need, using pre-generated C files\n")
|
||||
else:
|
||||
if USE_CYTHON:
|
||||
# check if cython is installed
|
||||
try:
|
||||
from Cython.Build import cythonize
|
||||
import Cython.Compiler.Options
|
||||
except ImportError:
|
||||
raise SystemExit("not found! Needed >= %s" % (CYTHON_MIN_VERSION))
|
||||
|
||||
# check min version
|
||||
if LooseVersion(Cython.__version__) < LooseVersion(CYTHON_MIN_VERSION):
|
||||
raise SystemExit("too old! Found %s Needed %s" % (
|
||||
Cython.__version__, CYTHON_MIN_VERSION))
|
||||
|
||||
# Cython PyMethod_New() is broken for py3! blacklisted
|
||||
if sys.version_info[0] > 2 and Cython.__version__ in CYTHON_BLACKLIST:
|
||||
raise SystemExit("found %s, it's broken! Need another release" %
|
||||
Cython.__version__)
|
||||
|
||||
sys.stdout.write("OK, found %s\n" % Cython.__version__)
|
||||
module_suffix = ".pyx"
|
||||
# Stop compilation on first error
|
||||
Cython.Compiler.Options.fast_fail = True
|
||||
# Generates HTML files with annotated source
|
||||
Cython.Compiler.Options.annotate = False
|
||||
# Set to False to disable docstrings
|
||||
Cython.Compiler.Options.docstrings = True
|
||||
|
||||
else:
|
||||
sys.stdout.write("not needed, using pre-generated C files\n")
|
||||
module_suffix = ".c"
|
||||
|
||||
# === Eina ===
|
||||
eina_cflags, eina_libs = pkg_config('Eina', 'eina', EFL_MIN_VER)
|
||||
|
@ -411,6 +397,16 @@ if set(("build", "build_ext", "install", "bdist", "sdist")) & set(sys.argv):
|
|||
|
||||
packages.append("efl.elementary")
|
||||
|
||||
# Cythonize all the external modules (if needed)
|
||||
if USE_CYTHON:
|
||||
ext_modules = cythonize(ext_modules,
|
||||
include_path=["include"],
|
||||
compiler_directives={
|
||||
#"c_string_type": "unicode",
|
||||
#"c_string_encoding": "utf-8",
|
||||
"embedsignature": True,
|
||||
})
|
||||
|
||||
|
||||
setup(
|
||||
name="python-efl",
|
||||
|
@ -452,13 +448,6 @@ setup(
|
|||
},
|
||||
packages=packages,
|
||||
ext_package="efl",
|
||||
ext_modules=cythonize(ext_modules,
|
||||
include_path=["include"],
|
||||
compiler_directives={
|
||||
#"c_string_type": "unicode",
|
||||
#"c_string_encoding": "utf-8",
|
||||
"embedsignature": True,
|
||||
}
|
||||
),
|
||||
ext_modules=ext_modules,
|
||||
py_modules=py_modules,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue