Skip to content

Commit cfd4912

Browse files
committed
Support wheel package creation with "make-installer.py --wheel" (cztomczak#219)...
Add long description in wheel package, fix "DESCRIPTION.rst UNKNOWN" (cztomczak#166).
1 parent 17b3ba2 commit cfd4912

File tree

2 files changed

+71
-28
lines changed

2 files changed

+71
-28
lines changed

tools/installer/cefpython3.setup.py

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -66,56 +66,66 @@ def run(self):
6666
post_install_hook()
6767

6868

69-
class BinaryDistribution(Distribution):
70-
def is_pure(self):
71-
return False
72-
73-
7469
# Provide a custom install command
7570
print("[setup.py] Overload install command to enable execution of"
7671
" post install hook")
7772
cmdclass = {"install": custom_install}
7873

79-
# Set custom platform tags on Mac when generating wheel package. See:
80-
# http://lepture.com/en/2014/python-on-a-hard-wheel
81-
if platform.system() == "Darwin" and "bdist_wheel" in sys.argv:
82-
print("[setup.py] Overload bdist_wheel command to add custom"
83-
" platform tags")
84-
from wheel.bdist_wheel import bdist_wheel
85-
86-
class custom_bdist_wheel(bdist_wheel):
87-
def get_tag(self):
88-
tag = bdist_wheel.get_tag(self)
89-
platform_tag = ("macosx_10_6_intel"
90-
".macosx_10_9_intel.macosx_10_9_x86_64"
91-
".macosx_10_10_intel.macosx_10_10_x86_64")
92-
tag = (tag[0], tag[1], platform_tag)
93-
return tag
94-
95-
cmdclass["bdist_wheel"] = custom_bdist_wheel
96-
elif platform.system() in ["Windows", "Linux"] and "bdist_wheel" in sys.argv:
97-
# On Windows and Linux platform tag is always "any".
74+
# Fix platform tag in wheel package
75+
if "bdist_wheel" in sys.argv:
9876
print("[setup.py] Overload bdist_wheel command to fix platform tag")
9977
from wheel.bdist_wheel import bdist_wheel
10078

10179
class custom_bdist_wheel(bdist_wheel):
10280
def get_tag(self):
10381
tag = bdist_wheel.get_tag(self)
10482
platform_tag = sysconfig.get_platform()
83+
if platform.system() == "Linux":
84+
assert "linux" in platform_tag
85+
# "linux-x86_64" replace with "manylinux1_x86_64"
86+
platform_tag = platform_tag.replace("linux", "manylinux1")
87+
platform_tag = platform_tag.replace("-", "_")
88+
elif platform.system() == "Darwin":
89+
# For explanation of Mac platform tags, see:
90+
# http://lepture.com/en/2014/python-on-a-hard-wheel
91+
platform_tag = ("macosx_10_6_intel"
92+
".macosx_10_9_intel.macosx_10_9_x86_64"
93+
".macosx_10_10_intel.macosx_10_10_x86_64")
10594
tag = (tag[0], tag[1], platform_tag)
10695
return tag
10796

97+
# Overwrite bdist_wheel command
10898
cmdclass["bdist_wheel"] = custom_bdist_wheel
10999

110100

111101
def main():
112102
setup(
113-
distclass=BinaryDistribution,
103+
distclass=Distribution,
114104
cmdclass=cmdclass,
115105
name="cefpython3", # No spaces here, so that it works with deb pkg
116106
version="{{VERSION}}",
117107
description="GUI toolkit for embedding a Chromium widget"
118108
" in desktop applications",
109+
long_description="CEF Python is an open source project founded"
110+
" by Czarek Tomczak in 2012 to provide python"
111+
" bindings for the Chromium Embedded Framework."
112+
" Examples of embedding CEF browser are available"
113+
" for many popular GUI toolkits including:"
114+
" wxPython, PyQt, PySide, Kivy, Panda3D, PyGTK,"
115+
" PyGObject, PyGame/PyOpenGL and PyWin32.\n\n"
116+
"There are many use cases for CEF. You can embed"
117+
" a web browser control based on Chromium with"
118+
" great HTML 5 support. You can use it to create"
119+
" a HTML 5 based GUI in an application, this can"
120+
" act as a replacement for standard GUI toolkits"
121+
" like wxWidgets, Qt or GTK. You can render web"
122+
" content off-screen in application that use custom"
123+
" drawing frameworks. You can use it for automated"
124+
" testing of existing applications. You can use it"
125+
" for web scraping or as a web crawler, or other"
126+
" kind of internet bots.\n\n"
127+
"Project website:\n"
128+
"https://github.com/cztomczak/cefpython",
119129
license="BSD 3-clause",
120130
author="Czarek Tomczak",
121131
author_email="czarek.tomczak@@gmail.com",

tools/make_installer.py

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
Create setup.py package installer.
66
77
Usage:
8-
make_installer.py VERSION
8+
make_installer.py VERSION [--wheel] [--python-tag xx] [--universal]
99
1010
Options:
1111
VERSION Version number eg. 50.0
12+
--wheel Generate wheel package.
13+
Additional args for the wheel package:
14+
--python-tag xx (eg. cp27 - cpython 2.7)
15+
--universal (any python 2 or 3)
1216
"""
1317

1418
from common import *
@@ -23,6 +27,8 @@
2327

2428
# Command line args
2529
VERSION = ""
30+
WHEEL = False
31+
WHEEL_ARGS = list()
2632

2733
# Globals
2834
SETUP_DIR = ""
@@ -89,16 +95,43 @@ def main():
8995
print("[make_installer.py] DONE. Installer package created: {setup_dir}"
9096
.format(setup_dir=SETUP_DIR))
9197

98+
# Optional generation of wheel package
99+
if WHEEL:
100+
print("[make_installer.py] Create Wheel package")
101+
if not len(WHEEL_ARGS):
102+
print("[make_installer.py] ERROR: you must specify flags"
103+
" eg. --python-tag cp27 or --universal")
104+
sys.exit(1)
105+
command = ("{python} setup.py bdist_wheel {wheel_args}"
106+
.format(python=sys.executable,
107+
wheel_args=" ".join(WHEEL_ARGS)))
108+
print("[make_installer.py] Run command: '{0}' in setup directory"
109+
.format(command))
110+
subprocess.check_call(command, cwd=SETUP_DIR, shell=True)
111+
dist_dir = os.path.join(SETUP_DIR, "dist")
112+
files = glob.glob(os.path.join(dist_dir, "*.whl"))
113+
assert len(files) == 1
114+
print("[make_installer.py] DONE. Wheel package created: {0}"
115+
.format(files[0]))
116+
92117

93118
def command_line_args():
119+
global VERSION, WHEEL, WHEEL_ARGS
94120
args = " ".join(sys.argv)
95121
match = re.search(r"\d+\.\d+", args)
96122
if match:
97-
global VERSION
98123
VERSION = match.group(0)
99124
else:
100125
print(__doc__)
101126
sys.exit(1)
127+
for arg in sys.argv:
128+
if arg == VERSION:
129+
continue
130+
if arg == "--wheel":
131+
WHEEL = True
132+
continue
133+
if WHEEL:
134+
WHEEL_ARGS.append(arg)
102135

103136

104137
def copy_tools_installer_files(setup_dir, pkg_dir):
@@ -288,7 +321,7 @@ def create_empty_log_file(log_file):
288321
command = "chmod 666 {file}".format(file=log_file)
289322
print("[make_installer.py] {command}"
290323
.format(command=command.replace(SETUP_DIR, "")))
291-
subprocess.call(command, shell=True)
324+
subprocess.check_call(command, shell=True)
292325

293326

294327
def short_src_path(path):

0 commit comments

Comments
 (0)