I'm making python application for linux os. And I'm wondering how can I make my package that will create config folders/files on executing: pip install my-package. On https://pip.pypa.io I didn't find if this is considered a bad practice, since my app is part package/app, probably the best way would to make dpkg package, but out of curiosity I want to know how can one achive this.
Add a comment |
1 Answer
Your typical setup.py file would be structured like so:
from setuptools import setup import sys setup(name = "package_name" ..... After the setup call you can use os.mkdir or anything else that you want to do.
Your final code would look something like this:
from setuptools import setup import sys import os setup(name = "package_name" ..... os.mkdir('test_path') What pip typically does is run python setup.py install. When the setup file is run, the os.mkdir will get run and hence your directory will be created.
3 Comments
ssundarraj
Place the os.mkdir after the
setup. In this case, if there are errors, it will not create the directory. Edited the answer to reflect that.