Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
command: |
apt update
apt-get update --yes && apt-get upgrade --yes
apt-get install --yes wget
apt-get install --yes wget git
# download and install miniconda3
mkdir -p ${HOME}/tools
cd ${HOME}/tools
Expand Down
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
101 changes: 101 additions & 0 deletions .github/workflows/build-and-publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Publish 📦 to PyPI

# Build on every branch push, tag push, and pull request change:
on:
push:
branches:
- main
tags:
- v*
pull_request:

jobs:
build_wheels:
name: Build Python 🐍 wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-11] #windows-2019

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Provide gfortran (macOS)
if: runner.os == 'macOS'
run: |
# https://github.com/actions/virtual-environments/issues/2524
# https://github.com/cbg-ethz/dce/blob/master/.github/workflows/pkgdown.yaml
sudo ln -s /usr/local/bin/gfortran-11 /usr/local/bin/gfortran
sudo mkdir /usr/local/gfortran
sudo ln -s /usr/local/Cellar/gcc@11/*/lib/gcc/11 /usr/local/gfortran/lib
gfortran --version

- name: Provide gfortran (Windows)
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2

- name: Tell distutils to use mingw (Windows)
if: runner.os == 'Windows'
run: |
echo "[build]`ncompiler=mingw32" | Out-File -Encoding ASCII ~/pydistutils.cfg

- name: Build wheels
uses: pypa/cibuildwheel@v2.11.2
env:
# Disable building for PyPy and 32bit.
CIBW_SKIP: pp* *-win32 *-manylinux_i686
# Package the DLL dependencies in the wheel for windows (done by default for the other platforms).
# delvewheel cannot mangle the libraries, stripping does not work.
CIBW_BEFORE_BUILD_WINDOWS: pip install delvewheel
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel show {wheel} && delvewheel repair -w {dest_dir} {wheel} --no-mangle-all"

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

build_sdist:
name: Build Python 🐍 source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.repository_owner == 'insarlab' && github.event_name == 'push'
steps:
- uses: actions/download-artifact@v3
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
path: dist

- name: Publish developed version 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1.5.0
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: false
verbose: true

- name: Publish released version 📦 to PyPI
uses: pypa/gh-action-pypi-publish@v1.5.0
if: startsWith(github.ref, 'refs/tags/v')
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true
72 changes: 0 additions & 72 deletions .github/workflows/publish-to-test-pypi.yml

This file was deleted.

10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ or via `apt` (or other package managers) for [Debian-derivative OS](https://wiki
apt install python3-pysolid
```

Installing via `conda` and `apt` is recomended because PySolid contains Fortran source code, which required compilcation. Otherwise, you may build it from source as described below.
Installing via `conda` and `apt` is recommended because PySolid contains Fortran source code, which required compilation. Otherwise, you may build it from source as described below.

#### 1.1 Build from source

Expand Down Expand Up @@ -56,10 +56,14 @@ python -m pip install -r PySolid/requirements.txt

```bash
# option 1: use pip to install pysolid into the current environment
# use "pip install -e" to install in the development mode
python -m pip install PySolid

# option 2: manually compile the Fortran code and setup environment variable
# option 2: use pip to install pysolid in develop mode (editable) into the current environment
# setting an environmental variable as below is required for editable installs via pyproject.toml
export SETUPTOOLS_ENABLE_FEATURES="legacy-editable"
python -m pip install -e PySolid

# option 3: manually compile the Fortran code and setup environment variable
cd PySolid/src/pysolid
f2py -c -m solid solid.for
export PYTHONPATH=${PYTHONPATH}:~/tools/PySolid
Expand Down
9 changes: 8 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ channels:
- conda-forge
- defaults
dependencies:
- python>=3.8
# for running
- numpy
- scipy
- matplotlib
- scikit-image
- fortran-compiler # A generic way to obtain the Fortran compiler across platforms through conda-forge channel
# for packaging and installation
- fortran-compiler # Fortran compiler across platforms through conda-forge channel
- pip
- setuptools
- setuptools_scm
- wheel
49 changes: 49 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[build-system]
requires = ["setuptools>=61.0", "setuptools_scm[toml]>=6.2", "numpy", "wheel"]

build-backend = "setuptools.build_meta"

[project]
name = "pysolid"
authors = [
{name="Zhang Yunjun", email="yunjunzgeo@gmail.com"},
{name="Dennis Milbert"},
]
description = "A Python wrapper for solid to compute solid Earth tides"
readme = "README.md"
requires-python = ">=3.8"
keywords = ["solid Earth tides", "deformation", "geodesy", "geophysics"]
license = {text = "GPL-3.0-or-later"}
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
]
dependencies = [
"numpy",
"scipy",
"matplotlib",
"scikit-image",
]
dynamic = ["version"]

[project.urls]
"Homepage" = "https://github.com/insarlab/PySolid"
"Bug Tracker" = "https://github.com/insarlab/PySolid/issues"

[tool.setuptools]
include-package-data = true
zip-safe = false

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
pysolid = ["*.for"]

[tool.setuptools_scm]
version_scheme = "post-release"
local_scheme = "no-local-version"
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# for running
numpy
scipy
matplotlib
scikit-image
# for packaging and installation
#fortran-compiler # Fortran compiler across platforms through conda-forge channel
pip
setuptools
setuptools_scm
wheel
63 changes: 1 addition & 62 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,74 +1,13 @@
# Author: Zhang Yunjun, Jan 2021
# Copyright 2020, by the California Institute of Technology.
# Note by Yunjun, Oct 2022: "pip install pysolid" does not work,
# because a Fortran compiler is required but not available via pip


import os
import sys

# always prefer setuptools over distutils
import setuptools
from numpy.distutils.core import setup, Extension

# Grab from pysolid.version: version
# link: https://stackoverflow.com/questions/53648900
sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
from pysolid.version import version

# Grab from README file: long_description
with open("README.md", "r") as f:
long_description = f.read()

setup(
name='pysolid',
version=version,
description="A Python wrapper for solid to compute solid Earth tides",
url="https://github.com/insarlab/PySolid",
download_url=("https://github.com/insarlab/PySolid/archive/v{}.tar.gz".format(version)),
long_description=long_description,
long_description_content_type="text/markdown",
author="Zhang Yunjun, Dennis Milbert",
author_email="yunjunzgeo@gmail.com",
license="GPL-3.0-or-later",
license_files=("LICENSE",),

classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
],
keywords="solid Eartth tides, deformation, geodesy, geophysics",

project_urls={
"Bug Reports": "https://github.com/insarlab/PySolid/issues",
"Source": "https://github.com/insarlab/PySolid",
},

# package discovery
packages=setuptools.find_packages("src"), # include all packages under src
package_dir={"": "src"}, # tell distutils packages are under src

# build fortran deps with numpy.f2py
# fortran extensions to build with numpy.f2py
ext_modules=[
Extension(name='pysolid.solid', sources=['src/pysolid/solid.for']),
],

# dependencies
python_requires=">=3.6",
install_requires=[
'numpy',
'scipy',
'matplotlib',
'scikit-image',
],

# data files
include_package_data=True,
package_data={
"pysolid": ["solid.for"],
},
)
Loading