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
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...