From b904e2b2b22b8efe2ba17ca6914cde924ee860f7 Mon Sep 17 00:00:00 2001 From: Christoph Groth <christoph.groth@cea.fr> Date: Wed, 21 Oct 2015 18:05:01 +0200 Subject: [PATCH] setup.py: disable cython by default The pip tool messes up the timestamps of files, so with our previous strategy of enabling cython by default the build fails if Cython is not available. Also, turn the "warning" into a "caution" message that is less frightening and send it to stdout only, so that it does not appear with pip. --- CONTRIBUTE.rst | 5 ++++- setup.py | 17 ++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTE.rst b/CONTRIBUTE.rst index 978d5fd3..8063c8b2 100644 --- a/CONTRIBUTE.rst +++ b/CONTRIBUTE.rst @@ -75,10 +75,13 @@ A useful trick for working on the source code is to build in-place so that there is no need to re-install after each change. This can be done with the following command :: - python setup.py build_ext -i + python setup.py build_ext -i --cython The ``kwant`` subdirectory of the source distribution will be thus turned into a proper Python package that can be imported. To be able to import Kwant from within Python, one can either work in the root directory of the distribution (where the subdirectory ``kwant`` is located), or make a (symbolic) link from somewhere in the Python search path to the the package subdirectory. + +The option ``--cython`` enables the translation of .pyx files into .c files. +It is only needed if any .pyx files have been modified. diff --git a/setup.py b/setup.py index c9dba0e6..ba679701 100755 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ MANIFEST_IN_FILE = 'MANIFEST.in' README_END_BEFORE = 'See also in this directory:' STATIC_VERSION_PATH = ('kwant', '_kwant_version.py') REQUIRED_CYTHON_VERSION = (0, 22) -NO_CYTHON_OPTION = '--no-cython' +CYTHON_OPTION = '--cython' TUT_DIR = 'tutorial' TUT_GLOB = 'doc/source/tutorial/*.py' TUT_HIDDEN_PREFIX = '#HIDDEN' @@ -59,10 +59,10 @@ version = _common.version version_is_from_git = _common.version_is_from_git try: - sys.argv.remove(NO_CYTHON_OPTION) - use_cython = False -except ValueError: + sys.argv.remove(CYTHON_OPTION) use_cython = True +except ValueError: + use_cython = False if use_cython: try: @@ -424,7 +424,7 @@ def ext_modules(extensions): if problematic_files: problematic_files = ", ".join(problematic_files) msg = ("Some Cython source files are newer than files that should have\n" - " been derived from them, but {}.\n" + "been derived from them, but {}.\n" "\n" "Affected files: {}") if use_cython: @@ -438,8 +438,11 @@ def ext_modules(extensions): complain_cython_unavailable() exit(1) else: - reason = "the option --no-cython has been given" - print(banner(" Warning "), msg.format(reason, problematic_files), + reason = "the option {} has not been given".format(CYTHON_OPTION) + dontworry = ('(Do not worry about this if you are building Kwant\n' + 'from unmodified sources, e.g. with "pip install".)\n') + print(banner(" Caution "), dontworry, + msg.format(reason, problematic_files), banner(), sep='\n', file=sys.stderr) return result -- GitLab