| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e5d9e59 commit 57e490d
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,5 +8,5 @@ if 0x02070000 <= sys.hexversion < 0x03000000: | |||
| 8 | 8 | else: | |
| 9 | 9 | raise Exception("Unsupported python version: " + sys.version) | |
| 10 | 10 | ||
| 11 | - __version__ = "v54" | ||
| 11 | + __version__ = "%(APP_VERSION)s" | ||
| 12 | 12 | __author__ = "CEF Python authors" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,114 @@ | |||
| 1 | + # Create a setup package. | ||
| 2 | + | ||
| 3 | + import sys | ||
| 4 | + import os | ||
| 5 | + import platform | ||
| 6 | + import argparse | ||
| 7 | + import re | ||
| 8 | + import platform | ||
| 9 | + import shutil | ||
| 10 | + import glob | ||
| 11 | + | ||
| 12 | + BITS = platform.architecture()[0] | ||
| 13 | + assert (BITS == "32bit" or BITS == "64bit") | ||
| 14 | + | ||
| 15 | + PACKAGE_NAME = "cefpython1" | ||
| 16 | + | ||
| 17 | + README_TEMPLATE = os.getcwd()+r"/README.txt.template" | ||
| 18 | + INIT_TEMPLATE = os.getcwd()+r"/__init__.py.template" | ||
| 19 | + SETUP_TEMPLATE = os.getcwd()+r"/setup.py.template" | ||
| 20 | + | ||
| 21 | + def main(): | ||
| 22 | + parser = argparse.ArgumentParser(usage="%(prog)s [options]") | ||
| 23 | + parser.add_argument("-v", "--version", help="cefpython version", | ||
| 24 | + required=True) | ||
| 25 | + args = parser.parse_args() | ||
| 26 | + assert re.search(r"^v\d+$", args.version), "Invalid version string" | ||
| 27 | + | ||
| 28 | + vars = {} | ||
| 29 | + vars["APP_VERSION"] = args.version | ||
| 30 | + | ||
| 31 | + print("Reading template: %s" % README_TEMPLATE) | ||
| 32 | + f = open(README_TEMPLATE) | ||
| 33 | + README_CONTENT = f.read() % vars | ||
| 34 | + f.close() | ||
| 35 | + | ||
| 36 | + print("Reading template: %s" % INIT_TEMPLATE) | ||
| 37 | + f = open(INIT_TEMPLATE) | ||
| 38 | + INIT_CONTENT = f.read() % vars | ||
| 39 | + f.close() | ||
| 40 | + | ||
| 41 | + print("Reading template: %s" % SETUP_TEMPLATE) | ||
| 42 | + f = open(SETUP_TEMPLATE) | ||
| 43 | + SETUP_CONTENT = f.read() % vars | ||
| 44 | + f.close() | ||
| 45 | + | ||
| 46 | + installer_dir = os.path.dirname(os.path.abspath(__file__)) | ||
| 47 | + | ||
| 48 | + setup_dir = installer_dir+"/"+PACKAGE_NAME+"_"+vars["APP_VERSION"]+"_linux_"+BITS+"_setup" | ||
| 49 | + print("Creating setup dir: "+setup_dir) | ||
| 50 | + os.mkdir(setup_dir) | ||
| 51 | + | ||
| 52 | + package_dir = setup_dir+"/"+PACKAGE_NAME | ||
| 53 | + print("Creating package dir") | ||
| 54 | + os.mkdir(package_dir) | ||
| 55 | + | ||
| 56 | + print("Creating README.txt from template") | ||
| 57 | + with open(setup_dir+"/README.txt", "w") as f: | ||
| 58 | + f.write(README_CONTENT) | ||
| 59 | + | ||
| 60 | + print("Creating setup.py from template") | ||
| 61 | + with open(setup_dir+"/setup.py", "w") as f: | ||
| 62 | + f.write(SETUP_CONTENT) | ||
| 63 | + | ||
| 64 | + binaries_dir = os.path.abspath(installer_dir+"/../binaries_"+BITS+"/") | ||
| 65 | + print("Copying binaries to package dir") | ||
| 66 | + ret = os.system("cp -rf "+binaries_dir+"/* "+package_dir) | ||
| 67 | + assert ret == 0 | ||
| 68 | + | ||
| 69 | + os.chdir(package_dir) | ||
| 70 | + print("Removing .log files from the package dir") | ||
| 71 | + ret = os.system("rm *.log") | ||
| 72 | + assert ret == 0 | ||
| 73 | + os.chdir(installer_dir) | ||
| 74 | + | ||
| 75 | + print("Creating __init__.py from template") | ||
| 76 | + with open(package_dir+"/__init__.py", "w") as f: | ||
| 77 | + f.write(INIT_CONTENT) | ||
| 78 | + | ||
| 79 | + print("Creating examples dir in package dir") | ||
| 80 | + os.mkdir(package_dir+"/examples/") | ||
| 81 | + | ||
| 82 | + print("Creating wx dir in package dir") | ||
| 83 | + os.mkdir(package_dir+"/wx/") | ||
| 84 | + | ||
| 85 | + print("Moving example scripts from package dir to examples dir") | ||
| 86 | + examples = glob.glob(package_dir+"/*.py") | ||
| 87 | + for example in examples: | ||
| 88 | + # Ignore: cefpython_py27.py - dummy API script | ||
| 89 | + if os.path.basename(example).startswith("cefpython_"): | ||
| 90 | + continue | ||
| 91 | + # Ignore: __init__.py | ||
| 92 | + if os.path.basename(example).startswith("__"): | ||
| 93 | + continue | ||
| 94 | + os.rename(example, package_dir+"/examples/"+os.path.basename(example)) | ||
| 95 | + ret = os.system("mv "+package_dir+"/*.html "+package_dir+"/examples/") | ||
| 96 | + assert ret == 0 | ||
| 97 | + | ||
| 98 | + print("Copying wx-subpackage to wx dir in package dir") | ||
| 99 | + wx_subpackage_dir = os.path.abspath(installer_dir+"/../../wx-subpackage/") | ||
| 100 | + ret = os.system("cp -rf "+wx_subpackage_dir+"/* "+package_dir+"/wx/") | ||
| 101 | + assert ret == 0 | ||
| 102 | + | ||
| 103 | + print("Moving wx examples from wx/examples to examples/wx") | ||
| 104 | + shutil.move(package_dir+"/wx/examples", package_dir+"/wx/wx/") | ||
| 105 | + shutil.move(package_dir+"/wx/wx/", package_dir+"/examples/") | ||
| 106 | + | ||
| 107 | + print("Copying package dir examples to setup dir") | ||
| 108 | + ret = os.system("cp -rf "+package_dir+"/examples/ "+setup_dir+"/examples/") | ||
| 109 | + assert ret == 0 | ||
| 110 | + | ||
| 111 | + print("Setup Package created.") | ||
| 112 | + | ||
| 113 | + if __name__ == "__main__": | ||
| 114 | + main() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ from distutils.core import setup | |||
| 2 | 2 | ||
| 3 | 3 | setup( | |
| 4 | 4 | name='CEF Python 1', | |
| 5 | - version='v54', | ||
| 5 | + version='%(APP_VERSION)s', | ||
| 6 | 6 | description='Python bindings for the Chromium Embedded Framework', | |
| 7 | 7 | license='BSD 3-Clause', | |
| 8 | 8 | author='Czarek Tomczak', | |
| Back | FazBrowse Home | New Git URL |
0 commit comments