diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..e69de29 diff --git a/obasync.py b/bin/obasync old mode 100755 new mode 100644 similarity index 96% rename from obasync.py rename to bin/obasync index 6520c39..7ead307 --- a/obasync.py +++ b/bin/obasync @@ -8,26 +8,28 @@ import os import sys import time -# Finds uno.py for MS-Windows -is_found_uno = False -for p in sys.path: - if os.path.exists(os.path.join(p, "uno.py")): - is_found_uno = True - break -if not is_found_uno: + +def append_uno_path(): + """ Appends the path of the uno module to the import path. """ + + is_found_uno = False + for p in sys.path: + if os.path.exists(os.path.join(p, "uno.py")): + return + # For uno.py on MacOS + cand = "/Applications/OpenOffice.app/Contents/MacOS" + if os.path.exists(os.path.join(cand, "uno.py")): + sys.path.append(cand) + return + # Finds uno.py for MS-Windows cand = sys.executable while cand != os.path.dirname(cand): cand = os.path.dirname(cand) if os.path.exists(os.path.join(cand, "uno.py")): sys.path.append(cand) - is_found_uno = True - break -# For uno.py on MacOS -if not is_found_uno: - cand = "/Applications/OpenOffice.app/Contents/MacOS" - if os.path.exists(os.path.join(cand, "uno.py")): - sys.path.append(cand) - is_found_uno = True + return + +append_uno_path() import uno from com.sun.star.connection import NoConnectException diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..0e0603e --- /dev/null +++ b/setup.py @@ -0,0 +1,22 @@ +import os +import sys +from setuptools import setup + +# For Python shipped with OpenOffice, python is a wrapper +# for python.bin that fixes the import and library path. We should +# call python instead of python.bin. """ +import os +import sys +if os.path.basename(sys.executable) == "python.bin": + sys.executable = os.path.join( + os.path.dirname(sys.executable), "python") + +setup(name="obasync", + version="0.1", + description="Office Basic macro source synchronizer", + url="https://github.com/imacat/obasync", + author="imacat", + author_email="imacat@mail.imacat.idv.tw", + license="Apache License, Version 2.0", + zip_safe=False, + scripts=["bin/obasync"])