Skip to content

Commit c62e0e3

Browse files
Merge pull request #11 from rozyczko/master
multiplatform CI
2 parents 6554365 + 229a980 commit c62e0e3

File tree

7 files changed

+87
-7
lines changed

7 files changed

+87
-7
lines changed

Diff for: .github/workflows/build.yaml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: build and upload
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
strategy:
8+
max-parallel: 4
9+
matrix:
10+
python-version: ['3.8', '3.9', '3.10']
11+
os: [ubuntu-latest, macos-latest, windows-latest]
12+
13+
runs-on: ${{ matrix.os }}
14+
steps:
15+
- name: Check-out repository
16+
uses: actions/checkout@v2
17+
18+
- name: set up conda
19+
uses: s-weigand/setup-conda@v1
20+
with:
21+
update-conda: true
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: |
26+
conda install -c conda-forge twine
27+
conda install -c conda-forge wheel
28+
conda install -c conda-forge setuptools
29+
conda install -c conda-forge pip
30+
conda install -c conda-forge gsl
31+
32+
- name: Build wheels
33+
run: |
34+
python setup.py sdist bdist_wheel
35+
36+
- name: Run tests
37+
run: |
38+
conda install -c conda-forge numpy
39+
python setup.py install
40+
python conda-recipe/run_test.py
41+
42+
- name: Upload Artifacts GitHub releases
43+
uses: ncipollo/release-action@v1
44+
with:
45+
draft: false
46+
prerelease: true
47+
allowUpdates: true
48+
replacesArtifacts: true
49+
token: ${{ secrets.GITHUB_TOKEN }}
50+
artifacts: ${{ github.workspace }}/dist/*.whl
51+
tag: 1.4.0
52+
body: This is an alpha build of the pdffit2 library (1.4.0)
53+
54+
# This step will upload tagged commits to pypi.
55+
# The pypi token must be added to GH secrets
56+
#
57+
# - name: Publish package
58+
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
59+
# uses: pypa/gh-action-pypi-publish@release/v1
60+
# with:
61+
# password: ${{ secrets.PYPI_API_TOKEN }}

Diff for: pdffit2module/PyFileStreambuf.h

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#ifndef PYFILESTREAMBUF_H_INCLUDED
2727
#define PYFILESTREAMBUF_H_INCLUDED
28+
#define PY_SSIZE_T_CLEAN
2829

2930
#include <Python.h>
3031
#include <streambuf>

Diff for: pdffit2module/bindings.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Comments:
1818
*
1919
***********************************************************************/
20-
20+
#define PY_SSIZE_T_CLEAN
2121
#include <Python.h>
2222

2323
#include "bindings.h"

Diff for: pdffit2module/misc.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Comments:
1818
*
1919
***********************************************************************/
20-
20+
#define PY_SSIZE_T_CLEAN
2121
#include <Python.h>
2222
#include <vector>
2323
#include <string>

Diff for: pdffit2module/pdffit2module.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Comments:
1818
*
1919
***********************************************************************/
20-
20+
#define PY_SSIZE_T_CLEAN
2121
#include <Python.h>
2222
#include <ostream>
2323

Diff for: pdffit2module/pyexceptions.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Comments:
1818
*
1919
***********************************************************************/
20-
20+
#define PY_SSIZE_T_CLEAN
2121
#include <Python.h>
2222

2323
PyObject *pypdffit2_runtimeError = 0;

Diff for: setup.py

+21-3
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@
3131

3232

3333
def gitinfo():
34-
from subprocess import Popen, PIPE
34+
from subprocess import Popen, PIPE, check_output
3535
kw = dict(stdout=PIPE, cwd=MYDIR, universal_newlines=True)
3636
proc = Popen(['git', 'describe', '--tags', '--match=v[[:digit:]]*'], **kw)
3737
desc = proc.stdout.read()
3838
proc = Popen(['git', 'log', '-1', '--format=%H %ct %ci'], **kw)
3939
glog = proc.stdout.read()
4040
rv = {}
41-
rv['version'] = '.post'.join(desc.strip().split('-')[:2]).lstrip('v')
4241
rv['commit'], rv['timestamp'], rv['date'] = glog.strip().split(None, 2)
42+
version = check_output(['git', 'tag']).decode('ascii').strip()
43+
rv['version'] = version
4344
return rv
4445

4546

@@ -66,6 +67,7 @@ def getversioncfg():
6667
except OSError:
6768
pass
6869
# finally, check and update the active version file
70+
6971
cp = RawConfigParser()
7072
cp.read(versioncfgfile)
7173
d = cp.defaults()
@@ -123,11 +125,27 @@ def get_gsl_config():
123125
rv['library_dirs'] += [lib]
124126
return rv
125127

128+
def get_gsl_config_win():
129+
'''Return dictionary with paths to GSL library, windwows version.
130+
This version is installed with conda.
131+
'''
132+
conda_prefix = os.environ['CONDA_PREFIX']
133+
inc = os.path.join(conda_prefix, 'Library', 'include')
134+
lib = os.path.join(conda_prefix, 'Library', 'lib')
135+
rv = {'include_dirs': [], 'library_dirs': []}
136+
rv['include_dirs'] += [inc]
137+
rv['library_dirs'] += [lib]
138+
return rv
139+
126140
# ----------------------------------------------------------------------------
127141

128142
# compile and link options
129143
define_macros = []
130-
gcfg = get_gsl_config()
144+
os_name = os.name
145+
if os_name == 'nt':
146+
gcfg = get_gsl_config_win()
147+
else:
148+
gcfg = get_gsl_config()
131149
include_dirs = [MYDIR] + gcfg['include_dirs']
132150
library_dirs = []
133151
libraries = []

0 commit comments

Comments
 (0)