Skip to content

Commit

Permalink
Merge pull request #22 from bjodah/more-sym
Browse files Browse the repository at this point in the history
Bump CI image, use sym
  • Loading branch information
bjodah authored Nov 3, 2016
2 parents f028076 + 0f58fde commit eb7dd6c
Show file tree
Hide file tree
Showing 18 changed files with 237 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .drone.sec
Original file line number Diff line number Diff line change
@@ -1 +1 @@
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkExMjhHQ00ifQ.RxcFQnm0aBsJCz8bgQj_zrSLCFgkvwrGGlRu8aUH2J74zDsuaXZIpnhEgtpMv6RX_kqudaofSMe_euEl-c24By4N4QE1me7UpnPDRkuLYmWl8xl2Klot0rqXKNhZO7A0KQVWdtuVNPH8MxZUwjY18VkhAa1jJLuvTKIEaxzF-1WUMFbmVnhgFGOzkQJXZQDax8RP1cF-t6B7fXFUBkphjRlfSG1dEGhSqtFOeLv-TJ2pCNBbNQrfDbYxd8yVtHABvbzezpaVBZhc5AEUleNv7s7bmn2yXD-BsVPWSEF5ksLekXEgKft-DsyiU2bF1d2aSoixgWZ-DTqubMy65VjhTQ.y03vzHCHgFhpsVFy.p3tAhOXZ3rfxWInB3ajy0z9XP7XH-r54tSH7OXvG_9COIt-a4Ej_hal3Pb0EMNCintIvgsn44cfE_V-4YIhmp8Dhv6u9ZwSAVC_7OKt4wG6GTX2FF_gN6KU-BhSfnoBtJrq0P3T4wr1Gu_3dvZN9quURLY-4wd8E-svXTBetfqfJgMjCKys0q2MRCf51OJyOio4OPP98UcWnzi27.HP0QWTXM5o_2lVZ8UDqPDw
eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkExMjhHQ00ifQ.AhUu4693LswxH_s88tvpvB2V2z0ql2NWLzlyb9aybs8LEip3FjeGedMMK3uYSb_SoakPIgOeBqsfWVeXyQV9wV8lV2yv_8F2gNx9ccDtzoXzfkakUA3rEelEkpE9MdI2_GOnn4J3Y0niNiAUZLBRgrp2vQa3xOUKyM1cKAmYO-T7B380LG_weB2KfiOqLiTItCwloSZGpQ6tzQ_-3ola5OKdK5tNPZF7lyXCTahuCEuQFFrJ9IcGjq9yuJ3qG0uRSV9Lp7y2Toyiua35wBt8ZLjFTiONOvlSqNpA9oMM6I1QRr6XOB2KFRMt0HQKYHnXMY3hdA67O51A4bMNTqhw6w.1RlrqyEuqdjcKg9_.pUYfpYMfGl0UpYmZ0UuXbjvthQs13RQ7cHiK_TbN6eyuR49snGr-8rVxKTOZpbZp9LLa-GIhYGTIKNOjtUvSCm_wJFlSSZoikt78FdOmgKRfSZAzlJ6IoOv6-9fEKd48C9_grap7m1Dssjb6Z36HW8XK5t6MValR4Bfk1gQF1X2tPwaU8aPL7gsZ0HUjqxdPobgwVI6TP-6eAliJpZg.ECsKZKJClxiqVbXfpeKwhw
9 changes: 3 additions & 6 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
build:
image: bjodah/bjodahimg:latest
image: bjodah/bjodahimg16:v1.2
environment:
- PYNLEQ2_NLEQ2_ROOT_URL=$$PYNLEQ2_NLEQ2_ROOT_URL
commands:
- python2.7 -m pip install --user pynleq2
- python3.4 -m pip install --user pynleq2
- (cd /; python2 -m pip install --user pynleq2)
- (cd /; python3 -m pip install --user pynleq2)
- export PYNLEQ2_NLEQ2_ROOT_URL=""
- ./scripts/ci.sh pyneqsys
- (cd examples/; ipython2 nbconvert --to=html --debug --ExecutePreprocessor.enabled=True --ExecutePreprocessor.timeout=300 *.ipynb)
- (cd examples/; ../scripts/render_index.sh *.html)
- ./scripts/generate_docs.sh
- ./scripts/prepare_deploy.sh

deploy:
Expand Down
Empty file added .gh-pages-skeleton/.nojekyll
Empty file.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
unreleased
==========
- Rely on ``sym`` package.

v0.4.2
======
- Support for chained solvers
Expand Down
36 changes: 25 additions & 11 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
{% set name = "pyneqsys" %}
{% set version = "0.5.0.git" %}

package:
name: pyneqsys
version: 0.4.0.git
name: {{ name|lower }}
version: {{ version }}

source:
path: ../
git_url: ../

build:
number: 0
script: python setup.py install --single-version-externally-managed --record record.txt

requirements:
build:
- python
- numpy
- setuptools
run:
- python
- numpy
- sympy
- scipy
- pyodesys
- sym
- sympy
- symcxx
- python-symengine
- pysym

test:
imports:
- pyneqsys
- {{ name }}
requires:
- nose
- pytest
commands:
- nosetests pyneqsys
- pytest --pyargs {{ name }}

about:
home: https://github.com/bjodah/pyneqsys
license: BSD
home: https://github.com/bjodah/{{ name }}
license: BSD 2-Clause
license_file: LICENSE
summary: 'Solve symbolically defined systems of non-linear equations numerically.'
doc_url: https://bjodah.github.io/{{ name }}/latest

extra:
recipe-maintainers:
- bjodah
8 changes: 4 additions & 4 deletions pyneqsys/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# -*- coding: utf-8 -*-
"""
Package for solving of symbolic systems of non-linear equations numerically.
Package for numerically solving symbolically defined systems of non-linear equations.
pyneqsys ties computer algebra systems like:
- SymPy
- symengine
- symcxx
- SymCXX
and numerical solvers such as:
- MINPACK in SciPy
- NLEQ2 in pynleq2
- KINSOL in pykinsol
in addition pyneqsys provides abstraction classes for e.g. having
conditional equations in a system.
together. In addition ``pyneqsys`` provides helper classes for
handling e.g. conditional equations in a system.
"""

from __future__ import absolute_import
Expand Down
2 changes: 1 addition & 1 deletion pyneqsys/_release.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.4.0.git'
__version__ = '0.5.0.git'
2 changes: 1 addition & 1 deletion pyneqsys/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy as np
from sym import Backend
from pyodesys.util import banded_jacobian, check_transforms
from sym.util import banded_jacobian, check_transforms

from .core import NeqSys, _ensure_3args

Expand Down
9 changes: 9 additions & 0 deletions scripts/check_clean_repo_on_master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,12 @@ if [[ ! -z $(git status -s) ]]; then
echo "'git status' show there are some untracked/uncommited changes. Aborting..."
exit 1
fi
if grep -e "^v" CHANGES.rst >/dev/null; then
if ! grep -e "^$1" CHANGES.rst >/dev/null; then
>&2 echo "CHANGES.rst does not contain an entry for: $1"
exit 1
fi
else
>&2 echo "CHANGES.rst does not start with v*"
exit 1
fi
27 changes: 14 additions & 13 deletions scripts/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ if [[ "$CI_BRANCH" =~ ^v[0-9]+.[0-9]?* ]]; then
eval export ${PKG_NAME^^}_RELEASE_VERSION=\$CI_BRANCH
echo ${CI_BRANCH} | tail -c +2 > __conda_version__.txt
fi
for PY in python2.7 python3.4; do
$PY -m pip install https://github.com/bjodah/sym/archive/master.zip # until sym > 0.1.2
$PY -m pip install --upgrade sympy==1.0
done
python2.7 setup.py sdist
(cd dist/; python2.7 -m pip install $PKG_NAME-$(python ../setup.py --version).tar.gz)
(cd dist/; python3.4 -m pip install $PKG_NAME-$(python ../setup.py --version).tar.gz)
(cd /; python2.7 -m pytest --pyargs $PKG_NAME)
(cd /; python3.4 -m pytest --pyargs $PKG_NAME)
python2.7 -m pip install --user -e .[all] pysym pykinsol git+https://github.com/bjodah/cyipopt.git
python3.4 -m pip install --user -e .[all] pysym pykinsol git+https://github.com/bjodah/cyipopt.git
PYTHONPATH=$(pwd) PYTHON=python2.7 ./scripts/run_tests.sh
PYTHONPATH=$(pwd) PYTHON=python3.4 ./scripts/run_tests.sh --cov $PKG_NAME --cov-report html
git archive -o /tmp/$PKG_NAME.zip HEAD # test pip installable zip (symlinks break)
python3 -m pip install /tmp/$PKG_NAME.zip

python2 setup.py sdist # test pip installable sdist (checks MANIFEST.in)
(cd dist/; python2 -m pip install $PKG_NAME-$(python2 ../setup.py --version).tar.gz)
(cd /; python2 -m pytest --pyargs $PKG_NAME)

python2 -m pip install --user -e .[all] pysym pykinsol git+https://github.com/bjodah/cyipopt.git
python3 -m pip install --user -e .[all] pysym pykinsol git+https://github.com/bjodah/cyipopt.git
PYTHONPATH=$(pwd) PYTHON=python2 ./scripts/run_tests.sh
PYTHONPATH=$(pwd) PYTHON=python3 ./scripts/run_tests.sh --cov $PKG_NAME --cov-report html
./scripts/coverage_badge.py htmlcov/ htmlcov/coverage.svg
! grep "DO-NOT-MERGE!" -R . --exclude ci.sh

./scripts/render_notebooks.sh
./scripts/generate_docs.sh
12 changes: 9 additions & 3 deletions scripts/generate_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@
NARGS=$#
PKG=$(find . -maxdepth 2 -name __init__.py -print0 | xargs -0 -n1 dirname | xargs basename)
AUTHOR=$(head -n 1 AUTHORS)
sphinx-apidoc --full --force -A "$AUTHOR" --module-first --doc-version=$(python setup.py --version) -F -o doc $PKG/ $PKG/tests/
sphinx-apidoc --full --force -A "$AUTHOR" --module-first --doc-version=$(python setup.py --version) -F -o doc $PKG/ $(find . -type d -name tests)
sed -i "s/chempy's/ChemPy's/g" doc/index.rst
#sed -i 's/Contents/.. include:: ..\/README.rst\n\nContents/g' doc/index.rst
echo ".. include:: ../README.rst" >>doc/index.rst
sed -i "s/'sphinx.ext.viewcode',/'sphinx.ext.viewcode',\n 'sphinx.ext.autosummary',\n 'numpydoc',/g" doc/conf.py
#echo ".. include:: ../README.rst" >>doc/index.rst
cat <<EOF >>doc/index.rst
Overview
========
$(tail -n+3 README.rst)
EOF
sed -i "s/'sphinx.ext.viewcode',/'sphinx.ext.viewcode',\n 'sphinx.ext.autosummary',\n 'sphinx.ext.mathjax',\n 'numpydoc',/g" doc/conf.py
sed -i "s/alabaster/sphinx_rtd_theme/g" doc/conf.py
if [[ $NARGS -eq 3 ]]; then
cat <<EOF>>doc/conf.py
Expand Down
25 changes: 19 additions & 6 deletions scripts/post_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,28 @@ SERVER=$2
GITHUBUSER=$3
PKG=$(find . -maxdepth 2 -name __init__.py -print0 | xargs -0 -n1 dirname | xargs basename)
PKG_UPPER=$(echo $PKG | tr '[:lower:]' '[:upper:]')
MD5=$(md5sum dist/${PKG}-$VERSION.tar.gz | cut -f1 -d' ')
SDIST_FILE=dist/${PKG}-$VERSION.tar.gz
if [[ ! -f "$SDIST_FILE" ]]; then
>&2 echo "Nonexistent file $SDIST_FILE"
exit 1
fi
SHA256=$(openssl sha256 "$SDIST_FILE" | cut -f2 -d' ')
if [[ -d "dist/conda-recipe-$VERSION" ]]; then
rm -r "dist/conda-recipe-$VERSION"
fi
cp -r conda-recipe/ dist/conda-recipe-$VERSION
sed -i -E -e "s/version:(.+)/version: $VERSION/" -e "s/path:(.+)/fn: $PKG-$VERSION.tar.gz\n url: https:\/\/github.com\/$GITHUBUSER\/$PKG\/releases\/download\/v$VERSION\/$PKG-$VERSION.tar.gz\n md5: $MD5/" dist/conda-recipe-$VERSION/meta.yaml

env ${PKG_UPPER}_RELEASE_VERSION=v$VERSION python setup.py upload_sphinx
sed -i -E \
-e "s/\{\% set version(.+)/\{\% set version = \"$VERSION\" \%\}\n\{\% set sha256 = \"$SHA256\" \%\}/" \
-e "s/git_url:(.+)/fn: \{\{ name \}\}-\{\{ version \}\}.tar.gz\n url: https:\/\/pypi.io\/packages\/source\/\{\{ name\[0\] \}\}\/\{\{ name \}\}\/\{\{ name \}\}-\{\{ version \}\}.tar.gz\n sha256: \{\{ sha256 \}\}/" \
dist/conda-recipe-$VERSION/meta.yaml

./scripts/update-gh-pages.sh v$VERSION

# Specific for this project:
scp -r dist/conda-recipe-$VERSION/ $PKG@$SERVER:~/public_html/conda-recipes/
scp dist/${PKG}-$VERSION.tar.gz $PKG@$SERVER:~/public_html/releases/
scp "$SDIST_FILE" "$PKG@$SERVER:~/public_html/releases/"
for CONDA_PY in 2.7 3.4 3.5; do
ssh $PKG@$SERVER "source /etc/profile; conda-build --python $CONDA_PY ~/public_html/conda-recipes/conda-recipe-$VERSION/"
for CONDA_NPY in 1.11; do
ssh $PKG@$SERVER "source /etc/profile; conda-build --python $CONDA_PY --numpy $CONDA_NPY ~/public_html/conda-recipes/conda-recipe-$VERSION/"
done
done
43 changes: 29 additions & 14 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,51 @@
#!/bin/bash -xe
#!/bin/bash -xeu
# Usage:
#
# $ ./scripts/release.sh v1.2.3 ~/anaconda2/bin
# $ ./scripts/release.sh v1.2.3 ~/anaconda2/bin upstream
# $ ./scripts/release.sh v1.2.3 ~/anaconda2/bin myserver.example.com GITHUB_USER GITHUB_REPO
#

if [[ $1 != v* ]]; then
echo "Argument does not start with 'v'"
exit 1
fi
if [[ $# == 3 ]]; then
REMOTE=origin
else
REMOTE=$4
fi
VERSION=${1#v}
CONDA_PATH=$2
SERVER=$3
find . -type f -iname "*.pyc" -exec rm {} +
find . -type f -iname "*.o" -exec rm {} +
find . -type f -iname "*.so" -exec rm {} +
find . -type d -name "__pycache__" -exec rmdir {} +
./scripts/check_clean_repo_on_master.sh
cd $(dirname $0)/..
# PKG will be name of the directory one level up containing "__init__.py"
PKG=$(find . -maxdepth 2 -name __init__.py -print0 | xargs -0 -n1 dirname | xargs basename)
! grep --include "*.py" "will_be_missing_in='$VERSION'" -R $PKG/ # see deprecation()
PKG_UPPER=$(echo $PKG | tr '[:lower:]' '[:upper:]')
./scripts/run_tests.sh
env ${PKG_UPPER}_RELEASE_VERSION=v$VERSION python setup.py sdist
env ${PKG_UPPER}_RELEASE_VERSION=v$VERSION ./scripts/generate_docs.sh
if [[ -e ./scripts/generate_docs.sh ]]; then
env ${PKG_UPPER}_RELEASE_VERSION=v$VERSION ./scripts/generate_docs.sh # $4 ${5:-$PKG} v$VERSION
fi
for CONDA_PY in 2.7 3.4 3.5; do
PATH=$2:$PATH ./scripts/build_conda_recipe.sh v$VERSION --python $CONDA_PY
for CONDA_NPY in 1.11; do
continue # we build the conda recipe on another host for now..
PATH=$CONDA_PATH:$PATH ./scripts/build_conda_recipe.sh v$VERSION --python $CONDA_PY --numpy $CONDA_NPY
done
done

# All went well
# All went well, add a tag and push it.
git tag -a v$VERSION -m v$VERSION
git push $REMOTE
git push $REMOTE --tags
git push
git push --tags
twine upload dist/${PKG}-$VERSION.tar.gz

echo "Create a new release on github (with custom .tar.gz), then run ./scripts/post_release.sh ..."
set +x
echo ""
echo " You may now create a new github release at with the tag \"v$VERSION\", here is a link:"
echo " https://github.com/$4/${5:-$PKG}/releases/new "
echo " name the release \"${PKG}-${VERSION}\", and don't foreget to manually attach the file:"
echo " $(openssl sha256 $(pwd)/dist/${PKG}-${VERSION}.tar.gz)"
echo " Then run:"
echo ""
echo " $ ./scripts/post_release.sh $1 $SERVER $4"
echo ""
4 changes: 2 additions & 2 deletions scripts/render_index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ for f in $@; do
continue # don't include notebooks starting with underscore
fi
img=$(basename $f .html).png
phantomjs $(unset CDPATH && cd "$(dirname "$0")" && echo $PWD)/rasterize.js $f $tmpdir/$img 1200px*900px
QT_QPA_PLATFORM=offscreen phantomjs $(unset CDPATH && cd "$(dirname "$0")" && echo $PWD)/rasterize.js $f $tmpdir/$img 1200px*900px
convert $tmpdir/$img -resize 400x300 thumbs/$img
cat <<EOF>>index.html
<p style='text-align: center'>
<a href='$f' style='ffont-ont-family: sans-serif'>
<a href='$f' style='font-family: sans-serif'>
<img src='thumbs/$img'><br>
$f
</a></p>
Expand Down
4 changes: 4 additions & 0 deletions scripts/render_notebooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash -e
cd examples/
jupyter nbconvert --debug --to=html --ExecutePreprocessor.enabled=True --ExecutePreprocessor.timeout=300 *.ipynb
../scripts/render_index.sh *.html
72 changes: 72 additions & 0 deletions scripts/update-gh-pages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash -x
#
# Usage:
#
# $ ./scripts/update-gh-pages.sh v0.6.0 origin
#

tag=${1:-master}
remote=${2:-origin}

ori_branch=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)
tmpdir=$(mktemp -d)
cleanup() {
rm -r $tmpdir
}
trap cleanup INT TERM

cp -r doc/_build/html/ $tmpdir
git ls-files --others | tar cf $tmpdir/untracked.tar -T -
if [[ -d .gh-pages-skeleton ]]; then
cp -r .gh-pages-skeleton $tmpdir
fi

git checkout gh-pages
if [[ $? -ne 0 ]]; then
git checkout --orphan gh-pages
if [[ $? -ne 0 ]]; then
>&2 echo "Failed to switch to 'gh-pages' branch."
cleanup
exit 1
fi
preexisting=0
else
preexisting=1
fi

if [[ $preexisting == 1 ]]; then
while [[ "$(git log -1 --pretty=%B)" == Volatile* ]]; do
# overwrite previous docs
git reset --hard HEAD~1
done
fi

shopt -s extglob
git clean -xfd
if [[ $preexisting == 1 ]]; then
git rm -rf !(v*) > /dev/null
fi
cp -r $tmpdir/html/ $tag
if [[ -d $tmpdir/.gh-pages-skeleton ]]; then
cp -r $tmpdir/.gh-pages-skeleton/. .
fi
if [[ "$tag" == v* ]]; then
ln -s $tag latest
commit_msg="Release docs for $tag"
else
if [[ $preexisting == 1 ]]; then
commit_msg="Volatile ($tag) docs"
else
commit_msg="Initial commit"
fi
fi
git add -f . >/dev/null
git commit -m "$commit_msg"
if [[ $preexisting == 1 ]]; then
git push -f $remote gh-pages
else
git push --set-upstream $remote gh-pages
fi
git checkout $ori_branch
tar xf $tmpdir/untracked.tar
cleanup
Loading

0 comments on commit eb7dd6c

Please sign in to comment.