I want to create a thin wrapper around this library https://github.com/jupyter-incubator/sparkmagic#installation
As you can see in the link, the installation step requires
- installing some packages with pip
- run some command of the type
jupyter enable ...
orjupyter-kernelspec install
- custom configuration file that I want to generate and place in the correct place
I am checking which options I have to make the installation as automatic as calling a script. So far I have came up creating a bash script with all these commands. In this way it works with a simple install.sh
but I might have problems since I will not know which python binaries to use. If a user wants to install the lib for python2 or python3 he cannot have this choice unless he touches the script.
I have then tried to use setup.py
and override the cmdclass
to insert custom code
from setuptools import setup
from setuptools.command.develop import develop
from setuptools.command.install import install
class PostDevelopCommand(develop):
"""Post-installation for development mode."""
def run(self):
develop.run(self)
print("do things")
class PostInstallCommand(install):
"""Post-installation for installation mode."""
def run(self):
install.run(self)
print("do things")
setup(
...
install_requires=['sparkmagic'],
cmdclass={
'develop': PostDevelopCommand,
'install': PostInstallCommand,
},
...
)
but the custom prints worked only when running python setup.py install
but not for pip install
I would like to make this last option work but if this is not the right patter to do this kind of things, could you suggest me which way to go?