Splunk Search

How to install a custom python library for a app with a lot of dependencies?

ConsoleBotTryPC
Path Finder

Hi,

Hope you'll are having a great day!

Coming to the question: How can I install Python libraries for usage in scripts under an app?

Basically, I have created an external lookup script, and it requires the following modules:
msgraph-sdk, azure-identity

I easily installed them for testing on my local system by using pip. Now I want to make it work on Splunk.

I researched a bit, and pretty much all the solutions mainly say to create a lib folder under etc/apps/<appName>/lib
And then copy and paste the external library folder in there.

The thing is, these libraries have a lot of dependencies with them, which get auto-installed when we do it with pip install.

So my question is, does there exist a more sophisticated and straightforward way to install these large libraries without copy-pasting potentially 100s of libraries?


Any help would be appreciated!


Thank youu,

Best,
Jay

Labels (1)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

This is about PIP install, not Splunk search. (And perhaps more suited for All Apps and Add-ons and Installation forums.)  A little googling shows https://stackoverflow.com/a/2916320/17164801 by Ian Bicking.

Use:

pip install --install-option="--prefix=$PREFIX_PATH" package_name

You might also want to use --ignore-installed to force all dependencies to be reinstalled using this new prefix. You can use --install-option to multiple times to add any of the options you can use with python setup.py install (--prefix is probably what you want, but there are a bunch more options you could use).


Hope this helps.

0 Karma

ConsoleBotTryPC
Path Finder

Alright, thanks a lot for the help.

Appreciate the help and advice for the right forum. 

Have a nice day.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...