Jelajahi Sumber

Merge pull request #3 from oz123/dev

merge dev to master
Oz N Tiram 3 tahun lalu
induk
melakukan
53d615fe1c
3 mengubah file dengan 76 tambahan dan 1 penghapusan
  1. 3 0
      README.md
  2. 68 0
      blogit.spec
  3. 5 1
      blogit/blogit.py

+ 3 - 0
README.md

@@ -1,3 +1,6 @@
+# NOTE: The development of this software project continues in gitlab: 
+https://gitlab.com/oz123/blogit
+
 blogit
 ======
 

+ 68 - 0
blogit.spec

@@ -0,0 +1,68 @@
+# -*- mode: python -*-
+
+block_cipher = None
+
+
+def Entrypoint(dist, group, name, **kwargs):
+    import pkg_resources
+
+    # get toplevel packages of distribution from metadata
+    def get_toplevel(dist):
+        distribution = pkg_resources.get_distribution(dist)
+        if distribution.has_metadata('top_level.txt'):
+            return list(distribution.get_metadata('top_level.txt').split())
+        else:
+            return []
+
+    kwargs.setdefault('hiddenimports', [])
+    packages = []
+    for distribution in kwargs['hiddenimports']:
+        packages += get_toplevel(distribution)
+
+    kwargs.setdefault('pathex', [])
+    # get the entry point
+    ep = pkg_resources.get_entry_info(dist, group, name)
+    # insert path of the egg at the verify front of the search path
+    kwargs['pathex'] = [ep.dist.location] + kwargs['pathex']
+    # script name must not be a valid module name to avoid name clashes on import
+    script_path = os.path.join(workpath, name + 'launcher')
+    print("creating script for entry point", dist, group, name)
+    with open(script_path, 'w') as fh:
+        print("import", ep.module_name, file=fh)
+        print("%s.%s()" % (ep.module_name, '.'.join(ep.attrs)), file=fh)
+        for package in packages:
+            print("import", package, file=fh)
+
+    return Analysis(
+        [script_path] + kwargs.get('scripts', []),
+        **kwargs
+    )
+
+a = Entrypoint('blogit', 'console_scripts', 'blogit',
+               datas=[('blogit/blogit-mir/*', 'blogit-mir')])
+
+pyz = PYZ(a.pure, a.zipped_data,
+             cipher=block_cipher)
+exe = EXE(pyz,
+          a.scripts,
+          a.binaries,
+          a.zipfiles,
+          a.datas,
+          [],
+          name='blogit',
+          debug=False,
+          bootloader_ignore_signals=False,
+          strip=False,
+          upx=True,
+          runtime_tmpdir=None,
+          console=True )
+
+coll = COLLECT(
+    exe,
+    a.binaries,
+    a.zipfiles,
+    a.datas,
+    name='blogit-dir',
+    strip=False,
+    upx=True
+)

+ 5 - 1
blogit/blogit.py

@@ -481,7 +481,11 @@ def preview():  # pragma: no coverage
 
 
 def quick_start():  # pragma: no coverage
-    path = resource_filename(Requirement.parse("blogit"), 'blogit/blogit-mir')
+    if getattr(sys, 'frozen', False):
+        path = os.path.join(sys._MEIPASS, 'blogit-mir')
+    else:
+        path = resource_filename(Requirement.parse("blogit"),
+                                 'blogit/blogit-mir')
     copy_tree(path, '.')
     print("edit conf.py, create some pages and posts and run blogit --preview")