BLD: Use tempita for cython templating
State: closed

- [x] closes #13399
- [x] tests added / passed
- [x] passes `git diff upstream/master | flake8 --diff`

not sure what the `setup.py` 's best practice be...

CC: @gfyoung 


Labels:
name: Build
description: Library building on various platforms
name: Clean

Comments:
does this change build time?

you might need to change the manifest (to not include the .pxi files)

## [Current coverage](https://codecov.io/gh/pydata/pandas/pull/13716?src=pr) is 84.56% (diff: 100%)

> Merging [#13716](https://codecov.io/gh/pydata/pandas/pull/13716?src=pr) into [master](https://codecov.io/gh/pydata/pandas/branch/master?src=pr) will not change coverage

``` diff
@@             master     #13716   diff @@
==========================================
  Files           141        141          
  Lines         51195      51195          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits          43295      43295          
  Misses         7900       7900          
  Partials          0          0          
```

> Powered by [Codecov](https://codecov.io?src=pr). Last update [9f94e6a...09f63b6](https://codecov.io/gh/pydata/pandas/compare/9f94e6a04564e8269b43c5b4e83854d277ea30bd...09f63b6b0eaef2c6506acba9484aeb3412d44ac5?src=pr)

For build time, tempita looks little slower. It may caused by include files are split to 4... (both after `setup.py clean`):

on current master:

```
Finished processing dependencies for pandas==0.18.1+220.g4c9ae94

real    5m23.612s
user    4m56.507s
sys 0m14.372s
```

tempita:

```
Finished processing dependencies for pandas==0.18.1+221.g9c1d26a

real    5m52.029s
user    5m12.612s
sys 0m13.344s
```

this looks fine to me. @jorisvandenbossche @wesm ?

Nice! (@sinhrks you're quite on speed lately! :-))

No further comment from me

LGTM - nice, @sinhrks !

> you might need to change the manifest (to not include the .pxi files)

added `*.pxi` on gitignore and manifest, as currently we don't use .pxi elsewhere.

can you make sure this is lintable (and add on as well), see [here](https://github.com/pydata/pandas/blob/master/ci/lint.sh#L26)

not a big deal, but if you manually lint pyx files these will be as well 

@sinhrks ping when ready

@jorisvandenbossche 

> is there a reason you use `pxi`/`pxi.in` files in this case, while we use `pyx` extension in other cases for included files?

I don't have a strong opinion about it, the name "pxi.in" is derived from @gfyoung 's PR. whichever looks consistent:
- use ".pyx" in all Cython files
- use ".pxi" in template-generated Cython files

This link [here ](http://docs.cython.org/en/latest/src/reference/language_basics.html) should help clarify the file extensions.

@gfyoung that link doesn't seem to work, can you update.

Corrected. So from that link, `pxi` files are not specific for 'template-generated files', but for 'include' files. 

But given that we currenlty use `.pyx` files for included files as well (eg join.pyx and generated.pyx included in algos.pyx https://github.com/pydata/pandas/blob/master/pandas/algos.pyx#L1337), I would either keep using `pyx` for the template genereated include files, or rename the other included files to `pxi` to have it consistent within the pandas source code. 
(but to be clear, not that important, this PR is a really nice improvement in the code generation)

I actually like that `.pxi` is template generated, and `.pyx` is not. sort of a visual diff.

thanks @sinhrks 

can always think about the `.pxi` vs `.pyx` question, but I think ok for now.