main.py -> __main__.py

Executing a package with python -m packagename will check for
__main__.py inside the package.  In other words main.py should have
always been named __main__.py.

In the unlikely event that someone depends on "import ocrmypdf.main"
being meaningful, main.py continues to exist and replicates the
behavior of __main__.  (It's unlikely because import ocrmypdf.main does
unpythonic ruffus-related things at things import time, essentially
configuring itself to work with sys.argv.  To fix another day.)

This should solve the problem of Debian needing to run test suites
before installation and afterwards for continuous integration without
having to patch either file, as python -m ocrmypdf will follow import
order.  That is, if the current directory contains "ocrmypdf/" (e.g.
staging a new version) then that will be tested, else sys.path will
be checked.
This commit is contained in:
James R. Barlow
2016-08-31 17:01:42 -07:00
parent 2625368aed
commit bd534c3313
4 changed files with 1478 additions and 1471 deletions
+1472
View File
File diff suppressed because it is too large Load Diff
Executable → Regular
+4 -1469
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -227,7 +227,7 @@ setup(
tests_require=tests_require,
entry_points={
'console_scripts': [
'ocrmypdf = ocrmypdf.main:run_pipeline'
'ocrmypdf = ocrmypdf.__main__:run_pipeline'
],
},
package_data={'ocrmypdf': ['data/sRGB.icc']},
+1 -1
View File
@@ -27,7 +27,7 @@ TEST_RESOURCES = os.path.join(PROJECT_ROOT, 'tests', 'resources')
TEST_OUTPUT = os.environ.get(
'OCRMYPDF_TEST_OUTPUT',
default=os.path.join(PROJECT_ROOT, 'tests', 'output', 'main'))
OCRMYPDF = [sys.executable, '-m', 'ocrmypdf.main']
OCRMYPDF = [sys.executable, '-m', 'ocrmypdf']
def running_in_docker():