Skip to content
Snippets Groups Projects
Commit b904e2b2 authored by Christoph Groth's avatar Christoph Groth
Browse files

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.
parent 22991a10
No related branches found
No related tags found
No related merge requests found
......@@ -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.
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment