scrapy / scrapyd

A service daemon to run Scrapy spiders
https://scrapyd.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
2.93k stars 571 forks source link

Why not use __main__? #454

Closed dhvcc closed 1 year ago

dhvcc commented 1 year ago

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!

jpmckinney commented 1 year ago

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 1 year ago

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.

jpmckinney commented 1 year ago

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.