Skip to content

BLD: Use tempita for cython templating #13716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Jul 20, 2016

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

CC: @gfyoung

@sinhrks sinhrks added Build Library building on various platforms Clean labels Jul 20, 2016
@sinhrks sinhrks added this to the 0.19.0 milestone Jul 20, 2016
"""
Template for each `dtype` helper function for join

WARNING: DO NOT edit .pxi FILE directly, .pxi is generated from .pxi.in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this warning should only be on the .pxi right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I see, maybe make sure this warning is in all of the .pxi.in files.....

@jreback
Copy link
Contributor

jreback commented Jul 20, 2016

does this change build time?

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

@codecov-io
Copy link

codecov-io commented Jul 20, 2016

Current coverage is 84.56% (diff: 100%)

Merging #13716 into master will not change coverage

@@             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. Last update 9f94e6a...09f63b6

@sinhrks
Copy link
Member Author

sinhrks commented Jul 20, 2016

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

@jreback
Copy link
Contributor

jreback commented Jul 20, 2016

this looks fine to me. @jorisvandenbossche @wesm ?

@jorisvandenbossche
Copy link
Member

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

No further comment from me

@gfyoung
Copy link
Member

gfyoung commented Jul 20, 2016

LGTM - nice, @sinhrks !

@sinhrks sinhrks force-pushed the tempita branch 2 times, most recently from 77c4d7e to d955b70 Compare July 20, 2016 18:30
@sinhrks
Copy link
Member Author

sinhrks commented Jul 20, 2016

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.


for name, c_type, dtype, can_hold_na, nogil in dtypes:

nogil = 'with nogil:' if nogil else ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a different variable name here (e.g., nogil_str)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. also, removed unnecessary gil kw not used in templates.

@jreback
Copy link
Contributor

jreback commented Jul 20, 2016

can you make sure this is lintable (and add on as well), see here

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

@jreback
Copy link
Contributor

jreback commented Jul 21, 2016

@sinhrks ping when ready

@@ -23,14 +23,26 @@ if [ "$LINT" ]; then
for path in 'window.pyx'
do
echo "linting -> pandas/$path"
flake8 pandas/$path --filename '*.pyx' --select=E501,E302,E203,E226,E111,E114,E221,E303,E128,E231,E126,E128
flake8 pandas/$path --filename '*.pyx' --select=E501,E302,E203,E226,E111,E114,E221,E303,E128,E231,E126
Copy link
Member Author

@sinhrks sinhrks Jul 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E128 is duplicated, thus removed.

@sinhrks sinhrks force-pushed the tempita branch 3 times, most recently from 6cc47c9 to fa307af Compare July 21, 2016 13:17
@@ -80,6 +80,7 @@ scikits
!np_datetime_strings.c
*.c
*.cpp
*.pxi
Copy link
Member

@jorisvandenbossche jorisvandenbossche Jul 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not that important for now, but in general those files should not necessarily be ignored, as we could also have non-generated .pxi files. Eg scipy includes the actual names of the generated file in the gitignore (because the generated files can also be eg .pyx files).
So maybe as good practice already include the actual names?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, by-definition .pxi are auto-generated, we never want to add them to the repo, while .pxi.in we always do.

Copy link
Member

@jorisvandenbossche jorisvandenbossche Jul 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK .pxi are just 'include' files, so they are not auto-generated by definition.

http://docs.cython.org/src/reference/language_basics.html#cython-file-types

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but WE are using them as auto-generated files (from .pxi.in)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

further we DON't want to include an auto-generated file in git. So yes maybe should specifically exclude them in .gitignore (or rather the auto-gen ones)

Copy link
Contributor

@jreback jreback Jul 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/cython/cython/wiki/FAQ#what-is-the-difference-between-a-pxd-and-pxi-file-when-should-either-be-used

I think we want to use .pxi for the auto-generated ones. while .pxd is much more like a c include file (e.g. its done by hand). .pyx is also 'hand-generated'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reconsidered this, and now I think we should include .pxi under git actually. Otherwise, Travis cache can't work because .pxi is always newly generated?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh ok - that will still reflect changes so that sounds fine

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change:

  • remove pxi from excluding rules
  • change setup.py to overwrite pxiif required comparing its timestamp.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slightly related question: is there a reason you use pxi/pxi.in files in this case, while we use pyx extension in other cases for included files? (would be nice to do this consistently within pandas)

@sinhrks sinhrks mentioned this pull request Jul 22, 2016
4 tasks
@sinhrks
Copy link
Member Author

sinhrks commented Jul 22, 2016

@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

@gfyoung
Copy link
Member

gfyoung commented Jul 22, 2016

This link here should help clarify the file extensions.

@jreback
Copy link
Contributor

jreback commented Jul 25, 2016

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

@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented Jul 25, 2016

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)

@jreback
Copy link
Contributor

jreback commented Jul 25, 2016

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

@jreback jreback closed this in 98c5b88 Jul 26, 2016
@jreback
Copy link
Contributor

jreback commented Jul 26, 2016

thanks @sinhrks

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

@sinhrks sinhrks deleted the tempita branch July 26, 2016 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Library building on various platforms Clean
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BLD: should we use tempita for cython templating
6 participants