diff --git a/pandas/src/generate_code.py b/pandas/src/generate_code.py index 5d4b18b36050f..0a488a778cc6b 100644 --- a/pandas/src/generate_code.py +++ b/pandas/src/generate_code.py @@ -1,12 +1,23 @@ +"""This file generates `generated.pyx` which is then included in `../algos.pyx` +during building. To regenerate `generated.pyx`, just run: + + `python generate_code.py`. + +""" + from __future__ import print_function -# we only need to be able to run this file on 2.7 -# don't introduce a pandas/pandas.compat import -# or we get a bootstrapping problem -from StringIO import StringIO +import os +from pandas.compat import StringIO import numpy as np _int64_max = np.iinfo(np.int64).max +warning_to_new_contributors = """ +# DO NOT EDIT THIS FILE: This file was autogenerated from generate_code.py, so +# please edit that file and then run `python2 generate_code.py` to re-generate +# this file. +""" + header = """ cimport numpy as np cimport cython @@ -2526,8 +2537,14 @@ def generate_from_template(template, exclude=None): take_2d_multi_template] -def generate_take_cython_file(path='generated.pyx'): +def generate_take_cython_file(): + # Put `generated.pyx` in the same directory as this file + directory = os.path.dirname(os.path.realpath(__file__)) + filename = 'generated.pyx' + path = os.path.join(directory, filename) + with open(path, 'w') as f: + print(warning_to_new_contributors, file=f) print(header, file=f) print(generate_ensure_dtypes(), file=f) diff --git a/pandas/src/generated.pyx b/pandas/src/generated.pyx index 83dfacba45211..b67d99146e664 100644 --- a/pandas/src/generated.pyx +++ b/pandas/src/generated.pyx @@ -1,4 +1,9 @@ +# DO NOT EDIT THIS FILE: This file was autogenerated from generate_code.py, so +# please edit that file and then run `python2 generate_code.py` to re-generate +# this file. + + cimport numpy as np cimport cython