I want to add an entry point to setup.py and pass in an argument. Is that possible, and if so how? I've tried, and looked up documentation, but can not figure out how to do it.
Example: Package format:
mypackage/
setup.py
mypackage/
__main__.py
main.py contains:
def main(print_me=False):
if print_me:
print("test")
setup.py contains console scipts that look like:
entry_points={
'console_scripts': [
'test = mypackage.__main__:main(print_me=True)'
]}
This doesn't seem to work, what would be the correct way, if there is one?
According to setuptools' documentation on "Automatic Script Creation" this is not possible:
The functions you specify are called with no arguments
Alternatively you could do such a thing:
In __main__.py
:
def main_true():
return main(print_me=True)
In setup.py
:
entry_points={
'console_scripts': [
'test = mypackage.__main__:main_true'
],
},
But in this particular case since True
is already the default argument for the parameter print_me
, this is probably not necessary, and changing 'test = mypackage.__main__:main(print_me=True)'
to 'test = mypackage.__main__:main'
should be enough.