|
| 1 | +""" |
| 2 | +This file generates `generated.pyx` which is then included in `../algos.pyx` |
| 3 | +during building. To regenerate `generated.pyx`, just run: |
| 4 | +
|
| 5 | + `python generate_code.py`. |
| 6 | +
|
| 7 | +""" |
| 8 | + |
1 | 9 | from __future__ import print_function |
2 | | -# we only need to be able to run this file on 2.7 |
3 | | -# don't introduce a pandas/pandas.compat import |
4 | | -# or we get a bootstrapping problem |
5 | | -from StringIO import StringIO |
| 10 | +import os |
| 11 | +from pandas.compat import StringIO |
6 | 12 | import numpy as np |
7 | 13 |
|
8 | 14 | _int64_max = np.iinfo(np.int64).max |
9 | 15 |
|
| 16 | +warning_to_new_contributors = """ |
| 17 | +# DO NOT EDIT THIS FILE: This file was autogenerated from generate_code.py, so |
| 18 | +# please edit that file and then run `python2 generate_code.py` to re-generate |
| 19 | +# this file. |
| 20 | +""" |
| 21 | + |
10 | 22 | header = """ |
11 | 23 | cimport numpy as np |
12 | 24 | cimport cython |
@@ -2580,8 +2592,14 @@ def generate_from_template(template, exclude=None): |
2580 | 2592 | take_2d_multi_template] |
2581 | 2593 |
|
2582 | 2594 |
|
2583 | | -def generate_take_cython_file(path='generated.pyx'): |
| 2595 | +def generate_take_cython_file(): |
| 2596 | + # Put `generated.pyx` in the same directory as this file |
| 2597 | + directory = os.path.dirname(os.path.realpath(__file__)) |
| 2598 | + filename = 'generated.pyx' |
| 2599 | + path = os.path.join(directory, filename) |
| 2600 | + |
2584 | 2601 | with open(path, 'w') as f: |
| 2602 | + print(warning_to_new_contributors, file=f) |
2585 | 2603 | print(header, file=f) |
2586 | 2604 |
|
2587 | 2605 | print(generate_ensure_dtypes(), file=f) |
|
0 commit comments