programmatically determine number of digital and analog pins in library

I am sorry if this has already been asked but I have not been able to find any answers.

I am looking for a way to programmatically determine at run-time the total number of digital and analog pins available for the running arduino in a library. I was using NUM_DIGITAL_PINS and NUM_ANALOG_INPUTS but once I moved my code to the library folder, it can no longer include arduinopins.h.

Thanks

You could put a chain of processor-dependent "#ifdef"s together.

it can no longer include arduinopins.h.

If that file can be included in a sketch, it can be included in a library. But, to make it available to be included in the library, it must also be included in the sketch.