-
Notifications
You must be signed in to change notification settings - Fork 67
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
Dependency version check #76
Comments
Would it be feasible to do something like this:
The |
Yer that could work. That's not easily doable at the moment right? |
The snippet that I wrote above would work with no changes. In practice, I'd probably write out the Does that make sense? Am I missing a piece? |
Ow do you mean to add this to the template comment in the source file? But would that trigger a rebuild as the template is only read if it's determined that a rebuild is needed? |
Here's a more explicit version of what I'm imagining. Two files:
This will result in a rebuild any time the Then, elsewhere, whenever you want to update the dependency versions, you write to that file. How exactly you write to it will depend on your exact application, but one application might be something like:
Is this useful? |
Thanks - the above works but it would be better if the dependency file was generated on the fly. This code doesn't seem to work:
Here the dependency file is generated in the template. From looking at the cppimport code I don't understand why the template isn't run a second time. |
Yes, it's as intended that the template is not being run a second time here. You can see the check for whether to enter the build step here: cppimport/cppimport/__init__.py Line 86 in e19e9a6
Currently, if the dependencies haven't changed and the extension seems built and importable then the expected behavior is to import the extension without re-running the template. I'd be open to changing the behavior so that we always run the templates on import. Or at least providing an option to run the template. One thing I'd be curious about is the performance impact of running the template during every import. Are we adding 500us or 50ms to the import time in the average case? Another related issue here is that the cppimport configuration is currently unpleasantly global. If we're adding another configuration option, it might be time to either make the configuration something that can be passed to the |
Ok I tested it here:
So its around 10 times slower. I think for our purpose it should be ok to write to the dependency file before importing the module. I will explore that option. Thanks for all the help! |
Hey,
I have a source file that has a dependency and I want to force
cppimport
to recompile the source when the dependency version changes. Unfortunately the header files of the dependency can remain the same when the version changes so I can't rely on that.I have a Python function that obtains the version of the dependency, what's the best way to force
cppimport
too recompile given this information? Would it be possible to add functionality so you can pass a string to be included in the checksum calculation (cppimport.checksum._calc_cur_checksum
)?The text was updated successfully, but these errors were encountered: