From e12f15e3295c9bf072f160bc80726e04442c5ffc Mon Sep 17 00:00:00 2001 From: Zhang Yunjun Date: Sun, 23 Oct 2022 19:58:44 -0700 Subject: [PATCH 1/3] bugfix to publish-to-pypi: add mamba env + skip wheel build/upload --- .github/workflows/publish-to-test-pypi.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index a3265d6..942ffef 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -8,6 +8,12 @@ on: tags: - v* +# activate miniconda environment +# link: https://github.com/marketplace/actions/provision-with-micromamba#IMPORTANT +defaults: + run: + shell: bash -l {0} + jobs: build-n-publish: if: github.repository_owner == 'insarlab' @@ -24,6 +30,12 @@ jobs: with: python-version: "3.10" + # link: https://github.com/marketplace/actions/provision-with-micromamba + - name: Install Conda environment with Micromamba + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: environment.yml + - name: Install pypa/build run: >- python -m @@ -36,9 +48,12 @@ jobs: python -m build --sdist - --wheel + --no-isolation # not install in an isolated environment --outdir dist/ . + # skip due to the bad request error from pypi: + # binary wheel has an unsupported platform tag 'linux_x86_64' + #--wheel - name: Publish developed version 📦 to Test PyPI if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' From 010bc4e1511f1e1078c5c1bdcaa4db4bd7dbc851 Mon Sep 17 00:00:00 2001 From: Zhang Yunjun Date: Sun, 23 Oct 2022 22:17:47 -0700 Subject: [PATCH 2/3] setup: grab dev version from version.py + grid/point: move solid_grid/point import into sub-functions, to support grabbing pysolid.version without a compiled solid.for + setup: switch to use pysolid.version to grab the dev version number --- setup.py | 14 +++++++------- src/pysolid/grid.py | 19 ++++++++++--------- src/pysolid/point.py | 20 ++++++++++---------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/setup.py b/setup.py index 50897db..f28aa09 100644 --- a/setup.py +++ b/setup.py @@ -4,17 +4,17 @@ # 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 version.py file: version -# Note by Yunjun, Oct 2022: do not use sys.path.append() to import pysolid because -# pysolid.__init__ requires the pysolid.solid sub-module, which is not compiled yet. -with open("src/pysolid/version.py", "r") as f: - lines = f.readlines() - line = [line for line in lines if line.strip().startswith("Tag(")][0].strip() - version = line.replace("'",'"').split('"')[1] +# 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: diff --git a/src/pysolid/grid.py b/src/pysolid/grid.py index cadd143..3920943 100644 --- a/src/pysolid/grid.py +++ b/src/pysolid/grid.py @@ -11,19 +11,12 @@ # pysolid.calc_solid_earth_tides_grid() +import datetime as dt import os + import numpy as np -import datetime as dt from skimage.transform import resize -try: - from pysolid.solid import solid_grid -except ImportError: - msg = "Cannot import name 'solid' from 'pysolid'!" - msg += '\n Maybe solid.for is NOT compiled yet.' - msg += '\n Check instruction at: https://github.com/insarlab/PySolid.' - raise ImportError(msg) - ################################## Earth tides - grid mode ################################### def calc_solid_earth_tides_grid(dt_obj, atr, step_size=1e3, display=False, verbose=True): @@ -49,6 +42,14 @@ def calc_solid_earth_tides_grid(dt_obj, atr, step_size=1e3, display=False, verbo Examples: atr = readfile.read_attribute('geo_velocity.h5') tide_e, tide_n, tide_u = calc_solid_earth_tides_grid('20180219', atr) """ + try: + from pysolid.solid import solid_grid + except ImportError: + msg = "Cannot import name 'solid' from 'pysolid'!" + msg += '\n Maybe solid.for is NOT compiled yet.' + msg += '\n Check instruction at: https://github.com/insarlab/PySolid.' + raise ImportError(msg) + vprint = print if verbose else lambda *args, **kwargs: None # location diff --git a/src/pysolid/point.py b/src/pysolid/point.py index 911e71d..07d109a 100644 --- a/src/pysolid/point.py +++ b/src/pysolid/point.py @@ -11,20 +11,13 @@ # pysolid.calc_solid_earth_tides_point() -import os import collections import datetime as dt +import os + import numpy as np -from scipy import signal from matplotlib import pyplot as plt, ticker, dates as mdates - -try: - from pysolid.solid import solid_point -except ImportError: - msg = "Cannot import name 'solid' from 'pysolid'!" - msg += '\n Maybe solid.for is NOT compiled yet.' - msg += '\n Check instruction at: https://github.com/insarlab/PySolid.' - raise ImportError(msg) +from scipy import signal ## Tidal constituents @@ -168,6 +161,13 @@ def calc_solid_earth_tides_point_per_day(lat, lon, date_str, step_sec=60): tide_n, tide_u) = calc_solid_earth_tides_point_per_day(34.0, -118.0, '20180219') """ + try: + from pysolid.solid import solid_point + except ImportError: + msg = "Cannot import name 'solid' from 'pysolid'!" + msg += '\n Maybe solid.for is NOT compiled yet.' + msg += '\n Check instruction at: https://github.com/insarlab/PySolid.' + raise ImportError(msg) ## calc solid Earth tides and write to text file txt_file = os.path.abspath('solid.txt') From e55525c4b8ad4d7c3bc90307496ac851f6d4ffbd Mon Sep 17 00:00:00 2001 From: Zhang Yunjun Date: Sun, 23 Oct 2022 22:36:50 -0700 Subject: [PATCH 3/3] add Tag for v0.2.3 + update lead sec to Jun 2023 + version: add Tab for version 0.2.3 + solid.for: update the file expiration date of the leap second table to 2023-Jun-28 as no leap second will be introduced at the end of Dec 2022, based on Bulletin C 64 (https://hpiers.obspm.fr/eoppc/bul/bulc/bulletinc.64) --- src/pysolid/solid.for | 6 +++--- src/pysolid/version.py | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pysolid/solid.for b/src/pysolid/solid.for index 63a7c62..9d70f88 100644 --- a/src/pysolid/solid.for +++ b/src/pysolid/solid.for @@ -1549,9 +1549,9 @@ ***** http://www.csgnetwork.com/julianmodifdateconv.html implicit double precision(a-h,o-z) - !*** upper limit, leap second table, 2022dec28 + !*** upper limit, leap second table, 2023jun28 !*** lower limit, leap second table, 1972jan01 - parameter(MJDUPPER=59941) + parameter(MJDUPPER=60123) parameter(MJDLOWER=41317) !*** leap second table limit flag @@ -1632,7 +1632,7 @@ ***** other leap second references at: ***** http://hpiers.obspm.fr/eoppc/bul/bulc/Leap_Second_History.dat ***** http://hpiers.obspm.fr/eoppc/bul/bulc/bulletinc.dat -***** File expires on 28 December 2022 +***** File expires on 28 June 2023 *** test against newest leaps first diff --git a/src/pysolid/version.py b/src/pysolid/version.py index 4322db5..0ee7deb 100644 --- a/src/pysolid/version.py +++ b/src/pysolid/version.py @@ -12,6 +12,7 @@ # release history Tag = collections.namedtuple('Tag', 'version date') release_history = ( + Tag('0.2.3', '2022-10-23'), Tag('0.2.2', '2022-07-20'), Tag('0.2.1', '2022-01-05'), Tag('0.2.0', '2021-11-10'),