scrapy/scrapyd

Why not use __main__?

dhvcc opened this issue · 3 comments

dhvcc commented

I was just wondering if there's a reason there's no __main__.py in scrapyd module? It would allow running scrapyd as a module, which is better, but that's only my opinion.
Thanks!

I'm not sure what you mean. console_scripts are configured in https://github.com/scrapy/scrapyd/blob/master/setup.py and the scrapyd command refers to this file: https://github.com/scrapy/scrapyd/blob/master/scrapyd/scripts/scrapyd_run.py

You can import modules like any other Python package without running the command's code.

dhvcc commented

Well yeah, but this entrypoint doesn't work when using python -m format. Running scrapyd is fine, but python -m scrapyd gives me No module named scrapyd.__main__; 'scrapyd' is a package and cannot be directly executed. It obviously works if I specify full path to the script like python -m scrapyd.scripts.scrapyd_run. It's just a simpler interface than using a separate script I think, plus it makes it easier to use with debuggers.

I mean, python -m scrapyd.scripts.scrapyd_run does what you need. Adding a __main__.py so that python -m scrapyd does the same thing is too low-priority.