diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 3383cb5a..9e17d3c5 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -15,10 +15,6 @@ replace = AC_INIT([xraylib],[{new_version}],[Tom.Schoonjans@me.com]) search = VERSION {current_version} replace = VERSION {new_version} -[bumpversion:file:java/GoogleAnalyticsThread.java] -search = GOOGLE_ANALYTICS_APPLICATION_VERSION = "{current_version}"; -replace = GOOGLE_ANALYTICS_APPLICATION_VERSION = "{new_version}"; - [bumpversion:file:java/build.gradle.in] search = version = '{current_version}' replace = version = '{new_version}' diff --git a/Changelog b/Changelog index b994e64b..2478bd4d 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,9 @@ +Version 4.1.4 Tom Schoonjans + +- Bug fix: return 0.0 early in `PM3_auger_cascade_kissel` and `PM4_auger_cascade_kissel` (reported and fixed by Chris Ninham) +- Bug fix: ensure that meson will error out when `python-numpy-bindings` is set to `enabled`, but `cython` is not found. +- Remove Google Analytics support as they have discontinued Universal Analytics + Version 4.1.3 Tom Schoonjans - Fix bug in python meson build, resulting in numpy integers not being accepted by SWIG generated python bindings (reported by Christian Koernig) diff --git a/java/GoogleAnalyticsThread.java b/java/GoogleAnalyticsThread.java deleted file mode 100644 index 3ea5dc78..00000000 --- a/java/GoogleAnalyticsThread.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.github.tschoonj.xraylib; - -import java.io.DataOutputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLEncoder; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.prefs.Preferences; - -public class GoogleAnalyticsThread extends Thread { - - private static final String GOOGLE_ANALYTICS_ENDPOINT = "https://www.google-analytics.com/collect"; - private static final String GOOGLE_ANALYTICS_TRACKING_ID = "UA-42595764-5"; - private static final String GOOGLE_ANALYTICS_APPLICATION_NAME = "xraylib"; - private static final String GOOGLE_ANALYTICS_APPLICATION_VERSION = "4.1.3"; - private static final String GOOGLE_ANALYTICS_HIT_TYPE = "event"; - - public void run() { - Map payload = new HashMap(); - payload.put("v", "1"); - payload.put("tid", GOOGLE_ANALYTICS_TRACKING_ID); - payload.put("t", GOOGLE_ANALYTICS_HIT_TYPE); - payload.put("an", GOOGLE_ANALYTICS_APPLICATION_NAME); - payload.put("av", GOOGLE_ANALYTICS_APPLICATION_VERSION); - - if (System.getenv().containsKey("CI")) { - payload.put("cid", "60220817-0a15-49ce-b581-9cab2b225e7d"); - payload.put("ec", "CI-java"); - } else { - Preferences prefs = Preferences.userNodeForPackage(GoogleAnalyticsThread.class); - payload.put("cid", prefs.get("uuid", UUID.randomUUID().toString())); - payload.put("ec", "java"); - } - - payload.put("ea", "import"); - payload.put("el", String.format("xraylib-%s-Java-%s-%s", GOOGLE_ANALYTICS_APPLICATION_VERSION, System.getProperty("java.runtime.name"), System.getProperty("java.runtime.version"))); - payload.put("ua", "Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14"); - - String url = GOOGLE_ANALYTICS_ENDPOINT; - try { - StringBuilder postData = new StringBuilder(); - for (Map.Entry parameter : payload.entrySet()) { - if (postData.length() != 0) - postData.append('&'); - final String encodedKey = URLEncoder.encode(parameter.getKey().toString(), "UTF-8"); - final String encodedValue = URLEncoder.encode(parameter.getValue().toString(), "UTF-8"); - postData.append(encodedKey); - postData.append("="); - postData.append(encodedValue); - } - byte[] postDataBytes = postData.toString().getBytes("UTF-8"); - - HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); - connection.setRequestMethod("POST"); - connection.setConnectTimeout(1000); - connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); - connection.setDoOutput(true); - connection.setUseCaches(false); - connection.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length)); - - try(DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) { - wr.write(postDataBytes); - } - - connection.getResponseCode(); - } catch (Exception e) { - System.err.println("GoogleAnalyticsThread exception caught: " + e.getMessage()); - } - } - public static void main(String[] args) { - Thread thread = new GoogleAnalyticsThread(); - thread.start(); - try { - thread.join(); - } catch (InterruptedException e) { - System.err.println("Thread got interrupted"); - } - } - -} diff --git a/java/Makefile.am b/java/Makefile.am index 44dd0845..50b7ed39 100644 --- a/java/Makefile.am +++ b/java/Makefile.am @@ -18,8 +18,7 @@ java_source = \ compoundDataNIST.java \ radioNuclideData.java \ Crystal_Struct.java \ - Crystal_Atom.java \ - GoogleAnalyticsThread.java + Crystal_Atom.java if ENABLE_JAVA diff --git a/java/Xraylib.java b/java/Xraylib.java index 59a22daa..9fac55fc 100644 --- a/java/Xraylib.java +++ b/java/Xraylib.java @@ -38,7 +38,6 @@ public class Xraylib { static { try { - new GoogleAnalyticsThread().start(); XRayInit(); } catch (Exception e){ diff --git a/python/xraylib_np.pyx b/python/xraylib_np.pyx index 4b1a45aa..d5c943cb 100644 --- a/python/xraylib_np.pyx +++ b/python/xraylib_np.pyx @@ -12,97 +12,12 @@ cimport xraylib_np_c as xrl import numpy as np cimport numpy as np -cimport cython from cython.parallel import prange -cimport cython.parallel np.import_array() __version__ = xrl.__version__.decode("utf-8") -import urllib -import os -import http.client -import uuid -from uuid import UUID -import platform -from pathlib import Path -import threading - -def __valid_uuid(_uuid): - try: - a = UUID(_uuid) - except ValueError: - return False - return True - -def __send_google_analytics_launch_event(): - GOOGLE_ANALYTICS_ENDPOINT = "https://www.google-analytics.com/collect" - GOOGLE_ANALYTICS_TRACKING_ID = "UA-42595764-5" - GOOGLE_ANALYTICS_APPLICATION_NAME = "xraylib" - GOOGLE_ANALYTICS_APPLICATION_VERSION = __version__ - GOOGLE_ANALYTICS_HIT_TYPE = "event" - - payload = dict( - v=1, # protocol version - tid=GOOGLE_ANALYTICS_TRACKING_ID, # tracking id - t=GOOGLE_ANALYTICS_HIT_TYPE, # hit type - an=GOOGLE_ANALYTICS_APPLICATION_NAME, # app name - av=GOOGLE_ANALYTICS_APPLICATION_VERSION, # app version - ) - - if 'CI' in os.environ: - payload['cid'] = '60220817-0a15-49ce-b581-9cab2b225e7d' # our default UUID for CI - payload['ec'] = 'CI-python_np' - else: - if os.name == 'nt': - import winreg - with winreg.CreateKey(winreg.HKEY_CURRENT_USER, r'Software\xraylib\ga_conf') as _key: - try: - _uuid = winreg.QueryValueEx(_key, 'uuid')[0] - if not __valid_uuid(_uuid): - raise Exception("Invalid UUID") - except Exception as e: - _uuid = str(uuid.uuid4()) - winreg.SetValueEx(_key, 'uuid', 0, winreg.REG_SZ, _uuid) - else: - try: - f = Path('~', '.config', 'xraylib', 'ga.conf').expanduser() - f.parent.mkdir(mode=0o700, parents=True, exist_ok=True) - if f.exists(): - if f.is_file(): - _uuid = f.read_text().strip() - if not __valid_uuid(_uuid): - _uuid = str(uuid.uuid4()) - f.write_text(_uuid) - else: - return - else: - _uuid = str(uuid.uuid4()) - f.write_text(_uuid) - except: - pass - - payload['cid'] = _uuid - payload['ec'] = 'python_np' - - payload['ea'] = 'import' - payload['el'] = 'xraylib-{}-Python-{}-{}'.format(__version__, platform.python_version(), platform.platform()) - payload['ua'] = "Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14" - - try: - data = urllib.parse.urlencode(payload).encode() - connection = http.client.HTTPSConnection('www.google-analytics.com', port=443, key_file=None, cert_file=None, timeout=1) - connection.request('POST', '/collect', data) - response = connection.getresponse() - except: - pass - -threading.Thread(target=__send_google_analytics_launch_event).start() - - - - XRAYLIB_MAJOR = xrl.XRAYLIB_MAJOR XRAYLIB_MINOR = xrl.XRAYLIB_MINOR AVOGNUM = xrl.AVOGNUM diff --git a/src/xraylib.i b/src/xraylib.i index 82f9bfea..562c524a 100644 --- a/src/xraylib.i +++ b/src/xraylib.i @@ -36,87 +36,6 @@ THIS SOFTWARE IS PROVIDED BY Bruno Golosio, Antonio Brunetti, Manuel Sanchez del #ifdef SWIGPYTHON %pythoncode { __version__ = VERSION - -import urllib -import os -import http.client -import uuid -from uuid import UUID -import platform -from pathlib import Path -import threading - -def __valid_uuid(_uuid): - try: - a = UUID(_uuid) - except ValueError: - return False - return True - -def __send_google_analytics_launch_event(): - GOOGLE_ANALYTICS_ENDPOINT = "https://www.google-analytics.com/collect" - GOOGLE_ANALYTICS_TRACKING_ID = "UA-42595764-5" - GOOGLE_ANALYTICS_APPLICATION_NAME = "xraylib" - GOOGLE_ANALYTICS_APPLICATION_VERSION = __version__ - GOOGLE_ANALYTICS_HIT_TYPE = "event" - - payload = dict( - v=1, # protocol version - tid=GOOGLE_ANALYTICS_TRACKING_ID, # tracking id - t=GOOGLE_ANALYTICS_HIT_TYPE, # hit type - an=GOOGLE_ANALYTICS_APPLICATION_NAME, # app name - av=GOOGLE_ANALYTICS_APPLICATION_VERSION, # app version - ) - - if 'CI' in os.environ: - payload['cid'] = '60220817-0a15-49ce-b581-9cab2b225e7d' # our default UUID for CI - payload['ec'] = 'CI-python' - else: - if os.name == 'nt': - import winreg - with winreg.CreateKey(winreg.HKEY_CURRENT_USER, r'Software\xraylib\ga_conf') as _key: - try: - _uuid = winreg.QueryValueEx(_key, 'uuid')[0] - if not __valid_uuid(_uuid): - raise Exception("Invalid UUID") - except Exception as e: - _uuid = str(uuid.uuid4()) - winreg.SetValueEx(_key, 'uuid', 0, winreg.REG_SZ, _uuid) - else: - try: - f = Path('~', '.config', 'xraylib', 'ga.conf').expanduser() - f.parent.mkdir(mode=0o700, parents=True, exist_ok=True) - if f.exists(): - if f.is_file(): - _uuid = f.read_text().strip() - if not __valid_uuid(_uuid): - _uuid = str(uuid.uuid4()) - f.write_text(_uuid) - else: - return - else: - _uuid = str(uuid.uuid4()) - f.write_text(_uuid) - except: - pass - - payload['cid'] = _uuid - payload['ec'] = 'python' - - payload['ea'] = 'import' - payload['el'] = 'xraylib-{}-Python-{}-{}'.format(__version__, platform.python_version(), platform.platform()) - payload['ua'] = "Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14" - - try: - data = urllib.parse.urlencode(payload).encode() - connection = http.client.HTTPSConnection('www.google-analytics.com', port=443, key_file=None, cert_file=None, timeout=1) - connection.request('POST', '/collect', data) - response = connection.getresponse() - except: - pass - -threading.Thread(target=__send_google_analytics_launch_event).start() - } #endif