From 8f4c7eaa417061b317648930a10e7e95789c9c7f Mon Sep 17 00:00:00 2001 From: Bastian Eicher Date: Tue, 30 Jun 2015 22:15:41 +0200 Subject: [PATCH] Generate batch file instead of shell script on Windows --- setup.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 17a3dea..5570df0 100644 --- a/setup.py +++ b/setup.py @@ -18,8 +18,54 @@ def init_releases_directory(feed): master_feed_name = feed.get_name().replace(' ', '-') + '.xml' - make_release = file('make-release', 'w') - make_release.write("""#!/bin/sh + if os.name == 'nt': + make_release = file('make-release.bat', 'w') + make_release.write("""@echo off + +:: The directory people will download the releases from. +:: This will appear in the remote feed file. +::set ARCHIVE_DIR_PUBLIC_URL=http://placeholder.org/releases/%%RELEASE_VERSION%% +set ARCHIVE_DIR_PUBLIC_URL= + +:: The path to the main feed. +:: The new version is added here when you publish a release. +::set MASTER_FEED_FILE="$HOME/public_html/feeds/MyProg.xml" +set MASTER_FEED_FILE=%s + +:: A shell command to upload the generated archive file to the +:: public server (corresponds to %%ARCHIVE_DIR_PUBLIC_URL%%, which is +:: used to download it again). +:: If unset, you'll have to upload it yourself. +::set ARCHIVE_UPLOAD_COMMAND=scp %%* me@myhost:/var/www/releases/%%RELEASE_VERSION%%/ +set ARCHIVE_UPLOAD_COMMAND= + +:: A shell command to upload the master feed (%%MASTER_FEED_FILE%%) and +:: related files to your web server. It will be downloaded using the +:: feed's URL. If unset, you'll have to upload it yourself. +::set MASTER_FEED_UPLOAD_COMMAND=scp %%* me@myhost:/var/www/feeds/ +set MASTER_FEED_UPLOAD_COMMAND= + +:: Your public version control repository. When publishing, the new +:: HEAD and the release tag will be pushed to this using a command +:: such as "git-push main master v0.1" +:: If unset, you'll have to update it yourself. +::set PUBLIC_SCM_REPOSITORY=origin +set PUBLIC_SCM_REPOSITORY= + +cd /d "%%~dp0" +0launch %s --release %s ^ + --archive-dir-public-url="%%ARCHIVE_DIR_PUBLIC_URL%%" ^ + --master-feed-file="%%MASTER_FEED_FILE%%" ^ + --archive-upload-command="%%ARCHIVE_UPLOAD_COMMAND%%" ^ + --master-feed-upload-command="%%MASTER_FEED_UPLOAD_COMMAND%%" ^ + --public-scm-repository="%%PUBLIC_SCM_REPOSITORY%%" ^ + %%* +""" % (master_feed_name, release_uri, feed.local_path)) + make_release.close() + print "Success - created script:\n %s" % os.path.abspath('make-release.bat') + else: + make_release = file('make-release', 'w') + make_release.write("""#!/bin/sh # The directory people will download the releases from. # This will appear in the remote feed file. @@ -60,7 +106,8 @@ exec 0launch %s --release %s \\ --public-scm-repository="$PUBLIC_SCM_REPOSITORY" \\ "$@" """ % (master_feed_name, release_uri, feed.local_path)) - make_release.close() - os.chmod('make-release', 0775 & ~umask) - print "Success - created script:\n %s\nNow edit it with your local settings." % os.path.abspath('make-release') + make_release.close() + os.chmod('make-release', 0775 & ~umask) + print "Success - created script:\n %s" % os.path.abspath('make-release') + print "Now edit it with your local settings." print "Then, create new releases by running it." -- 2.11.4.GIT