windows support

debug-parimap-hang
Sebastian Heimann 2 years ago
parent befb5a64ec
commit fa28a350e0

@ -360,6 +360,116 @@ steps:
---
kind: pipeline
type: exec
name: tests-windows
platform:
os: windows
steps:
- name: install
commands:
- xcopy C:\\vagrant\\test-data\\data test\\data\\ /E
- xcopy C:\\vagrant\\test-data\\example_run_dir test\\example_run_dir\\ /E
- Remove-Item -Recurse -Force -ErrorAction Ignore C:\\Users\\vagrant\\miniconda3\\Lib\\site-packages\\pyrocko
- python setup.py install
- name: tests-base
commands:
- python maintenance/run_tests_windows.py test.base
depends_on:
- install
- name: tests-gf
commands:
- python maintenance/run_tests_windows.py test.gf
depends_on:
- install
- name: tests-examples
commands:
- python maintenance/run_tests_windows.py test.examples
depends_on:
- install
- name: tests-gui
commands:
- python maintenance/run_tests_windows.py test.gui
depends_on:
- install
- name: finalize
commands: []
depends_on:
- tests-base
- tests-gf
- tests-examples
- tests-gui
---
kind: pipeline
type: exec
name: pip-windows
trigger:
branch:
- release
- candidate
- pip
platform:
os: windows
steps:
- name: build
commands:
- Remove-Item -Recurse -Force -ErrorAction Ignore C:\\Users\\vagrant\\miniconda3\\Lib\\site-packages\\pyrocko
- conda create -y -n py36 python=3.6 m2-patch setuptools numpy=1.14
- conda run -n py36 python setup.py install
- conda run -n py36 python setup.py bdist_wheel
- conda create -y -n py37 python=3.7 m2-patch setuptools numpy=1.14
- conda run -n py37 python setup.py install
- conda run -n py37 python setup.py bdist_wheel
- conda create -y -n py38 python=3.8 m2-patch setuptools numpy=1.14
- conda run -n py38 python setup.py install
- conda run -n py38 python setup.py bdist_wheel
- conda create -y -n py39 python=3.9 m2-patch setuptools numpy=1.16
- conda run -n py39 python setup.py install
- conda run -n py39 python setup.py bdist_wheel
- name: upload-testing
when:
branch:
- candidate
- pip
commands:
- pip install twine
- bash maintenance/pip/upload_wheels_windows.sh testing
environment:
PYPI_USERNAME:
from_secret: pypi-username
PYPI_PASSWORD:
from_secret: pypi-password
- name: upload
when:
branch:
- release
commands:
- bash maintenance/pip/upload_wheels_windows.sh live
environment:
PYPI_USERNAME:
from_secret: pypi-username
PYPI_PASSWORD:
from_secret: pypi-password
---
kind: pipeline
type: docker
name: coverage
@ -480,6 +590,48 @@ steps:
---
kind: pipeline
type: exec
name: conda-packages-windows
trigger:
branch:
- candidate
- release
- conda
platform:
os: windows
steps:
- name: build-test
commands:
- cd maintenance\\conda\\
- conda run -n base bash build_packages_windows.sh dryrun
when:
branch:
- candidate
- conda
- name: build-test-upload
commands:
- cd maintenance\\conda\\
- conda run -n base bash build_packages_windows.sh upload
environment:
CONDA_USERNAME:
from_secret: conda-username
CONDA_PASSWORD:
from_secret: conda-password
when:
branch:
- release
- name: cleanup
commands:
- Remove-Item -Recurse -Force -ErrorAction Ignore C:\\Windows\\Temp\\pyrocko*
---
kind: pipeline
type: docker
name: notify-hive

@ -1,5 +1,5 @@
fail_fast: true
files: ^(src|test)/
files: ^(src/|test/|examples/|setup.py)
repos:
- repo: local
hooks:
@ -7,5 +7,5 @@ repos:
name: flake8
entry: flake8
language: system
files: ^src/
files: ^(src/|test/|examples/|setup.py)
types: [python]

@ -1,5 +0,0 @@
---
linters:
flake8:
python: 3

@ -1,93 +0,0 @@
language: python
cache:
pip: true
directories:
- $TRAVIS_BUILD_DIR/pyrocko/test/data
env:
global:
- OMP_NUM_THREADS=2
matrix:
include:
- os: linux
python: 2.7
virtualenv:
system_site_packages: true
dist: precise
# - os: osx
# osx_image: xcode7.3
# language: generic
# allow_failures:
# - os: osx
#
addons:
apt:
packages: [ python-qt4, python-qt4-gl, python-qt4-dev, python-dev,
gfortran, libatlas-dev, libopenblas-dev,
python-yaml, python-tk, libyaml-dev,
poppler-utils, ghostscript, imagemagick, xvfb,
libssl1.0.0 ]
before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew tap homebrew/science; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew tap homebrew/python; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew unlink libyaml; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gcc libyaml; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then pip install matplotlib; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then xcode-select --install || true ; fi
- pip install --upgrade pip setuptools wheel
- pip install --only-binary=numpy,scipy,matplotlib scipy numpy matplotlib
- pip install progressbar setuptools flake8 pyyaml coveralls jinja2 future coverage nose
- git clone https://github.com/pyrocko/fomosto-qseis
- cd fomosto-qseis; autoreconf -i; ./configure; make; export PATH=$PATH:`pwd`/src; cd ..
- git clone https://github.com/pyrocko/fomosto-qseis2d
- cd fomosto-qseis2d; autoreconf -i; ./configure; make; export PATH=$PATH:`pwd`/src/r:`pwd`/src/s; cd ..
- git clone https://github.com/pyrocko/fomosto-psgrn-pscmp
- cd fomosto-psgrn-pscmp; autoreconf -i; ./configure; make; export PATH=$PATH:`pwd`/src/psgrn:`pwd`/src/pscmp; cd ..
- git clone https://github.com/pyrocko/fomosto-qssp.git
- cd fomosto-qssp; autoreconf -i; ./configure; make; export PATH=$PATH:`pwd`/src; cd ..
before_script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then flake8 src/ test/ ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export DISPLAY=:99.0 ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sh -e /etc/init.d/xvfb start ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sleep 3 ; fi
install:
- pip install .
script:
- travis_wait nosetests run --with-coverage --cover-package=pyrocko test/
after_success:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then coveralls; fi
deploy:
- provider: pypi
user: pyrocko
password:
secure: "crUt0q8F1oSgG5nzfpjd8bmBtHpVWXZE/qYVRlniux4X7tkO6GnW1rZpE2iBJxjEd3ADmgGZwFKj5215HHOZlcxFVQ/w8BnpI9WCkEaph0kA1I+aIrZg+fzpyEcskQ5Nzg1YQIcN/5wVEwmSZtK55gZyFccZMjqZQTkMJiJHZUGT1SyMYlFtoZ508lXtRxhC1EqhBSUa67KIaZoyA1BTgNEFzRNHCqquyb0dalbaiMfpl3UVxzPkik+L9yIUUc/xKC5NRWwAJY6xT7Qf+lvTC1MTSaNva0TG4PpZ5Zfr/N9HuJXXNTToRAd39tSSypt6TeIvOKA7caD6QNWzioQwA86mjskR1GgRTYo1yEAJApBbHtRWvZvp0noSTYcRtb4XDWc5J1L0vxRsvmPmrSUNLmYDrPz++G2HO+ZrJhjuCme8d6RRMpj5/k2TAnpx0PnjoLLnb9QLoe/U26CbmCQDTLSiXcC0g6jo3Wxyx37truWuG2M2Sh1vmV2qnJVi12FkOg6vJhtvIMvLU1M1kPCiAVcIGO9x4IU+tU/vV5LoNuuqEZT+fRJBtqbMH3LpRMRsMrB/ZRCJ2XnJIsRvkd6ibWYQkmk2L37R8OnNc7y7mI9N4iR158KPmcSL5Ft7LtV+J+42uAgWSolHlpvksBp3ZzIOMfofSRysr7vWmtqCK2U="
on:
all_branches: true
# branch: master
# tags: true
distributions: "sdist bdist_wheel"
server: https://test.pypi.org/legacy/
- provider: script
script: maintenance/anaconda_deploy.sh
on:
all_branches: true
# branch: master
# tags: true
notifications:
email: false

@ -2,6 +2,7 @@ recursive-include prerequisites *
recursive-include extras *
recursive-include src *.md
recursive-include src/ext/pyavl-1.12 *
recursive-include maintenance *.rst
include *.md *.tar.gz *.cfg
include maintenance/readme-pip.rst
include *.md *.tar.gz *.cfg *.patch
global-exclude *.py[cod] __pycache__

@ -1,5 +0,0 @@
FROM debian:stable
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get install -y rsync git python3-pip xvfb libgles2-mesa libfontconfig1 libxrender1 libxkbcommon-x11-0 python3-requests

@ -1,5 +1,5 @@
#!/bin/bash
docker build nest -t pyrocko-nest
docker build docs -t pyrocko-docs
docker build aux -t pyrocko-aux
docker build util -t pyrocko-util
docker build pyrocko -t pyrocko

@ -5,7 +5,7 @@ from pyrocko.gf import meta
# Define a list of phases.
phase_defs = [meta.TPDef(id='stored:p', definition='p'),
phase_defs = [meta.TPDef(id='stored:depth_p', definition='p'),
meta.TPDef(id='stored:P', definition='P')]
# Load a velocity model. In this example use the default AK135.
@ -70,7 +70,7 @@ for phase_def in phase_defs:
sptree.dump(filename='sptree_%s.yaml' % phase_def.id.split(':')[1])
# Define a :py:class:`pyrocko.gf.meta.Timing` instance.
timing = meta.Timing('first(p|P)')
timing = meta.Timing('first(depth_p|P)')
# If only one interpolated onset is need at a time you can retrieve
@ -96,7 +96,7 @@ coords = num.array((x_want, num.tile(z_want, x_want.shape))).T
# *interpolate_many* then interpolates onset times for each of these
# pairs.
tts = interpolated_tts["stored:p"].interpolate_many(coords)
tts = interpolated_tts["stored:depth_p"].interpolate_many(coords)
# Plot distance vs. onset time
plt.plot(x_want, tts, '.')

@ -0,0 +1,182 @@
diff -ruN libmseed/libmseed.h libmseed_mod/libmseed.h
--- libmseed/libmseed.h 2019-06-19 10:59:29.000000000 +0200
+++ libmseed_mod/libmseed.h 2021-04-09 09:44:41.881346528 +0200
@@ -511,6 +511,7 @@
double samprate; /* Nominal sample rate (Hz) */
int64_t samplecnt; /* Number of samples in trace coverage */
void *datasamples; /* Data samples, 'numsamples' of type 'sampletype' */
+ size_t bufsize;
int64_t numsamples; /* Number of data samples in datasamples */
char sampletype; /* Sample type code: a, i, f, d */
void *prvtptr; /* Private pointer for general use, unused by libmseed */
diff -ruN libmseed/Makefile.win libmseed_mod/Makefile.win
--- libmseed/Makefile.win 2019-06-19 10:59:29.000000000 +0200
+++ libmseed_mod/Makefile.win 2021-04-09 09:44:41.881346528 +0200
@@ -5,9 +5,10 @@
NODEBUG=1
INCS = -I.
-OPTS = -D_CRT_SECURE_NO_WARNINGS
+OPTS = -D_CRT_SECURE_NO_WARNINGS -DWIN32
LIB = libmseed.lib
DLL = libmseed.dll
+CFLAGS = /Ox
OBJS= fileutils.obj \
genutils.obj \
diff -ruN libmseed/traceutils.c libmseed_mod/traceutils.c
--- libmseed/traceutils.c 2019-06-19 10:59:29.000000000 +0200
+++ libmseed_mod/traceutils.c 2021-04-09 09:44:41.881346528 +0200
@@ -437,6 +437,7 @@
mst_addmsr (MSTrace *mst, MSRecord *msr, flag whence)
{
int samplesize = 0;
+ size_t min_size;
if (!mst || !msr)
return -1;
@@ -465,13 +466,16 @@
return -1;
}
- mst->datasamples = realloc (mst->datasamples,
- (size_t) (mst->numsamples * samplesize + msr->numsamples * samplesize));
+ min_size = (size_t) (mst->numsamples * samplesize + msr->numsamples * samplesize);
- if (mst->datasamples == NULL)
- {
- ms_log (2, "mst_addmsr(): Cannot allocate memory\n");
- return -1;
+ if (min_size > mst->bufsize) {
+ mst->datasamples = realloc (mst->datasamples, min_size*2);
+ if (mst->datasamples == NULL)
+ {
+ ms_log (2, "mst_addmsr(): Cannot allocate memory\n");
+ return -1;
+ }
+ mst->bufsize = min_size*2;
}
}
@@ -548,6 +552,7 @@
flag whence)
{
int samplesize = 0;
+ size_t min_size;
if (!mst)
return -1;
@@ -568,13 +573,15 @@
return -1;
}
- mst->datasamples = realloc (mst->datasamples,
- (size_t) (mst->numsamples * samplesize + numsamples * samplesize));
-
- if (mst->datasamples == NULL)
- {
- ms_log (2, "mst_addspan(): Cannot allocate memory\n");
- return -1;
+ min_size = (size_t) (mst->numsamples * samplesize + numsamples * samplesize);
+ if (min_size > mst->bufsize) {
+ mst->datasamples = realloc (mst->datasamples, min_size*2);
+ if (mst->datasamples == NULL)
+ {
+ ms_log (2, "mst_addspan(): Cannot allocate memory\n");
+ return -1;
+ }
+ mst->bufsize = min_size*2;
}
}
@@ -1108,6 +1115,7 @@
float *fdata;
double *ddata;
int64_t idx;
+ size_t bufsize;
if (!mst)
return -1;
@@ -1160,11 +1168,13 @@
}
/* Reallocate buffer for reduced size needed */
- if (!(mst->datasamples = realloc (mst->datasamples, (size_t) (mst->numsamples * sizeof (int32_t)))))
+ bufsize = (size_t) (mst->numsamples * sizeof (int32_t));
+ if (!(mst->datasamples = realloc (mst->datasamples, bufsize)))
{
ms_log (2, "mst_convertsamples: cannot re-allocate buffer for sample conversion\n");
return -1;
}
+ mst->bufsize = bufsize;
}
mst->sampletype = 'i';
@@ -1184,11 +1194,13 @@
fdata[idx] = (float)ddata[idx];
/* Reallocate buffer for reduced size needed */
- if (!(mst->datasamples = realloc (mst->datasamples, (size_t) (mst->numsamples * sizeof (float)))))
+ bufsize = (size_t) (mst->numsamples * sizeof (float));
+ if (!(mst->datasamples = realloc (mst->datasamples, bufsize)))
{
ms_log (2, "mst_convertsamples: cannot re-allocate buffer after sample conversion\n");
return -1;
}
+ mst->bufsize = bufsize;
}
mst->sampletype = 'f';
@@ -1197,7 +1209,8 @@
/* Convert to 64-bit doubles */
else if (type == 'd')
{
- if (!(ddata = (double *)malloc ((size_t) (mst->numsamples * sizeof (double)))))
+ bufsize = (size_t) (mst->numsamples * sizeof (double));
+ if (!(ddata = (double *)malloc (bufsize)))
{
ms_log (2, "mst_convertsamples: cannot allocate buffer for sample conversion to doubles\n");
return -1;
@@ -1219,6 +1232,7 @@
}
mst->datasamples = ddata;
+ mst->bufsize = bufsize;
mst->sampletype = 'd';
} /* Done converting to 64-bit doubles */
@@ -1659,7 +1673,7 @@
int trpackedrecords = 0;
int64_t trpackedsamples = 0;
int samplesize;
- int64_t bufsize;
+ size_t bufsize;
hptime_t preservestarttime = 0;
double preservesamprate = 0.0;
@@ -1745,21 +1759,22 @@
mst->starttime = msr->starttime;
samplesize = ms_samplesize (mst->sampletype);
- bufsize = (mst->numsamples - trpackedsamples) * samplesize;
+ bufsize = (size_t) (mst->numsamples - trpackedsamples) * samplesize;
if (bufsize)
{
memmove (mst->datasamples,
(char *)mst->datasamples + (trpackedsamples * samplesize),
- (size_t)bufsize);
+ bufsize);
- mst->datasamples = realloc (mst->datasamples, (size_t)bufsize);
+ mst->datasamples = realloc (mst->datasamples, bufsize);
if (mst->datasamples == NULL)
{
ms_log (2, "mst_pack(): Cannot (re)allocate datasamples buffer\n");
return -1;
}
+ mst->bufsize = bufsize;
}
else
{

@ -5,6 +5,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "3072"]
end
config.vm.network :private_network, ip: '192.168.115.111'
config.vm.network :forwarded_port, guest: 22, host: 22111, id: 'ssh'
#config.vm.network :private_network, ip: '192.168.115.111'
#config.vm.network :forwarded_port, guest: 22, host: 22111, id: 'ssh'
end

@ -8,7 +8,7 @@ action="$2"
pyrockodir="pyrocko"
cd $HOME
sudo yum -y install git gcc
sudo yum -y install git gcc patch
if [ -e "$pyrockodir" ] ; then
sudo rm -rf "$pyrockodir"

@ -2,14 +2,12 @@
set -e
vagrant halt
running=`vagrant global-status | grep running | grep conda/boxes/centos-7` || /bin/true
if [ ! -z "$running" ]; then
echo "vagrant box already running:" $running
exit 1
fi
#running=`vagrant global-status | grep running | grep conda/boxes/centos-7` || /bin/true
#
#if [ ! -z "$running" ]; then
# echo "vagrant box already running:" $running
# exit 1
#fi
if [ ! -z "$(git status --untracked-files=no --porcelain)" ]; then
echo "repos not clean"
@ -46,4 +44,5 @@ set -e
rm env.sh
vagrant halt
vagrant destroy -f
exit $STATE

@ -5,8 +5,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "3072"]
end
config.vm.network :private_network, ip: '192.168.115.112'
config.vm.network :forwarded_port, guest: 22, host: 22112, id: 'ssh'
#config.vm.network :private_network, ip: '192.168.115.112'
#config.vm.network :forwarded_port, guest: 22, host: 22112, id: 'ssh'
config.vm.synced_folder ".", "/vagrant",
type: "rsync",
rsync__chown: false

@ -2,14 +2,12 @@
set -e
vagrant halt
running=`vagrant global-status | grep running | grep conda/boxes/osx` || /bin/true
if [ ! -z "$running" ]; then
echo "vagrant box already running:" $running
exit 1
fi
#running=`vagrant global-status | grep running | grep conda/boxes/osx` || /bin/true
#
#if [ ! -z "$running" ]; then
# echo "vagrant box already running:" $running
# exit 1
#fi
if [ ! -z "$(git status --untracked-files=no --porcelain)" ]; then
echo "repos not clean"
@ -46,4 +44,5 @@ set -e
rm env.sh
vagrant halt
vagrant destroy -f
exit $STATE

@ -1,2 +0,0 @@
# This file is to be called by the conda build process
$PYTHON setup.py install

@ -1,17 +1,20 @@
{% set data = load_setup_py_data() %}
{% set data = load_setup_py_data(setup_file='../../../setup.py', from_recipe_dir=True) %}
package:
name: pyrocko
version: {{ data.get('version') }}
source:
path: pyrocko.git/
path: ../../..
requirements:
build:
- python
- {{ compiler('c') }}
- numpy
- setuptools
- m2-patch # [win]
- m2-bash # [win]
host:
- python
- numpy
@ -27,6 +30,9 @@ requirements:
- jinja2
- nose
build:
script: {{PYTHON}} setup.py install
test:
source_files:
- test
@ -35,7 +41,7 @@ test:
imports:
- pyrocko
commands:
- nosetests --verbosity=2 --detailed-errors test.base.test_util
- python -m nose --verbosity=2 --detailed-errors test.base.test_util
about:
home: https://pyrocko.org

@ -30,66 +30,54 @@ fi
ORIGPATH="$PATH"
for VERSION in 3 2 ; do
CONDA_URL="https://repo.anaconda.com/miniconda"
CONDA_PREFIX="$HOME/miniconda3"
CONDA_INSTALLER="miniconda3.sh"
CONDA_URL="https://repo.anaconda.com/miniconda"
HERE=`pwd`
CONDA_PREFIX="$HERE/miniconda${VERSION}"
CONDA_INSTALLER="miniconda${VERSION}.sh"
export PATH="$CONDA_PREFIX/bin:$ORIGPATH"
export PATH="$CONDA_PREFIX/bin:$ORIGPATH"
if [ `uname` == "Darwin" ]; then
CONDA_FILE="Miniconda${VERSION}-latest-MacOSX-x86_64.sh"
else
CONDA_FILE="Miniconda${VERSION}-latest-Linux-x86_64.sh"
fi
# Install Miniconda
if [ `uname` == "Darwin" ]; then
CONDA_FILE="Miniconda3-latest-MacOSX-x86_64.sh"
else
CONDA_FILE="Miniconda3-latest-Linux-x86_64.sh"
fi
if [ ! -f "$CONDA_INSTALLER" ] ; then
echo "getting conda from:" "$CONDA_URL/$CONDA_FILE"
curl "$CONDA_URL/$CONDA_FILE" -o "$CONDA_INSTALLER"
chmod +x "$CONDA_INSTALLER"
rm -rf "$CONDA_PREFIX"
fi
# Install Miniconda
if [ ! -d "$CONDA_PREFIX" ] ; then
"./$CONDA_INSTALLER" -b -u -p "$CONDA_PREFIX"
conda install -y conda-build conda-verify anaconda-client numpy
fi
HERE=`pwd`
cd "$HOME"
if [ -d "build/pyrocko.git" ] ; then
rm -rf "build/pyrocko.git"
fi
if [ ! -f "$CONDA_INSTALLER" ] ; then
echo "getting conda from:" "$CONDA_URL/$CONDA_FILE"
curl "$CONDA_URL/$CONDA_FILE" -o "$CONDA_INSTALLER"
chmod +x "$CONDA_INSTALLER"
rm -rf "$CONDA_PREFIX"
fi
git clone -b $BRANCH "../.." "build/pyrocko.git"
rm -rf build/pyrocko.git/.git
rm -rf build/pyrocko.git/maintenance/conda
if [ "$ACTION" == "upload" ] ; then
anaconda login --username "$CONDA_USERNAME" --password "$CONDA_PASSWORD" --hostname conda-builder-`uname`
conda config --set anaconda_upload yes
function anaconda_logout {
anaconda logout
}
trap anaconda_logout EXIT
else
conda config --set anaconda_upload no
fi
if [ ! -d "$CONDA_PREFIX" ] ; then
"./$CONDA_INSTALLER" -b -u -p "$CONDA_PREFIX"
conda install -y conda-build conda-verify anaconda-client numpy
fi
if [ "$VERSION" == "3" ] ; then
conda-build --python 3.6 build
conda-build --python 3.7 build
conda-build --python 3.8 build
fi
cd "$HERE"
if [ "$ACTION" == "upload" ] ; then
anaconda login --username "$CONDA_USERNAME" --password "$CONDA_PASSWORD" --hostname conda-builder-`uname`
conda config --set anaconda_upload yes
function anaconda_logout {
anaconda logout
}
trap anaconda_logout EXIT
else
conda config --set anaconda_upload no
fi
if [ "$VERSION" == "2" ] ; then
conda-build build
fi
conda-build --python 3.6 build
conda-build --python 3.7 build
conda-build --python 3.8 build
conda-build --python 3.9 build
if [ "$ACTION" == "upload" ] ; then
trap - EXIT
anaconda_logout
fi
done
if [ "$ACTION" == "upload" ] ; then
trap - EXIT
anaconda_logout
fi

@ -0,0 +1,46 @@
#!/bin/bash
set -e
if [ ! -f "build_packages_windows.sh" ] ; then
echo 'must be run from inside maintenance/conda'
exit 1
fi
ACTION="$1"
if [ -z "$ACTION" ] ; then
echo "usage: build_packages.sh (dryrun|upload)"
exit 1
fi
if [ "$ACTION" == "UPLOAD" ] ; then
if [ -z "$CONDA_USERNAME" -o -z "$CONDA_PASSWORD" ] ; then
echo "need anaconda credentials as env variables"
exit 1
fi
fi
conda install -y conda-build conda-verify anaconda-client numpy
if [ "$ACTION" == "upload" ] ; then
anaconda login --username "$CONDA_USERNAME" --password "$CONDA_PASSWORD" --hostname conda-builder-`uname`
conda config --set anaconda_upload yes
function anaconda_logout {
anaconda logout
}
trap anaconda_logout EXIT
else
conda config --set anaconda_upload no
fi
conda-build --python 3.6 build
conda-build --python 3.7 build
conda-build --python 3.8 build
conda-build --python 3.9 build
if [ "$ACTION" == "upload" ] ; then
trap - EXIT
anaconda_logout
fi

@ -0,0 +1,17 @@
#!/bin/bash
destination=$1
if [ -z "$destination" ] ; then
echo "usage: upload_wheels.sh (testing|live)"
fi
if [ "$destination" == 'live' ] ; then
twine upload dist/pyrocko-* \
--username="$PYPI_USERNAME" --password="$PYPI_PASSWORD" \
--skip-existing --disable-progress-bar
else
twine upload --repository-url https://test.pypi.org/legacy/ dist/pyrocko-* \
--username="$PYPI_USERNAME" --password="$PYPI_PASSWORD" \
--skip-existing --disable-progress-bar
fi

@ -0,0 +1,22 @@
#!/usr/bin/env python
import os
import sys
from glob import glob
from nose.core import run_exit
if len(sys.argv) == 2:
target = sys.argv[1].split('.')
if len(target) == 3:
scripts = [sys.argv[1]]
elif len(target) == 2:
scripts = glob(os.path.join(*(target + ['test_*.py'])))
elif len(target) == 1:
scripts = glob(os.path.join(*(target + ['*', 'test_*.py'])))
else:
scripts = glob(os.path.join('test', '*', 'test_*.py'))
sys.argv[1:] = scripts
run_exit()

@ -0,0 +1,15 @@
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "win10"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "4096"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
end
config.vm.network :private_network, ip: '192.168.115.15'
config.vm.network :forwarded_port, guest: 22, host: 22015, id: 'ssh'
config.vm.guest = :windows
config.vm.communicator = "winrm"
config.winssh.shell = "cmd"
end

@ -0,0 +1,37 @@
@echo off
if not exist "C:\Users\vagrant\miniconda3.exe" (
echo Downloading conda installer...
call curl "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe" -o "C:\Users\vagrant\miniconda3.exe" -s
) else (
echo Conda installer already downloaded.
)
if not exist "%UserProfile%\miniconda3" (
echo Installing conda...
call "C:\Users\vagrant\miniconda3.exe" /InstallationType=JustMe /S /D="%UserProfile%\miniconda3"
echo Installing conda modules needed by Pyrocko...
call "%UserProfile%\miniconda3\Scripts\activate.bat"
call conda install -y m2-libiconv m2-libintl m2-vim m2-bash m2-patch git
call conda install -y setuptools numpy scipy matplotlib pyqt pyyaml progressbar2 requests jinja2 nose
) else (
echo Conda is already installed, activating...
call "%UserProfile%\miniconda3\Scripts\activate.bat"
)
if exist "%UserProfile%\pyrocko" (
rmdir /s /q "%UserProfile%\pyrocko"
)
call git clone -b %1 "C:\vagrant\pyrocko.git" "%UserProfile%\pyrocko"
cd pyrocko
mklink /d "test\data" "C:\vagrant\pyrocko-test-data"
mklink /d "test\example_run_dir" "C:\vagrant\example_run_dir"
call python setup.py install
call python -m pyrocko.print_version deps > "C:\vagrant\test-%1.py3.out"
call python maintenance\run_tests_windows.py %2 >> "C:\vagrant\test-%1.py3.out" 2>&1
exit 0

@ -0,0 +1,29 @@
#!/bin/bash
set -e
branch="$1"
if [ -z "$branch" ]; then
branch=`git rev-parse --abbrev-ref HEAD`
fi
thetest="$2"
if [ -z "$thetest" ]; then
thetest="test"
fi
rm -rf pyrocko.git pyrocko-test-data example_run_dir *.out *.log
git clone --bare "../../.." "pyrocko.git"
cp -a "../../../test/data" pyrocko-test-data
cp -a "../../../test/example_run_dir" example_run_dir
echo "testing branch: $branch"
echo "running test: $thetest"
echo "testing branch $branch" >> log.out
date -uIseconds >> log.out
vagrant up
vagrant ssh -- "C:\\vagrant\\inside.bat" "$branch" "$thetest" > >(tee -a "log.out") 2> >(tee -a "log.out" >&2) || /bin/true
vagrant halt
date -uIseconds >> log.out

@ -0,0 +1,9 @@
:: "c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
IF NOT EXIST "libmseed" (
tar -xzf libmseed-2.19.6.tar.gz --exclude=doc --exclude=test --exclude=example
patch -s -p0 < libmseed-2.19.6-speedread.patch
) ELSE (
ECHO libmseed found
)

@ -2,12 +2,10 @@
set -e
if [ ! -f libmseed/libmseed.a ]; then
if [ ! -d libmseed ]; then
rm -rf libmseed
tar -xzf libmseed-2.19.6.tar.gz
cd libmseed
CFLAGS="-fPIC" make static
cd ..
tar -xzf libmseed-2.19.6.tar.gz --exclude=doc --exclude=test --exclude=example
patch -s -p0 < libmseed-2.19.6-speedread.patch
fi
if [ ! -d evalresp-3.3.0/lib ]; then

@ -6,12 +6,16 @@ import time
import shutil
import tempfile
import numpy
import glob
from distutils.sysconfig import get_python_inc
from setuptools import setup, Extension, Command
from setuptools.command.build_py import build_py
from setuptools.command.build_ext import build_ext
from setuptools.command.install import install
is_windows = sys.platform.startswith('win')
running_bdist_wheel = False
try:
from wheel.bdist_wheel import bdist_wheel
@ -101,13 +105,26 @@ installed_date = %s
pass
libmseed_sources = [op.join('libmseed', entry) for entry in [
'fileutils.c', 'genutils.c', 'gswap.c', 'lmplatform.c',
'logging.c', 'lookup.c', 'msrutils.c', 'pack.c', 'packdata.c',
'parseutils.c', 'selection.c', 'tracelist.c', 'traceutils.c',
'unpack.c', 'unpackdata.c']]
def make_prerequisites():
from subprocess import check_call
if is_windows:
cmd = ['prerequisites\\prerequisites.bat']
else:
cmd = ['sh', 'prerequisites/prerequisites.sh']
try:
check_call(['sh', 'prerequisites/prerequisites.sh'])
check_call(cmd)
except Exception:
sys.exit('error: failed to build the included prerequisites with '
'"sh prerequisites/prerequisites.sh"')
'"%s"' % ' '.join(cmd))
def get_readme_paths():
@ -116,7 +133,7 @@ def get_readme_paths():
for (path, dirnames, filenames) in os.walk(
op.join(op.dirname(__file__), 'src')):
paths.extend(
[op.join(path.split('/', 1)[1], fn) for fn in filenames if
[op.join(*(op.split(path)[1:] + (fn,))) for fn in filenames if
fn == 'README.md'])
return paths
@ -287,9 +304,10 @@ class CustomInstallCommand(install):
def symlink_interpreter(self):
if not running_bdist_wheel \
and hasattr(self, 'install_scripts') \
and sys.executable:
and sys.executable \
and not is_windows:
target = os.path.join(self.install_scripts, 'pyrocko-python')
target = os.path.join(self.install_scripts, 'pyrocko-python.exe')
if os.path.exists(target):
os.unlink(target)
@ -398,7 +416,6 @@ class CustomBuildAppCommand(build_ext):
self.make_app()
def make_app(self):
import glob
import os
import shutil
from setuptools import setup
@ -455,8 +472,11 @@ def _check_for_openmp():
import subprocess
tmpdir = tempfile.mkdtemp(prefix='pyrocko')
compiler = os.environ.get(
'CC', distutils.sysconfig.get_config_var('CC')).split()[0]
try:
compiler = os.environ.get(
'CC', distutils.sysconfig.get_config_var('CC')).split()[0]
except Exception:
return False
# Attempt to compile a test script.
# See http://openmp.org/wp/openmp-compilers/
@ -551,6 +571,112 @@ cmdclass = {
if CustomBDistWheelCommand:
cmdclass['bdist_wheel'] = CustomBDistWheelCommand
if is_windows:
extra_compile_args = []
else:
extra_compile_args = ['-Wextra']
ext_modules = [
Extension(
'datacube_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=extra_compile_args,
sources=[op.join('src', 'io', 'ext', 'datacube_ext.c')]),
Extension(
'signal_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=extra_compile_args,
sources=[op.join('src', 'ext', 'signal_ext.c')]),
Extension(
'mseed_ext',
include_dirs=[get_python_inc(), numpy.get_include(),
get_build_include('libmseed')],
extra_compile_args=extra_compile_args + (
['-D_CRT_SECURE_NO_WARNINGS', '-DWIN32'] if is_windows else []),
sources=[
op.join('src', 'io', 'ext', 'mseed_ext.c')] + libmseed_sources),
Extension(
'ims_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=extra_compile_args,
sources=[op.join('src', 'io', 'ext', 'ims_ext.c')]),
Extension(
"avl",
sources=[op.join('src', 'ext', 'pyavl-1.12', 'avl.c'),
op.join('src', 'ext', 'pyavl-1.12', 'avlmodule.c')],
define_macros=[('HAVE_AVL_VERIFY', None),
('AVL_FOR_PYTHON', None)],
include_dirs=[get_python_inc()],
extra_compile_args=['-Wno-parentheses', '-Wno-uninitialized']
if not is_windows else [],
extra_link_args=[] if sys.platform != 'sunos5' else ['-Wl,-x']),
Extension(
'eikonal_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=extra_compile_args + omp_arg,
extra_link_args=[] + omp_lib,
sources=[op.join('src', 'ext', 'eikonal_ext.c')]),
Extension(
'orthodrome_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=extra_compile_args,
sources=[op.join('src', 'ext', 'orthodrome_ext.c')]),
Extension(
'parstack_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=extra_compile_args + omp_arg,
extra_link_args=[] + omp_lib,
sources=[op.join('src', 'ext', 'parstack_ext.c')]),
Extension(
'autopick_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=extra_compile_args,
sources=[op.join('src', 'ext', 'autopick_ext.c')]),
Extension(
'gf.store_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=extra_compile_args
+ ['-D_FILE_OFFSET_BITS=64'] + omp_arg,
extra_link_args=[] + omp_lib,
sources=[op.join('src', 'gf', 'ext', 'store_ext.c')]),
Extension(
'ahfullgreen_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=extra_compile_args,
sources=[op.join('src', 'ext', 'ahfullgreen_ext.c')])]
ext_modules_non_windows = [
Extension(
'util_ext',
extra_compile_args=extra_compile_args,
sources=[op.join('src', 'ext', 'util_ext.c')]),
Extension(
'evalresp_ext',
include_dirs=[get_python_inc(), numpy.get_include(),
get_build_include('evalresp-3.3.0/include/')],
library_dirs=[get_build_include('evalresp-3.3.0/lib/')],
libraries=['evresp'],
extra_compile_args=extra_compile_args + [
'-I%s' % get_build_include('evalresp-3.3.0/include')],
sources=[op.join('src', 'ext', 'evalresp_ext.c')])]
if not is_windows:
ext_modules.extend(ext_modules_non_windows)
setup(
cmdclass=cmdclass,
name=packname,
@ -599,101 +725,12 @@ setup(
},
packages=[packname] + subpacknames,
package_dir={'pyrocko': 'src'},
ext_package=packname,
ext_modules=[
Extension(
'util_ext',
extra_compile_args=['-Wextra'],
sources=[op.join('src', 'ext', 'util_ext.c')]),
Extension(
'signal_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=['-Wextra'],
sources=[op.join('src', 'ext', 'signal_ext.c')]),
Extension(
'mseed_ext',
include_dirs=[get_python_inc(), numpy.get_include(),
get_build_include('libmseed/')],
library_dirs=[get_build_include('libmseed/')],
libraries=['mseed'],
extra_compile_args=['-Wextra'],
sources=[op.join('src', 'io', 'ext', 'mseed_ext.c')]),
Extension(
'evalresp_ext',
include_dirs=[get_python_inc(), numpy.get_include(),
get_build_include('evalresp-3.3.0/include/')],
library_dirs=[get_build_include('evalresp-3.3.0/lib/')],
libraries=['evresp'],
extra_compile_args=[
'-Wextra',
'-I%s' % get_build_include('evalresp-3.3.0/include')],
sources=[op.join('src', 'ext', 'evalresp_ext.c')]),
Extension(
'ims_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=['-Wextra'],
sources=[op.join('src', 'io', 'ext', 'ims_ext.c')]),
Extension(
'datacube_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=['-Wextra'],
sources=[op.join('src', 'io', 'ext', 'datacube_ext.c')]),
Extension(
'autopick_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=['-Wextra'],
sources=[op.join('src', 'ext', 'autopick_ext.c')]),
Extension(
'gf.store_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=['-D_FILE_OFFSET_BITS=64', '-Wextra'] + omp_arg,
extra_link_args=[] + omp_lib,
sources=[op.join('src', 'gf', 'ext', 'store_ext.c')]),
Extension(
'eikonal_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=['-Wextra'] + omp_arg,
extra_link_args=[] + omp_lib,
sources=[op.join('src', 'ext', 'eikonal_ext.c')]),
Extension(
'parstack_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=['-Wextra'] + omp_arg,
extra_link_args=[] + omp_lib,
sources=[op.join('src', 'ext', 'parstack_ext.c')]),
Extension(
'ahfullgreen_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=['-Wextra'],
sources=[op.join('src', 'ext', 'ahfullgreen_ext.c')]),
Extension(
'orthodrome_ext',
include_dirs=[get_python_inc(), numpy.get_include()],
extra_compile_args=['-Wextra'],
sources=[op.join('src', 'ext', 'orthodrome_ext.c')]),
Extension(
"avl",
sources=[op.join('src', 'ext', 'pyavl-1.12', 'avl.c'),
op.join('src', 'ext', 'pyavl-1.12', 'avlmodule.c')],
define_macros=[('HAVE_AVL_VERIFY', None),
('AVL_FOR_PYTHON', None)],
include_dirs=[get_python_inc()],
extra_compile_args=['-Wno-parentheses', '-Wno-uninitialized'],
extra_link_args=[] if sys.platform != 'sunos5' else ['-Wl,-x']),
],
ext_modules=ext_modules,
scripts=[
'src/apps/gmtpy-epstopdf',

@ -32,6 +32,11 @@ import logging
import ssl
import socket
try:
import certifi
except ImportError:
certifi = None
from pyrocko import util
from pyrocko.util import DownloadError
@ -45,6 +50,13 @@ try:
except NameError:
newstr = str
if certifi:
g_cafile = certifi.where()
else:
g_cafile = None
logger = logging.getLogger('pyrocko.client.fdsn')
g_url = '%(site)s/fdsnws/%(service)s/%(majorversion)i/%(method)s'
@ -237,6 +249,8 @@ def _request(
if allow_TLSv1:
url_args['context'] = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
url_args['cafile'] = g_cafile
opener = None
req = Request(url)

@ -5,6 +5,27 @@
import time
class EvalrespNotAvailable(Exception):
pass
def import_ext():
try:
from pyrocko import evalresp_ext as ext
return ext
except ImportError:
raise EvalrespNotAvailable(
'The pyrocko.evalresp module is not supported on your platform.')
def have_evalresp():
try:
import_ext()
return True
except EvalrespNotAvailable:
return False
def evalresp(
sta_list='*',
cha_list='*',
@ -23,7 +44,8 @@ def evalresp(
listinterp_in_flag=0,
listinterp_tension=1000.0):
from pyrocko import evalresp_ext as ext
ext = import_ext()
datime = time.strftime('%Y,%j,%H:%M:%S', time.gmtime(instant))
return ext.evalresp(sta_list, cha_list, net_code, locid, datime,

@ -3,17 +3,22 @@
#include "Python.h"
#include "numpy/arrayobject.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef _WIN32
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#include <complex.h>
typedef npy_float64 float64_t;
#ifdef _WIN32
typedef _Dcomplex complex_t;
#else
typedef double complex complex_t;
#endif
#ifndef _WIN32
#define max(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
@ -23,6 +28,35 @@ typedef npy_float64 float64_t;
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })
#endif
#ifndef _WIN32
#define DI I
#define mulcc(a,b) (a)*(b)
#define mulcr(a,b) (a)*(b)
#define addcc(a,b) (a)+(b)
#define addcr(a,b) (a)+(b)
#define subcc(a,b) (a)-(b)
#define subcr(a,b) (a)-(b)
#define build_complex(a, b) (a) + I*(b)
#else
static const complex_t DI = { 0.0, 1.0 };
#define mulcc(a,b) _Cmulcc(a,b)
#define mulcr(a,b) _Cmulcr(a,b)
complex_t addcc(complex_t a, complex_t b) {
return _Cbuild(creal(a) + creal(b), cimag(a) + cimag(b));
}
complex_t addcr(complex_t a, double b) {
return _Cbuild(creal(a) + b, cimag(a));
}
complex_t subcc(complex_t a, complex_t b) {
return _Cbuild(creal(a) - creal(b), cimag(a) - cimag(b));
}
complex_t subcr(complex_t a, double b) {
return _Cbuild(creal(a) - b, cimag(a));
}
#define build_complex _Cbuild
#endif
typedef enum {
SUCCESS = 0,
@ -30,7 +64,7 @@ typedef enum {
BAD_ARRAY,
} ahfullgreen_error_t;
const char* ahfullgreen_error_names[] = {
static const char* ahfullgreen_error_names[] = {
"SUCCESS",
"SINGULARITY",
"BAD_ARRAY",
@ -91,7 +125,7 @@ static ahfullgreen_error_t numpy_or_none_to_c_double(
}