Skip to content

Commit 387f386

Browse files
committed
Support for PyPI / pip wheel packages on Linux (cztomczak#219).
Upload "cefpython3-53.2.dev0-py2.py3-none-manylinux1_x86_64.whl" to PyPI (package for Python 2.7 / 3.4 / 3.5 and 64-bit). PIP 8.1+ is required to install manylinux1 wheel packages. Update make-setup.py. Commands that were run to build manylinux1 package after .so files were built for all distributions Python 2.7 / 3.4 / 3.5: > cd cefpython/src/linux/installer/ > python make-setup.py 53.2 > cd cefpython3*/ > python setup.py bdist_wheel --universal > cd dist/ The generated file was "cefpython3-53.2-py2.py3-none-any.whl" and it was renamed in two places: 1. Version was changed from "53.2" to "53.2.dev0" to mark it as a pre-release so that it installs only with "pip --pre" flag. However this doesn't work, it still installs without the --pre flag. Looks like it is required to mark it as "dev0" version when creating the setup package when running make-setup.py. Adding this postfix to version would break examples that make version checks - needs further investigation. Still, the "dev0" postfix is visible in file that was uploaded to PyPI. 2. Platform tag "-any.whl" was changed to "-manylinux1_x86_64.whl".
1 parent 0af803f commit 387f386

File tree

1 file changed

+38
-24
lines changed

1 file changed

+38
-24
lines changed

src/linux/installer/make-setup.py

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
import sys
88
import os
9-
import platform
10-
import argparse
119
import re
1210
import platform
1311
import shutil
@@ -26,6 +24,8 @@
2624
README_FILE = os.getcwd()+r"/README.txt"
2725
INIT_TEMPLATE = os.getcwd()+r"/__init__.py.template"
2826
SETUP_TEMPLATE = os.getcwd()+r"/setup.py.template"
27+
# SETUP_CFG_TEMPLATE = os.getcwd()+r"/setup.cfg.template"
28+
2929

3030
def str_format(string, dictionary):
3131
orig_string = string
@@ -37,19 +37,22 @@ def str_format(string, dictionary):
3737
raise Exception("Not all strings formatted")
3838
return string
3939

40+
4041
def main():
41-
parser = argparse.ArgumentParser(usage="%(prog)s [options]")
42-
parser.add_argument("-v", "--version", help="cefpython version",
43-
required=True)
44-
args = parser.parse_args()
45-
assert re.search(r"^\d+\.\d+$", args.version), (
46-
"Invalid version string")
47-
48-
vars = {}
49-
vars["APP_VERSION"] = args.version
50-
vars["PLATFORM"] = sysconfig.get_platform()
51-
vars["PY_VERSION_DIGITS_ONLY"] = (str(sys.version_info.major) + ""
52-
+ str(sys.version_info.minor)) # "27" or "34"
42+
args = ' '.join(sys.argv)
43+
match = re.search(r"\d+\.\d+", args)
44+
if match:
45+
version = match.group(0)
46+
else:
47+
print("Usage make-setup.py {version}")
48+
sys.exit(1)
49+
50+
template_vars = dict()
51+
template_vars["APP_VERSION"] = version
52+
template_vars["PLATFORM"] = sysconfig.get_platform()
53+
template_vars["PY_VERSION_DIGITS_ONLY"] = (
54+
str(sys.version_info.major) +
55+
str(sys.version_info.minor)) # e.g. "27" or "34"
5356

5457
print("Reading template: %s" % README_FILE)
5558
f = open(README_FILE)
@@ -58,17 +61,23 @@ def main():
5861

5962
print("Reading template: %s" % INIT_TEMPLATE)
6063
f = open(INIT_TEMPLATE)
61-
INIT_CONTENT = str_format(f.read(), vars)
64+
INIT_CONTENT = str_format(f.read(), template_vars)
6265
f.close()
6366

6467
print("Reading template: %s" % SETUP_TEMPLATE)
6568
f = open(SETUP_TEMPLATE)
66-
SETUP_CONTENT = str_format(f.read(), vars)
69+
SETUP_CONTENT = str_format(f.read(), template_vars)
6770
f.close()
6871

72+
# print("Reading template: %s" % SETUP_CFG_TEMPLATE)
73+
# f = open(SETUP_CFG_TEMPLATE)
74+
# SETUP_CFG_CONTENT = str_format(f.read(), template_vars)
75+
# f.close()
76+
6977
installer_dir = os.path.dirname(os.path.abspath(__file__))
7078

71-
setup_dir = installer_dir+"/"+PACKAGE_NAME+"-"+vars["APP_VERSION"]+"-"+LINUX_BITS+"-setup"
79+
setup_dir = (installer_dir + "/" + PACKAGE_NAME+"-" +
80+
template_vars["APP_VERSION"] + "-" + LINUX_BITS + "-setup")
7281
print("Creating setup dir: "+setup_dir)
7382
os.mkdir(setup_dir)
7483

@@ -79,7 +88,6 @@ def main():
7988
print("Copying License file")
8089
shutil.copy("../../../License", package_dir)
8190

82-
8391
print("Creating README.txt from template")
8492
with open(setup_dir+"/README.txt", "w") as f:
8593
f.write(README_CONTENT)
@@ -88,14 +96,18 @@ def main():
8896
with open(setup_dir+"/setup.py", "w") as f:
8997
f.write(SETUP_CONTENT)
9098

99+
# print("Creating setup.cfg from template")
100+
# with open(setup_dir+"/setup.cfg", "w") as f:
101+
# f.write(SETUP_CFG_CONTENT)
102+
91103
binaries_dir = os.path.abspath(installer_dir+"/../binaries_"+BITS+"/")
92104
print("Copying binaries to package dir")
93105
ret = os.system("cp -rf "+binaries_dir+"/* "+package_dir)
94106
assert ret == 0
95107

96108
os.chdir(package_dir)
97109
print("Removing .log files from the package dir")
98-
ret = os.system("rm *.log")
110+
os.system("rm *.log")
99111
# assert ret == 0 - if there are no .log files this assert would fail.
100112
os.chdir(installer_dir)
101113

@@ -111,7 +123,7 @@ def main():
111123

112124
print("Moving kivy-select-boxes dir to examples dir")
113125
shutil.move(package_dir+"/kivy-select-boxes",
114-
package_dir+"/examples/kivy-select-boxes")
126+
package_dir+"/examples/kivy-select-boxes")
115127

116128
print("Creating wx dir in package dir")
117129
os.mkdir(package_dir+"/wx/")
@@ -127,7 +139,9 @@ def main():
127139
continue
128140
os.rename(example, package_dir+"/examples/"+os.path.basename(example))
129141
ret = os.system("mv "+package_dir+"/*.html "+package_dir+"/examples/")
142+
assert ret == 0
130143
ret = os.system("mv "+package_dir+"/*.js "+package_dir+"/examples/")
144+
assert ret == 0
131145
ret = os.system("mv "+package_dir+"/*.css "+package_dir+"/examples/")
132146
assert ret == 0
133147

@@ -149,13 +163,13 @@ def main():
149163
debug_log_dirs = [package_dir,
150164
package_dir+"/examples/",
151165
package_dir+"/examples/wx/"]
152-
for dir in debug_log_dirs:
153-
print("Creating empty debug.log in %s" % dir)
154-
with open(dir+"/debug.log", "w") as f:
166+
for curdir in debug_log_dirs:
167+
print("Creating empty debug.log in %s" % curdir)
168+
with open(curdir+"/debug.log", "w") as f:
155169
f.write("")
156170
# Set write permissions so that Wheel package files have it
157171
# right. So that examples may be run from package directory.
158-
subprocess.call("chmod 666 %s/debug.log" % dir, shell=True)
172+
subprocess.call("chmod 666 %s/debug.log" % curdir, shell=True)
159173

160174
print("Setup Package created successfully.")
161175

0 commit comments

Comments
 (0)