Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Commit

Permalink
autogenerate homebrew formula
Browse files Browse the repository at this point in the history
  • Loading branch information
iandennismiller committed Sep 28, 2016
1 parent cdbedc1 commit 5c4a65c
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 12 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Expand Up @@ -3,11 +3,9 @@ cache: pip
python:
- 2.7
- 3.5
# command to install dependencies
install:
- make dev install
# command to run tests
script:
- make travis
- nosetests -w pub2 -c etc/tests-travis.cfg --with-coverage --cover-package=pub2
after_success:
coveralls --rcfile=.coveragerc
- coveralls --rcfile=.coveragerc
10 changes: 6 additions & 4 deletions Makefile
Expand Up @@ -25,14 +25,16 @@ watch:
test:
$(TEST_CMD)

travis:
nosetests -w $(MOD_NAME) -c etc/tests-travis.cfg --with-coverage --cover-package=$(MOD_NAME)

tox:
tox

release:
# first: python setup.py register -r https://pypi.python.org/pypi
python setup.py sdist upload -r https://pypi.python.org/pypi

.PHONY: clean install test watch docs release tox dev travis
# create a homebrew install script
homebrew:
etc/poet-homebrew.sh
cp /tmp/pub2.rb etc/pub2.rb

.PHONY: clean install test watch docs release tox dev homebrew
62 changes: 62 additions & 0 deletions etc/poet-homebrew.sh
@@ -0,0 +1,62 @@
#!/bin/bash
# based on https://github.com/Homebrew/brew/blob/master/docs/Python-for-Formula-Authors.md#installing
# rebuild with 'make homebrew'

PKG=pub2

source $(brew --prefix)/bin/virtualenvwrapper.sh

# create virtualenv and install
mktmpenv
cd ~/Work/${PKG}
make install

# use poet to build pip package manifest
pip install homebrew-pypi-poet
poet ${PKG} > /tmp/poet.rb

# extract python package URL
URL=$(perl -n000e 'print $1 while /^..resource\s\"pub2\"\sdo\n\s+url\s\"(.*?)\"\n.*?\n..end\n\n/mg' /tmp/poet.rb)

# remove package resource from poet manifest
perl -0777 -i.original -pe 's/..resource\s\"pub2\"\sdo\n.*?\n.*?\n..end\n\n//igs' /tmp/poet.rb

# determine sha256 checksum for python package
curl -q -o /tmp/pkg.tgz ${URL}
SHA=$(shasum -a 256 /tmp/pkg.tgz | cut -d ' ' -f 1 -)
rm /tmp/pkg.tgz

# write header
cat > /tmp/pkg.rb <<-EOF
# Homebrew Formula
# pub2 (c) Ian Dennis Miller
# rebuild with 'make homebrew'
class Pub2 < Formula
desc "Pub2 is a self-publishing framework"
homepage "https://github.com/iandennismiller/pub2"
url "${URL}"
sha256 "${SHA}"
EOF

# write poet manifest
cat /tmp/poet.rb >> /tmp/pkg.rb

# write footer
cat >> /tmp/pkg.rb <<-EOF
include Language::Python::Virtualenv
def install
virtualenv_install_with_resources
end
end
EOF

# exit virtualenv
deactivate

# finalize
mv /tmp/pkg.rb /tmp/${PKG}.rb
echo "created /tmp/${PKG}.rb"
13 changes: 9 additions & 4 deletions etc/pub2.rb
@@ -1,12 +1,12 @@
# Homebrew Formula for Pub2
# Homebrew Formula
# pub2 (c) Ian Dennis Miller
# based on https://github.com/Homebrew/brew/blob/master/docs/Python-for-Formula-Authors.md
# rebuild with 'make homebrew'

class Pub2 < Formula
desc "Pub2 is a self-publishing framework"
homepage "https://github.com/iandennismiller/pub2"
url "https://files.pythonhosted.org/packages/b7/d3/2e9657021c1fb0a9379a5105e83507b3460dec7d53ef9ed4a9734e467eec/pub2-0.1.2.tar.gz"
sha256 "601f96ae47716f2d23fdbc9455187b59bec70c9a26a2b13f830692624ac3b5d8"
url "https://files.pythonhosted.org/packages/a1/cc/cbe1f520a3ac1015bdc51cb5c24750dd64fb740eaa6e38165984fbf20489/pub2-0.1.5.tar.gz"
sha256 "f51e3db24c9e5693ef06993e9ff0b1375a67ec08bec256d6cf6ac1bb7a789bf3"

resource "click" do
url "https://files.pythonhosted.org/packages/7a/00/c14926d8232b36b08218067bcd5853caefb4737cda3f0a47437151344792/click-6.6.tar.gz"
Expand Down Expand Up @@ -53,6 +53,11 @@ class Pub2 < Formula
sha256 "0e2b62b497bd5f0afebc002eda4d90df9d209c30ef257e8673c90a6b5c119d62"
end

resource "Wand" do
url "https://files.pythonhosted.org/packages/bd/b2/a2276b912d641a196af3713772899b4a7af5114295ad0ebc44039014b2cc/Wand-0.4.3.tar.gz"
sha256 "576133476b1970313b4ab69460051dba2563ac125143bc109d6c796f77d9bd57"
end

include Language::Python::Virtualenv

def install
Expand Down

0 comments on commit 5c4a65c

Please sign in to comment.