X Tutup
Skip to content

Commit e0ca373

Browse files
committed
SESPRINGPYTHONPY-102: Patched build.py to make it OS neutral. Works with python2.4, 2.5, and 2.6.
git-svn-id: https://src.springframework.org/svn/se-springpython-py/trunk/springpython@509 ce8fead1-4192-4296-8608-a705134b927f
1 parent b616d89 commit e0ca373

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

build.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ def clean(dir):
112112
print "Removing '%s' directory" % dir
113113
if os.path.exists(dir):
114114
shutil.rmtree(dir, True)
115-
# TODO: Make this OS-independent
116-
os.system("find . -name '*.pyc' -exec rm -f {} \;")
117-
os.system("find . -name '*.class' -exec rm -f {} \;")
118-
115+
for root, dirs, files in os.walk(".", topdown=False):
116+
for name in files:
117+
if name.endswith(".pyc") or name.endswith(".class"):
118+
os.remove(os.path.join(root, name))
119+
119120
def test(dir):
120121
"""
121122
Run nose programmatically, so that it uses the same python version as this script uses
@@ -170,18 +171,34 @@ def build(dir, version, s3bucket, filepath):
170171
patterns_to_replace = [("version", version), ("download_url", "http://s3.amazonaws.com/%s/%s-%s.tar.gz" % (s3bucket, s3key, version))]
171172

172173
_substitute(dir + "/build.py", dir + "/setup.py", patterns_to_replace)
173-
os.system("cd %s ; python setup.py sdist ; mv dist/* .. ; \\rm -rf dist ; \\rm -f MANIFEST" % dir)
174-
174+
175+
os.chdir(dir)
176+
os.system("%s %s sdist" % (sys.executable, os.path.join(".", "setup.py")))
177+
os.chdir("..")
178+
179+
dist_dir = os.path.join(os.getcwd(), dir, "dist")
180+
181+
for name in os.listdir(dist_dir):
182+
old_location = os.path.join(dist_dir,name)
183+
new_location = "."
184+
shutil.move(old_location, new_location)
185+
186+
os.rmdir(dist_dir)
187+
os.remove(os.path.join(dir, "MANIFEST"))
188+
175189
def package(dir, version, s3bucket, src_filename, sample_filename):
176190
if not os.path.exists(dir):
177191
os.makedirs(dir)
178192

179193
_substitute("src/plugins/coily-template", "src/plugins/coily", [("version", version)])
180-
os.system("chmod 755 src/plugins/coily")
194+
os.chmod("src/plugins/coily", 0755)
181195
build("src", version, s3bucket, src_filename)
182196
build("samples", version, s3bucket, sample_filename)
183197
os.remove("src/plugins/coily")
184-
os.system("mv *.tar.gz %s" % dir)
198+
199+
for name in glob("*.tar.gz"):
200+
old_location = os.path.join(".", name)
201+
shutil.move(old_location, dir)
185202

186203
curdir = os.getcwd()
187204
os.chdir("src/plugins")
@@ -243,8 +260,8 @@ def publish(filepath, s3bucket, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, versio
243260
print "Error code %s: Unable to publish" % check.status
244261

245262
def register():
246-
os.system("cd src ; python setup.py register")
247-
os.system("cd samples ; python setup.py register")
263+
os.system("cd src ; %s setup.py register" % sys.executable)
264+
os.system("cd samples ; %s setup.py register" % sys.executable)
248265

249266
def copy(src, dest, patterns):
250267
if not os.path.exists(dest):

0 commit comments

Comments
 (0)
X Tutup