Skip to content

Instantly share code, notes, and snippets.

@plq
Created June 13, 2016 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plq/a4e383ef129618579f7cc86606c2b21d to your computer and use it in GitHub Desktop.
Save plq/a4e383ef129618579f7cc86606c2b21d to your computer and use it in GitHub Desktop.
pap() {
python -c "import $1" || exit 1;
echo $(dirname "$(python -c "import $1; print $1.__file__")"); #"
}
prp() {
retval="$1";
retval="$(pap "$retval")";
[ -z "$retval" ] && exit 1;
while [ ! -e "$retval"/setup.py ]; do
retval="$( dirname "$retval" )";
if [ "$PWD" == "/" ]; then
echo $1 icin setup.py bulunamadi;
exit 2;
fi
done;
echo "$retval";
}
get_egg() {
package=$1;
proj_path="$(prp "$package")";
(cd "$proj_path"; $PYTHON setup.py bdist_egg --exclude-source-files || exit 1;) || exit 1
mv "$proj_path"/dist/*.egg runtime;
}
verbump() {
package=$1;
proj_path="$(prp "$package")";
initfile="$proj_path/aa/__init__.py";
vline=$(grep ^__version__ "$initfile");
majmin=$(echo $vline | cut -d\' -f 2 | cut -d. -f1,2);
build=$(echo $vline | cut -d\' -f 2 | cut -d. -f3);
let "build+=1";
sed -i "s/$vline/__version__ = '$majmin.$build'/g" "$initfile";
git commit -m verbump "$initfile";
}
# sampe usage for a project that depends on twisted trunk.
get_egg twisted
get_egg myproj
verbump myproj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment