From c0abd19dda895abd0d9b84dfa2ae3f6d0a94afd2 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 20:49:42 +0200 Subject: [PATCH 01/32] remove unnecessary files --- .codeclimate.yml | 17 ----------------- misc/pytest_migration/convert_pytest.sh | 19 ------------------- package.json | 16 ---------------- requirements.txt | 1 - 4 files changed, 53 deletions(-) delete mode 100644 .codeclimate.yml delete mode 100644 misc/pytest_migration/convert_pytest.sh delete mode 100644 package.json delete mode 100644 requirements.txt diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index 56e96001..00000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,17 +0,0 @@ -engines: - pep8: - enabled: true - checks: - E501: - enabled: false - E402: - enabled: false -ratings: - paths: - - "**.py" -exclude_paths: -- versioneer.py -- efel/_version.py -- docs/source/conf.py -- efel/tests -- examples diff --git a/misc/pytest_migration/convert_pytest.sh b/misc/pytest_migration/convert_pytest.sh deleted file mode 100644 index 78e7a700..00000000 --- a/misc/pytest_migration/convert_pytest.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -cd efel/tests - -declare -a StringArray=("./") - -for dir in ${StringArray[@]} -do - sed -i'' 's/nt.assert_raises/pytest.raises/g' $dir*.py - sed -i'' 's/nt.ok_/nt.assert_true/g' $dir*.py - sed -i'' 's/nt.eq_/nt.assert_equal/g' $dir*.py - sed -i'' 's/nt.assert/assert/g' $dir*.py - sed -i'' 's/nt.assert_almost_equal/numpy.testing.assert_allclose/g' $dir*.py - sed -i'' 's/places=/rtol=0, atol=1e-/g' $dir*.py - sed -i'' 's/@nt.raises(/@pytest.mark.xfail(raises=/g' $dir*.py - sed -i'' 's/import nose.tools as nt//g' $dir*.py -done - -nose2pytest -v . \ No newline at end of file diff --git a/package.json b/package.json deleted file mode 100644 index 25851287..00000000 --- a/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "eFEL", - "description": "The Electrophys Feature Extraction Library (eFEL) allows neuroscientists to automatically extract features from time series data recorded from neurons (both in vitro and in silico).", - "version": "2.12.0", - "scripts": { - "build_doc": "echo 'efel.readthedocs.io'" - }, - "repository": { - "type": "git", - "url": "https://github.com/BlueBrain/eFEL/releases", - "issuesurl": "https://github.com/BlueBrain/eFEL/issues" - }, - "author": "Werner Van Geit (werner.vangeit@epfl.ch)", - "contributors": ["Ruben Moor", "Rajnish Ranjan", "Luis Riquelme", "Christian Roessert", "Werner Van Geit"], - "license": "LGPL/BSD" -} diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index d6e1198b..00000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ --e . From accabbb65a474cd469e85666ce23e1d077e36164 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 20:58:28 +0200 Subject: [PATCH 02/32] remove builddist --- setup.cfg | 4 ---- 1 file changed, 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index 9d2ff1f4..2c02cf5c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,7 +10,3 @@ versionfile_source = efel/_version.py versionfile_build = efel/_version.py tag_prefix = parentdir_prefix = - -# Package support both python 2.6 and 2.7 -[bdist_wheel] -universal = 1 From b024c55a82128544610be3a3276bde6a3f44e4a9 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 21:00:06 +0200 Subject: [PATCH 03/32] remove py37 from test.yml --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0377980c..b766420a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v2 @@ -26,7 +26,7 @@ jobs: pip install tox tox-gh-actions - name: Run tox - run: tox + run: tox # since python-version is set above it calls py3-etc. not docs - name: "Upload coverage to Codecov" uses: codecov/codecov-action@v2 From 438dfe4c6b448b327deaefbfe632b0732af9e3cd Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 21:03:57 +0200 Subject: [PATCH 04/32] simplify setup.py --- setup.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/setup.py b/setup.py index 8596415a..596406c9 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,5 @@ """ eFEL setup """ -# pylint: disable=C0325 - """ Copyright (c) 2015, EPFL/Blue Brain Project @@ -21,10 +19,8 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. """ -try: - from setuptools import setup, Extension -except ImportError: - from distutils.core import setup, Extension # pylint: disable=E0611,F0401 + +from setuptools import setup, Extension import os import versioneer @@ -74,7 +70,7 @@ name="efel", version=versioneer.get_version(), cmdclass=versioneer.get_cmdclass(), - install_requires=['numpy>=1.6', 'six'], + install_requires=['numpy>=1.6'], extras_require={'neo': ['neo[neomatlabio]>=0.5.1']}, packages=['efel', 'efel.pyfeatures', 'efel.units'], author="BlueBrain Project, EPFL", @@ -90,11 +86,11 @@ "features to be calculated. The library will then extract the requested " "features and return the values to the user.", license="LGPLv3", - keywords=( + keywords=[ 'feature', 'extraction', 'electrophysiology', - 'BlueBrainProject'), + 'BlueBrainProject'], url='https://github.com/BlueBrain/eFEL', classifiers=[ 'Development Status :: 4 - Beta', @@ -108,8 +104,6 @@ 'Topic :: Utilities'], package_data={ '': ['DependencyV5.txt', - 'VERSION.txt', 'README.md', - 'GITHASH.txt', 'units/units.json'] + cppcore_headers}, ext_modules=[cppcore]) From 2bd6c759e465b24185e66fb277b11a636000f754 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 17:31:13 +0200 Subject: [PATCH 05/32] remove unused passenv in tox --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index e0142909..584cb144 100644 --- a/tox.ini +++ b/tox.ini @@ -22,7 +22,6 @@ allowlist_externals = find extras = neo -passenv = https_proxy commands = make clean From 356df25b041f821044f144d6a22e6234fc0a43cb Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 18:14:18 +0200 Subject: [PATCH 06/32] move tests out of package --- {efel/tests => tests}/.gitignore | 0 .../DependencyV5_LibV4peakindices.txt | 0 {efel/tests => tests}/diff_expected_results.png | Bin {efel/tests => tests}/featurenames.json | 0 {efel/tests => tests}/log/.gitignore | 0 .../neo_test_files/create_neo_files.py | 0 .../neo_test_files/neo_test_file_epoch_times.mat | Bin .../neo_test_files/neo_test_file_events_time.mat | Bin .../neo_test_file_events_time_incomplete.mat | Bin .../neo_test_files/neo_test_file_no_times.mat | Bin {efel/tests => tests}/plot_expectedresults_diff.py | 0 {efel/tests => tests}/test_allfeatures.py | 0 {efel/tests => tests}/test_basic.py | 0 {efel/tests => tests}/test_cppcore.py | 0 {efel/tests => tests}/test_io.py | 0 {efel/tests => tests}/test_pyfeatures.py | 0 {efel/tests => tests}/test_units.py | 0 .../tests => tests}/testdata/allfeatures/convert.py | 0 .../testdata/allfeatures/expectedresults.json | 0 .../testdata/allfeatures/testbacdata.txt | 0 .../testdata/allfeatures/testbap1data.txt | 0 .../testdata/allfeatures/testbap2data.txt | 0 .../testdata/allfeatures/testdata.txt | 0 .../testdata/allfeatures/testdb1data.txt | 0 .../testdata/allfeatures/testdb2data.txt | 0 .../testdata/allfeatures/testdb3data.txt | 0 .../testdata/allfeatures/testdbdata.txt | 0 .../basic/AP_begin_indices_95810005.abf.csv | 0 {efel/tests => tests}/testdata/basic/ahptest_1.txt | 0 {efel/tests => tests}/testdata/basic/current.txt | 0 .../tests => tests}/testdata/basic/dendritic_AP.txt | 0 .../tests => tests}/testdata/basic/derivwindow.txt | 0 .../tests => tests}/testdata/basic/init_burst1.txt | 0 .../tests => tests}/testdata/basic/init_burst2.txt | 0 .../tests => tests}/testdata/basic/init_burst3.txt | 0 .../testdata/basic/initburst_sahp_error.txt | 0 .../testdata/basic/mean_frequency_1.txt | 0 .../testdata/basic/min_AHP_values_single_peak.txt | 0 {efel/tests => tests}/testdata/basic/sagtrace_1.txt | 0 .../testdata/basic/spike_outside_stim.txt | 0 .../basic/spiking_from_beginning_to_end.txt | 0 {efel/tests => tests}/testdata/basic/tau20.0.csv | 0 .../basic/zero_ISI_log_slope_skip95824004.abf.csv | 0 {efel/tests => tests}/update_expectedresults.py | 0 {efel/tests => tests}/update_featurenames.py | 0 45 files changed, 0 insertions(+), 0 deletions(-) rename {efel/tests => tests}/.gitignore (100%) rename {efel/tests => tests}/DependencyV5_LibV4peakindices.txt (100%) rename {efel/tests => tests}/diff_expected_results.png (100%) rename {efel/tests => tests}/featurenames.json (100%) rename {efel/tests => tests}/log/.gitignore (100%) rename {efel/tests => tests}/neo_test_files/create_neo_files.py (100%) rename {efel/tests => tests}/neo_test_files/neo_test_file_epoch_times.mat (100%) rename {efel/tests => tests}/neo_test_files/neo_test_file_events_time.mat (100%) rename {efel/tests => tests}/neo_test_files/neo_test_file_events_time_incomplete.mat (100%) rename {efel/tests => tests}/neo_test_files/neo_test_file_no_times.mat (100%) rename {efel/tests => tests}/plot_expectedresults_diff.py (100%) rename {efel/tests => tests}/test_allfeatures.py (100%) rename {efel/tests => tests}/test_basic.py (100%) rename {efel/tests => tests}/test_cppcore.py (100%) rename {efel/tests => tests}/test_io.py (100%) rename {efel/tests => tests}/test_pyfeatures.py (100%) rename {efel/tests => tests}/test_units.py (100%) rename {efel/tests => tests}/testdata/allfeatures/convert.py (100%) rename {efel/tests => tests}/testdata/allfeatures/expectedresults.json (100%) rename {efel/tests => tests}/testdata/allfeatures/testbacdata.txt (100%) rename {efel/tests => tests}/testdata/allfeatures/testbap1data.txt (100%) rename {efel/tests => tests}/testdata/allfeatures/testbap2data.txt (100%) rename {efel/tests => tests}/testdata/allfeatures/testdata.txt (100%) rename {efel/tests => tests}/testdata/allfeatures/testdb1data.txt (100%) rename {efel/tests => tests}/testdata/allfeatures/testdb2data.txt (100%) rename {efel/tests => tests}/testdata/allfeatures/testdb3data.txt (100%) rename {efel/tests => tests}/testdata/allfeatures/testdbdata.txt (100%) rename {efel/tests => tests}/testdata/basic/AP_begin_indices_95810005.abf.csv (100%) rename {efel/tests => tests}/testdata/basic/ahptest_1.txt (100%) rename {efel/tests => tests}/testdata/basic/current.txt (100%) rename {efel/tests => tests}/testdata/basic/dendritic_AP.txt (100%) rename {efel/tests => tests}/testdata/basic/derivwindow.txt (100%) rename {efel/tests => tests}/testdata/basic/init_burst1.txt (100%) rename {efel/tests => tests}/testdata/basic/init_burst2.txt (100%) rename {efel/tests => tests}/testdata/basic/init_burst3.txt (100%) rename {efel/tests => tests}/testdata/basic/initburst_sahp_error.txt (100%) rename {efel/tests => tests}/testdata/basic/mean_frequency_1.txt (100%) rename {efel/tests => tests}/testdata/basic/min_AHP_values_single_peak.txt (100%) rename {efel/tests => tests}/testdata/basic/sagtrace_1.txt (100%) rename {efel/tests => tests}/testdata/basic/spike_outside_stim.txt (100%) rename {efel/tests => tests}/testdata/basic/spiking_from_beginning_to_end.txt (100%) rename {efel/tests => tests}/testdata/basic/tau20.0.csv (100%) rename {efel/tests => tests}/testdata/basic/zero_ISI_log_slope_skip95824004.abf.csv (100%) rename {efel/tests => tests}/update_expectedresults.py (100%) rename {efel/tests => tests}/update_featurenames.py (100%) diff --git a/efel/tests/.gitignore b/tests/.gitignore similarity index 100% rename from efel/tests/.gitignore rename to tests/.gitignore diff --git a/efel/tests/DependencyV5_LibV4peakindices.txt b/tests/DependencyV5_LibV4peakindices.txt similarity index 100% rename from efel/tests/DependencyV5_LibV4peakindices.txt rename to tests/DependencyV5_LibV4peakindices.txt diff --git a/efel/tests/diff_expected_results.png b/tests/diff_expected_results.png similarity index 100% rename from efel/tests/diff_expected_results.png rename to tests/diff_expected_results.png diff --git a/efel/tests/featurenames.json b/tests/featurenames.json similarity index 100% rename from efel/tests/featurenames.json rename to tests/featurenames.json diff --git a/efel/tests/log/.gitignore b/tests/log/.gitignore similarity index 100% rename from efel/tests/log/.gitignore rename to tests/log/.gitignore diff --git a/efel/tests/neo_test_files/create_neo_files.py b/tests/neo_test_files/create_neo_files.py similarity index 100% rename from efel/tests/neo_test_files/create_neo_files.py rename to tests/neo_test_files/create_neo_files.py diff --git a/efel/tests/neo_test_files/neo_test_file_epoch_times.mat b/tests/neo_test_files/neo_test_file_epoch_times.mat similarity index 100% rename from efel/tests/neo_test_files/neo_test_file_epoch_times.mat rename to tests/neo_test_files/neo_test_file_epoch_times.mat diff --git a/efel/tests/neo_test_files/neo_test_file_events_time.mat b/tests/neo_test_files/neo_test_file_events_time.mat similarity index 100% rename from efel/tests/neo_test_files/neo_test_file_events_time.mat rename to tests/neo_test_files/neo_test_file_events_time.mat diff --git a/efel/tests/neo_test_files/neo_test_file_events_time_incomplete.mat b/tests/neo_test_files/neo_test_file_events_time_incomplete.mat similarity index 100% rename from efel/tests/neo_test_files/neo_test_file_events_time_incomplete.mat rename to tests/neo_test_files/neo_test_file_events_time_incomplete.mat diff --git a/efel/tests/neo_test_files/neo_test_file_no_times.mat b/tests/neo_test_files/neo_test_file_no_times.mat similarity index 100% rename from efel/tests/neo_test_files/neo_test_file_no_times.mat rename to tests/neo_test_files/neo_test_file_no_times.mat diff --git a/efel/tests/plot_expectedresults_diff.py b/tests/plot_expectedresults_diff.py similarity index 100% rename from efel/tests/plot_expectedresults_diff.py rename to tests/plot_expectedresults_diff.py diff --git a/efel/tests/test_allfeatures.py b/tests/test_allfeatures.py similarity index 100% rename from efel/tests/test_allfeatures.py rename to tests/test_allfeatures.py diff --git a/efel/tests/test_basic.py b/tests/test_basic.py similarity index 100% rename from efel/tests/test_basic.py rename to tests/test_basic.py diff --git a/efel/tests/test_cppcore.py b/tests/test_cppcore.py similarity index 100% rename from efel/tests/test_cppcore.py rename to tests/test_cppcore.py diff --git a/efel/tests/test_io.py b/tests/test_io.py similarity index 100% rename from efel/tests/test_io.py rename to tests/test_io.py diff --git a/efel/tests/test_pyfeatures.py b/tests/test_pyfeatures.py similarity index 100% rename from efel/tests/test_pyfeatures.py rename to tests/test_pyfeatures.py diff --git a/efel/tests/test_units.py b/tests/test_units.py similarity index 100% rename from efel/tests/test_units.py rename to tests/test_units.py diff --git a/efel/tests/testdata/allfeatures/convert.py b/tests/testdata/allfeatures/convert.py similarity index 100% rename from efel/tests/testdata/allfeatures/convert.py rename to tests/testdata/allfeatures/convert.py diff --git a/efel/tests/testdata/allfeatures/expectedresults.json b/tests/testdata/allfeatures/expectedresults.json similarity index 100% rename from efel/tests/testdata/allfeatures/expectedresults.json rename to tests/testdata/allfeatures/expectedresults.json diff --git a/efel/tests/testdata/allfeatures/testbacdata.txt b/tests/testdata/allfeatures/testbacdata.txt similarity index 100% rename from efel/tests/testdata/allfeatures/testbacdata.txt rename to tests/testdata/allfeatures/testbacdata.txt diff --git a/efel/tests/testdata/allfeatures/testbap1data.txt b/tests/testdata/allfeatures/testbap1data.txt similarity index 100% rename from efel/tests/testdata/allfeatures/testbap1data.txt rename to tests/testdata/allfeatures/testbap1data.txt diff --git a/efel/tests/testdata/allfeatures/testbap2data.txt b/tests/testdata/allfeatures/testbap2data.txt similarity index 100% rename from efel/tests/testdata/allfeatures/testbap2data.txt rename to tests/testdata/allfeatures/testbap2data.txt diff --git a/efel/tests/testdata/allfeatures/testdata.txt b/tests/testdata/allfeatures/testdata.txt similarity index 100% rename from efel/tests/testdata/allfeatures/testdata.txt rename to tests/testdata/allfeatures/testdata.txt diff --git a/efel/tests/testdata/allfeatures/testdb1data.txt b/tests/testdata/allfeatures/testdb1data.txt similarity index 100% rename from efel/tests/testdata/allfeatures/testdb1data.txt rename to tests/testdata/allfeatures/testdb1data.txt diff --git a/efel/tests/testdata/allfeatures/testdb2data.txt b/tests/testdata/allfeatures/testdb2data.txt similarity index 100% rename from efel/tests/testdata/allfeatures/testdb2data.txt rename to tests/testdata/allfeatures/testdb2data.txt diff --git a/efel/tests/testdata/allfeatures/testdb3data.txt b/tests/testdata/allfeatures/testdb3data.txt similarity index 100% rename from efel/tests/testdata/allfeatures/testdb3data.txt rename to tests/testdata/allfeatures/testdb3data.txt diff --git a/efel/tests/testdata/allfeatures/testdbdata.txt b/tests/testdata/allfeatures/testdbdata.txt similarity index 100% rename from efel/tests/testdata/allfeatures/testdbdata.txt rename to tests/testdata/allfeatures/testdbdata.txt diff --git a/efel/tests/testdata/basic/AP_begin_indices_95810005.abf.csv b/tests/testdata/basic/AP_begin_indices_95810005.abf.csv similarity index 100% rename from efel/tests/testdata/basic/AP_begin_indices_95810005.abf.csv rename to tests/testdata/basic/AP_begin_indices_95810005.abf.csv diff --git a/efel/tests/testdata/basic/ahptest_1.txt b/tests/testdata/basic/ahptest_1.txt similarity index 100% rename from efel/tests/testdata/basic/ahptest_1.txt rename to tests/testdata/basic/ahptest_1.txt diff --git a/efel/tests/testdata/basic/current.txt b/tests/testdata/basic/current.txt similarity index 100% rename from efel/tests/testdata/basic/current.txt rename to tests/testdata/basic/current.txt diff --git a/efel/tests/testdata/basic/dendritic_AP.txt b/tests/testdata/basic/dendritic_AP.txt similarity index 100% rename from efel/tests/testdata/basic/dendritic_AP.txt rename to tests/testdata/basic/dendritic_AP.txt diff --git a/efel/tests/testdata/basic/derivwindow.txt b/tests/testdata/basic/derivwindow.txt similarity index 100% rename from efel/tests/testdata/basic/derivwindow.txt rename to tests/testdata/basic/derivwindow.txt diff --git a/efel/tests/testdata/basic/init_burst1.txt b/tests/testdata/basic/init_burst1.txt similarity index 100% rename from efel/tests/testdata/basic/init_burst1.txt rename to tests/testdata/basic/init_burst1.txt diff --git a/efel/tests/testdata/basic/init_burst2.txt b/tests/testdata/basic/init_burst2.txt similarity index 100% rename from efel/tests/testdata/basic/init_burst2.txt rename to tests/testdata/basic/init_burst2.txt diff --git a/efel/tests/testdata/basic/init_burst3.txt b/tests/testdata/basic/init_burst3.txt similarity index 100% rename from efel/tests/testdata/basic/init_burst3.txt rename to tests/testdata/basic/init_burst3.txt diff --git a/efel/tests/testdata/basic/initburst_sahp_error.txt b/tests/testdata/basic/initburst_sahp_error.txt similarity index 100% rename from efel/tests/testdata/basic/initburst_sahp_error.txt rename to tests/testdata/basic/initburst_sahp_error.txt diff --git a/efel/tests/testdata/basic/mean_frequency_1.txt b/tests/testdata/basic/mean_frequency_1.txt similarity index 100% rename from efel/tests/testdata/basic/mean_frequency_1.txt rename to tests/testdata/basic/mean_frequency_1.txt diff --git a/efel/tests/testdata/basic/min_AHP_values_single_peak.txt b/tests/testdata/basic/min_AHP_values_single_peak.txt similarity index 100% rename from efel/tests/testdata/basic/min_AHP_values_single_peak.txt rename to tests/testdata/basic/min_AHP_values_single_peak.txt diff --git a/efel/tests/testdata/basic/sagtrace_1.txt b/tests/testdata/basic/sagtrace_1.txt similarity index 100% rename from efel/tests/testdata/basic/sagtrace_1.txt rename to tests/testdata/basic/sagtrace_1.txt diff --git a/efel/tests/testdata/basic/spike_outside_stim.txt b/tests/testdata/basic/spike_outside_stim.txt similarity index 100% rename from efel/tests/testdata/basic/spike_outside_stim.txt rename to tests/testdata/basic/spike_outside_stim.txt diff --git a/efel/tests/testdata/basic/spiking_from_beginning_to_end.txt b/tests/testdata/basic/spiking_from_beginning_to_end.txt similarity index 100% rename from efel/tests/testdata/basic/spiking_from_beginning_to_end.txt rename to tests/testdata/basic/spiking_from_beginning_to_end.txt diff --git a/efel/tests/testdata/basic/tau20.0.csv b/tests/testdata/basic/tau20.0.csv similarity index 100% rename from efel/tests/testdata/basic/tau20.0.csv rename to tests/testdata/basic/tau20.0.csv diff --git a/efel/tests/testdata/basic/zero_ISI_log_slope_skip95824004.abf.csv b/tests/testdata/basic/zero_ISI_log_slope_skip95824004.abf.csv similarity index 100% rename from efel/tests/testdata/basic/zero_ISI_log_slope_skip95824004.abf.csv rename to tests/testdata/basic/zero_ISI_log_slope_skip95824004.abf.csv diff --git a/efel/tests/update_expectedresults.py b/tests/update_expectedresults.py similarity index 100% rename from efel/tests/update_expectedresults.py rename to tests/update_expectedresults.py diff --git a/efel/tests/update_featurenames.py b/tests/update_featurenames.py similarity index 100% rename from efel/tests/update_featurenames.py rename to tests/update_featurenames.py From 88b16d6c8b529dbb4f6fce98ec4c04c65146a651 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 18:19:23 +0200 Subject: [PATCH 07/32] update Makefile --- Makefile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 33a9a9a1..ad6498cb 100644 --- a/Makefile +++ b/Makefile @@ -33,19 +33,13 @@ update_version: git add GITHASH.txt && \ git add VERSION.txt && \ git commit -m 'Updated version number' -test: virtualenv install install_test_requirements - cd efel/tests; nosetests -s -v -x --with-coverage --cover-xml \ - --cover-package efel -debugtest: virtualenv install install_test_requirements - cd efel/tests; nosetests -a debugtest -s -v -x --with-coverage --cover-xml \ - --cover-package efel pypi: test pip install twine --upgrade rm -rf dist python setup.py sdist bdist twine upload dist/* clean: - rm -rf efel/tests/log/fllog.txt + rm -rf tests/log/fllog.txt rm -rf build_cmake rm -rf build rm -rf docs/build From 740b55a89ccd85df7c28afd1220b62c835026943 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 18:21:11 +0200 Subject: [PATCH 08/32] update Makefile remove old nosetest commands --- Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Makefile b/Makefile index ad6498cb..496fee4e 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,3 @@ -TEST_REQUIREMENTS=nose coverage virtualenv - all: install install: clean python setup.py sdist @@ -25,8 +23,6 @@ doc_upload: doc git commit -m "Updating docs" && \ git push "git@github.com:BlueBrain/eFEL.git" master:gh-pages --force && \ rm -rf .git -install_test_requirements: - pip install -q $(TEST_REQUIREMENTS) --upgrade update_version: cd efel && \ python -c 'import version; version._get_version_number()' && \ From 15d05aa51fb9125262677b612cfb0ceae3e83008 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 18:49:28 +0200 Subject: [PATCH 09/32] delete .codeclimate.yml --- efel/__init__.py | 5 +- efel/_version.py | 336 +++++++++++++++++++++++++++++++++-------------- 2 files changed, 242 insertions(+), 99 deletions(-) diff --git a/efel/__init__.py b/efel/__init__.py index b4337e1e..60e72ea9 100644 --- a/efel/__init__.py +++ b/efel/__init__.py @@ -23,6 +23,5 @@ from efel.api import * import efel.io -from ._version import get_versions -__version__ = get_versions()['version'] -del get_versions +from . import _version +__version__ = _version.get_versions()['version'] diff --git a/efel/_version.py b/efel/_version.py index 1b9f0236..8be97b39 100644 --- a/efel/_version.py +++ b/efel/_version.py @@ -5,8 +5,9 @@ # directories (produced by setup.py build) will contain a much shorter file # that just contains the computed version number. -# This file is released into the public domain. Generated by -# versioneer-0.18 (https://github.com/warner/python-versioneer) +# This file is released into the public domain. +# Generated by versioneer-0.29 +# https://github.com/python-versioneer/python-versioneer """Git implementation of _version.py.""" @@ -15,9 +16,11 @@ import re import subprocess import sys +from typing import Any, Callable, Dict, List, Optional, Tuple +import functools -def get_keywords(): +def get_keywords() -> Dict[str, str]: """Get the keywords needed to look up the version information.""" # these strings will be replaced by git during git-archive. # setup.py/versioneer.py will grep for the variable names, so they must @@ -33,8 +36,15 @@ def get_keywords(): class VersioneerConfig: """Container for Versioneer configuration parameters.""" + VCS: str + style: str + tag_prefix: str + parentdir_prefix: str + versionfile_source: str + verbose: bool -def get_config(): + +def get_config() -> VersioneerConfig: """Create, populate and return the VersioneerConfig() object.""" # these strings are filled in when 'setup.py versioneer' creates # _version.py @@ -43,7 +53,7 @@ def get_config(): cfg.style = "pep440-minor" cfg.tag_prefix = "" cfg.parentdir_prefix = "" - cfg.versionfile_source = "bluepyopt/_version.py" + cfg.versionfile_source = "efel/_version.py" cfg.verbose = False return cfg @@ -52,13 +62,13 @@ class NotThisMethod(Exception): """Exception raised if a method is not valid for the current scenario.""" -LONG_VERSION_PY = {} -HANDLERS = {} +LONG_VERSION_PY: Dict[str, str] = {} +HANDLERS: Dict[str, Dict[str, Callable]] = {} -def register_vcs_handler(vcs, method): # decorator - """Decorator to mark a method as the handler for a particular VCS.""" - def decorate(f): +def register_vcs_handler(vcs: str, method: str) -> Callable: # decorator + """Create decorator to mark a method as the handler of a VCS.""" + def decorate(f: Callable) -> Callable: """Store f in HANDLERS[vcs][method].""" if vcs not in HANDLERS: HANDLERS[vcs] = {} @@ -67,22 +77,35 @@ def decorate(f): return decorate -def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, - env=None): +def run_command( + commands: List[str], + args: List[str], + cwd: Optional[str] = None, + verbose: bool = False, + hide_stderr: bool = False, + env: Optional[Dict[str, str]] = None, +) -> Tuple[Optional[str], Optional[int]]: """Call the given command(s).""" assert isinstance(commands, list) - p = None - for c in commands: + process = None + + popen_kwargs: Dict[str, Any] = {} + if sys.platform == "win32": + # This hides the console window if pythonw.exe is used + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + popen_kwargs["startupinfo"] = startupinfo + + for command in commands: try: - dispcmd = str([c] + args) + dispcmd = str([command] + args) # remember shell=False, so use git.cmd on windows, not just git - p = subprocess.Popen([c] + args, cwd=cwd, env=env, - stdout=subprocess.PIPE, - stderr=(subprocess.PIPE if hide_stderr - else None)) + process = subprocess.Popen([command] + args, cwd=cwd, env=env, + stdout=subprocess.PIPE, + stderr=(subprocess.PIPE if hide_stderr + else None), **popen_kwargs) break - except EnvironmentError: - e = sys.exc_info()[1] + except OSError as e: if e.errno == errno.ENOENT: continue if verbose: @@ -93,18 +116,20 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, if verbose: print("unable to find command, tried %s" % (commands,)) return None, None - stdout = p.communicate()[0].strip() - if sys.version_info[0] >= 3: - stdout = stdout.decode() - if p.returncode != 0: + stdout = process.communicate()[0].strip().decode() + if process.returncode != 0: if verbose: print("unable to run %s (error)" % dispcmd) print("stdout was %s" % stdout) - return None, p.returncode - return stdout, p.returncode + return None, process.returncode + return stdout, process.returncode -def versions_from_parentdir(parentdir_prefix, root, verbose): +def versions_from_parentdir( + parentdir_prefix: str, + root: str, + verbose: bool, +) -> Dict[str, Any]: """Try to determine the version from the parent directory name. Source tarballs conventionally unpack into a directory that includes both @@ -113,15 +138,14 @@ def versions_from_parentdir(parentdir_prefix, root, verbose): """ rootdirs = [] - for i in range(3): + for _ in range(3): dirname = os.path.basename(root) if dirname.startswith(parentdir_prefix): return {"version": dirname[len(parentdir_prefix):], "full-revisionid": None, "dirty": False, "error": None, "date": None} - else: - rootdirs.append(root) - root = os.path.dirname(root) # up a level + rootdirs.append(root) + root = os.path.dirname(root) # up a level if verbose: print("Tried directories %s but none started with prefix %s" % @@ -130,41 +154,48 @@ def versions_from_parentdir(parentdir_prefix, root, verbose): @register_vcs_handler("git", "get_keywords") -def git_get_keywords(versionfile_abs): +def git_get_keywords(versionfile_abs: str) -> Dict[str, str]: """Extract version information from the given file.""" # the code embedded in _version.py can just fetch the value of these # keywords. When used from setup.py, we don't want to import _version.py, # so we do it with a regexp instead. This function is not used from # _version.py. - keywords = {} + keywords: Dict[str, str] = {} try: - f = open(versionfile_abs, "r") - for line in f.readlines(): - if line.strip().startswith("git_refnames ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["refnames"] = mo.group(1) - if line.strip().startswith("git_full ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["full"] = mo.group(1) - if line.strip().startswith("git_date ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["date"] = mo.group(1) - f.close() - except EnvironmentError: + with open(versionfile_abs, "r") as fobj: + for line in fobj: + if line.strip().startswith("git_refnames ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["refnames"] = mo.group(1) + if line.strip().startswith("git_full ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["full"] = mo.group(1) + if line.strip().startswith("git_date ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["date"] = mo.group(1) + except OSError: pass return keywords @register_vcs_handler("git", "keywords") -def git_versions_from_keywords(keywords, tag_prefix, verbose): +def git_versions_from_keywords( + keywords: Dict[str, str], + tag_prefix: str, + verbose: bool, +) -> Dict[str, Any]: """Get version information from git keywords.""" - if not keywords: - raise NotThisMethod("no keywords at all, weird") + if "refnames" not in keywords: + raise NotThisMethod("Short version file found") date = keywords.get("date") if date is not None: + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 # -like" string, which we must then edit to make compliant), because @@ -177,11 +208,11 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose): if verbose: print("keywords are unexpanded, not using") raise NotThisMethod("unexpanded keywords, not a git-archive tarball") - refs = set([r.strip() for r in refnames.strip("()").split(",")]) + refs = {r.strip() for r in refnames.strip("()").split(",")} # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of # just "foo-1.0". If we see a "tag: " prefix, prefer those. TAG = "tag: " - tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)]) + tags = {r[len(TAG):] for r in refs if r.startswith(TAG)} if not tags: # Either we're using git < 1.8.3, or there really are no tags. We use # a heuristic: assume all version tags have a digit. The old git %d @@ -190,7 +221,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose): # between branches and tags. By ignoring refnames without digits, we # filter out many common branch names like "release" and # "stabilization", as well as "HEAD" and "master". - tags = set([r for r in refs if re.search(r'\d', r)]) + tags = {r for r in refs if re.search(r'\d', r)} if verbose: print("discarding '%s', no digits" % ",".join(refs - tags)) if verbose: @@ -199,6 +230,11 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose): # sorting will prefer e.g. "2.0" over "2.0rc1" if ref.startswith(tag_prefix): r = ref[len(tag_prefix):] + # Filter out refs that exactly match prefix or that don't start + # with a number once the prefix is stripped (mostly a concern + # when prefix is '') + if not re.match(r'\d', r): + continue if verbose: print("picking %s" % r) return {"version": r, @@ -214,7 +250,12 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose): @register_vcs_handler("git", "pieces_from_vcs") -def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): +def git_pieces_from_vcs( + tag_prefix: str, + root: str, + verbose: bool, + runner: Callable = run_command +) -> Dict[str, Any]: """Get version from 'git describe' in the root of the source tree. This only gets called if the git-archive 'subst' keywords were *not* @@ -225,8 +266,15 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): if sys.platform == "win32": GITS = ["git.cmd", "git.exe"] - out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root, - hide_stderr=True) + # GIT_DIR can interfere with correct operation of Versioneer. + # It may be intended to be passed to the Versioneer-versioned project, + # but that should not change where we get our version from. + env = os.environ.copy() + env.pop("GIT_DIR", None) + runner = functools.partial(runner, env=env) + + _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root, + hide_stderr=not verbose) if rc != 0: if verbose: print("Directory %s not under git control" % root) @@ -234,24 +282,57 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] # if there isn't one, this yields HEX[-dirty] (no NUM) - describe_out, rc = run_command(GITS, ["describe", "--tags", "--dirty", - "--always", "--long", - "--match", "%s*" % tag_prefix], - cwd=root) + describe_out, rc = runner(GITS, [ + "describe", "--tags", "--dirty", "--always", "--long", + "--match", f"{tag_prefix}[[:digit:]]*" + ], cwd=root) # --long was added in git-1.5.5 if describe_out is None: raise NotThisMethod("'git describe' failed") describe_out = describe_out.strip() - full_out, rc = run_command(GITS, ["rev-parse", "HEAD"], cwd=root) + full_out, rc = runner(GITS, ["rev-parse", "HEAD"], cwd=root) if full_out is None: raise NotThisMethod("'git rev-parse' failed") full_out = full_out.strip() - pieces = {} + pieces: Dict[str, Any] = {} pieces["long"] = full_out pieces["short"] = full_out[:7] # maybe improved later pieces["error"] = None + branch_name, rc = runner(GITS, ["rev-parse", "--abbrev-ref", "HEAD"], + cwd=root) + # --abbrev-ref was added in git-1.6.3 + if rc != 0 or branch_name is None: + raise NotThisMethod("'git rev-parse --abbrev-ref' returned error") + branch_name = branch_name.strip() + + if branch_name == "HEAD": + # If we aren't exactly on a branch, pick a branch which represents + # the current commit. If all else fails, we are on a branchless + # commit. + branches, rc = runner(GITS, ["branch", "--contains"], cwd=root) + # --contains was added in git-1.5.4 + if rc != 0 or branches is None: + raise NotThisMethod("'git branch --contains' returned error") + branches = branches.split("\n") + + # Remove the first line if we're running detached + if "(" in branches[0]: + branches.pop(0) + + # Strip off the leading "* " from the list of branches. + branches = [branch[2:] for branch in branches] + if "master" in branches: + branch_name = "master" + elif not branches: + branch_name = None + else: + # Pick the first branch that is returned. Good or bad. + branch_name = branches[0] + + pieces["branch"] = branch_name + # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] # TAG might have hyphens. git_describe = describe_out @@ -268,7 +349,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): # TAG-NUM-gHEX mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe) if not mo: - # unparseable. Maybe git-describe is misbehaving? + # unparsable. Maybe git-describe is misbehaving? pieces["error"] = ("unable to parse git-describe output: '%s'" % describe_out) return pieces @@ -293,26 +374,27 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): else: # HEX: no tags pieces["closest-tag"] = None - count_out, rc = run_command(GITS, ["rev-list", "HEAD", "--count"], - cwd=root) - pieces["distance"] = int(count_out) # total number of commits + out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root) + pieces["distance"] = len(out.split()) # total number of commits # commit date: see ISO-8601 comment in git_versions_from_keywords() - date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"], - cwd=root)[0].strip() + date = runner(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip() + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) return pieces -def plus_or_dot(pieces): +def plus_or_dot(pieces: Dict[str, Any]) -> str: """Return a + if we don't already have one, else return a .""" if "+" in pieces.get("closest-tag", ""): return "." return "+" -def render_pep440(pieces): +def render_pep440(pieces: Dict[str, Any]) -> str: """Build up version string, with post-release "local version identifier". Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you @@ -337,40 +419,71 @@ def render_pep440(pieces): return rendered -def render_pep440_pre(pieces): - """TAG[.post.devDISTANCE] -- No -dirty. +def render_pep440_branch(pieces: Dict[str, Any]) -> str: + """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . + + The ".dev0" means not master branch. Note that .dev0 sorts backwards + (a feature branch will appear "older" than the master branch). Exceptions: - 1: no tags. 0.post.devDISTANCE + 1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty] """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] - if pieces["distance"]: - rendered += ".post.dev%d" % pieces["distance"] + if pieces["distance"] or pieces["dirty"]: + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" else: # exception #1 - rendered = "0.post.dev%d" % pieces["distance"] + rendered = "0" + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+untagged.%d.g%s" % (pieces["distance"], + pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" return rendered -def render_pep440_minor(pieces): - """TAG[.DISTANCE] . No -dirty +def pep440_split_post(ver: str) -> Tuple[str, Optional[int]]: + """Split pep440 version string at the post-release segment. - Exceptions: - 1: no tags. 0.DISTANCE + Returns the release segments before the post-release and the + post-release version number (or -1 if no post-release segment is present). """ + vc = str.split(ver, ".post") + return vc[0], int(vc[1] or 0) if len(vc) == 2 else None + +def render_pep440_pre(pieces: Dict[str, Any]) -> str: + """TAG[.postN.devDISTANCE] -- No -dirty. + + Exceptions: + 1: no tags. 0.post0.devDISTANCE + """ if pieces["closest-tag"]: - rendered = pieces["closest-tag"] if pieces["distance"]: - rendered += ".%d" % pieces["distance"] + # update the post release segment + tag_version, post_version = pep440_split_post(pieces["closest-tag"]) + rendered = tag_version + if post_version is not None: + rendered += ".post%d.dev%d" % (post_version + 1, pieces["distance"]) + else: + rendered += ".post0.dev%d" % (pieces["distance"]) + else: + # no commits, use the tag as the version + rendered = pieces["closest-tag"] else: # exception #1 - rendered = "0.%d" % pieces["distance"] + rendered = "0.post0.dev%d" % pieces["distance"] return rendered -def render_pep440_post(pieces): +def render_pep440_post(pieces: Dict[str, Any]) -> str: """TAG[.postDISTANCE[.dev0]+gHEX] . The ".dev0" means dirty. Note that .dev0 sorts backwards @@ -397,12 +510,41 @@ def render_pep440_post(pieces): return rendered -def render_pep440_old(pieces): +def render_pep440_post_branch(pieces: Dict[str, Any]) -> str: + """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . + + The ".dev0" means not master branch. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%s" % pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+g%s" % pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_old(pieces: Dict[str, Any]) -> str: """TAG[.postDISTANCE[.dev0]] . The ".dev0" means dirty. - Eexceptions: + Exceptions: 1: no tags. 0.postDISTANCE[.dev0] """ if pieces["closest-tag"]: @@ -419,7 +561,7 @@ def render_pep440_old(pieces): return rendered -def render_git_describe(pieces): +def render_git_describe(pieces: Dict[str, Any]) -> str: """TAG[-DISTANCE-gHEX][-dirty]. Like 'git describe --tags --dirty --always'. @@ -439,7 +581,7 @@ def render_git_describe(pieces): return rendered -def render_git_describe_long(pieces): +def render_git_describe_long(pieces: Dict[str, Any]) -> str: """TAG-DISTANCE-gHEX[-dirty]. Like 'git describe --tags --dirty --always -long'. @@ -459,7 +601,7 @@ def render_git_describe_long(pieces): return rendered -def render(pieces, style): +def render(pieces: Dict[str, Any], style: str) -> Dict[str, Any]: """Render the given version pieces into the requested style.""" if pieces["error"]: return {"version": "unknown", @@ -473,12 +615,14 @@ def render(pieces, style): if style == "pep440": rendered = render_pep440(pieces) + elif style == "pep440-branch": + rendered = render_pep440_branch(pieces) elif style == "pep440-pre": rendered = render_pep440_pre(pieces) - elif style == "pep440-minor": - rendered = render_pep440_minor(pieces) elif style == "pep440-post": rendered = render_pep440_post(pieces) + elif style == "pep440-post-branch": + rendered = render_pep440_post_branch(pieces) elif style == "pep440-old": rendered = render_pep440_old(pieces) elif style == "git-describe": @@ -493,7 +637,7 @@ def render(pieces, style): "date": pieces.get("date")} -def get_versions(): +def get_versions() -> Dict[str, Any]: """Get version information or return default if unable to do so.""" # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have # __file__, we can work backwards from there to the root. Some @@ -514,7 +658,7 @@ def get_versions(): # versionfile_source is the relative path from the top of the source # tree (where the .git directory might live) to this file. Invert # this to find the root from __file__. - for i in cfg.versionfile_source.split('/'): + for _ in cfg.versionfile_source.split('/'): root = os.path.dirname(root) except NameError: return {"version": "0+unknown", "full-revisionid": None, From 464d61eb37b68eb44c9e3c31ff8ab340354d5a14 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 19:04:01 +0200 Subject: [PATCH 10/32] stay with the old versioneer --- efel/_version.py | 336 ++++++++++++++--------------------------------- 1 file changed, 96 insertions(+), 240 deletions(-) diff --git a/efel/_version.py b/efel/_version.py index 8be97b39..1b9f0236 100644 --- a/efel/_version.py +++ b/efel/_version.py @@ -5,9 +5,8 @@ # directories (produced by setup.py build) will contain a much shorter file # that just contains the computed version number. -# This file is released into the public domain. -# Generated by versioneer-0.29 -# https://github.com/python-versioneer/python-versioneer +# This file is released into the public domain. Generated by +# versioneer-0.18 (https://github.com/warner/python-versioneer) """Git implementation of _version.py.""" @@ -16,11 +15,9 @@ import re import subprocess import sys -from typing import Any, Callable, Dict, List, Optional, Tuple -import functools -def get_keywords() -> Dict[str, str]: +def get_keywords(): """Get the keywords needed to look up the version information.""" # these strings will be replaced by git during git-archive. # setup.py/versioneer.py will grep for the variable names, so they must @@ -36,15 +33,8 @@ def get_keywords() -> Dict[str, str]: class VersioneerConfig: """Container for Versioneer configuration parameters.""" - VCS: str - style: str - tag_prefix: str - parentdir_prefix: str - versionfile_source: str - verbose: bool - -def get_config() -> VersioneerConfig: +def get_config(): """Create, populate and return the VersioneerConfig() object.""" # these strings are filled in when 'setup.py versioneer' creates # _version.py @@ -53,7 +43,7 @@ def get_config() -> VersioneerConfig: cfg.style = "pep440-minor" cfg.tag_prefix = "" cfg.parentdir_prefix = "" - cfg.versionfile_source = "efel/_version.py" + cfg.versionfile_source = "bluepyopt/_version.py" cfg.verbose = False return cfg @@ -62,13 +52,13 @@ class NotThisMethod(Exception): """Exception raised if a method is not valid for the current scenario.""" -LONG_VERSION_PY: Dict[str, str] = {} -HANDLERS: Dict[str, Dict[str, Callable]] = {} +LONG_VERSION_PY = {} +HANDLERS = {} -def register_vcs_handler(vcs: str, method: str) -> Callable: # decorator - """Create decorator to mark a method as the handler of a VCS.""" - def decorate(f: Callable) -> Callable: +def register_vcs_handler(vcs, method): # decorator + """Decorator to mark a method as the handler for a particular VCS.""" + def decorate(f): """Store f in HANDLERS[vcs][method].""" if vcs not in HANDLERS: HANDLERS[vcs] = {} @@ -77,35 +67,22 @@ def decorate(f: Callable) -> Callable: return decorate -def run_command( - commands: List[str], - args: List[str], - cwd: Optional[str] = None, - verbose: bool = False, - hide_stderr: bool = False, - env: Optional[Dict[str, str]] = None, -) -> Tuple[Optional[str], Optional[int]]: +def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, + env=None): """Call the given command(s).""" assert isinstance(commands, list) - process = None - - popen_kwargs: Dict[str, Any] = {} - if sys.platform == "win32": - # This hides the console window if pythonw.exe is used - startupinfo = subprocess.STARTUPINFO() - startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW - popen_kwargs["startupinfo"] = startupinfo - - for command in commands: + p = None + for c in commands: try: - dispcmd = str([command] + args) + dispcmd = str([c] + args) # remember shell=False, so use git.cmd on windows, not just git - process = subprocess.Popen([command] + args, cwd=cwd, env=env, - stdout=subprocess.PIPE, - stderr=(subprocess.PIPE if hide_stderr - else None), **popen_kwargs) + p = subprocess.Popen([c] + args, cwd=cwd, env=env, + stdout=subprocess.PIPE, + stderr=(subprocess.PIPE if hide_stderr + else None)) break - except OSError as e: + except EnvironmentError: + e = sys.exc_info()[1] if e.errno == errno.ENOENT: continue if verbose: @@ -116,20 +93,18 @@ def run_command( if verbose: print("unable to find command, tried %s" % (commands,)) return None, None - stdout = process.communicate()[0].strip().decode() - if process.returncode != 0: + stdout = p.communicate()[0].strip() + if sys.version_info[0] >= 3: + stdout = stdout.decode() + if p.returncode != 0: if verbose: print("unable to run %s (error)" % dispcmd) print("stdout was %s" % stdout) - return None, process.returncode - return stdout, process.returncode + return None, p.returncode + return stdout, p.returncode -def versions_from_parentdir( - parentdir_prefix: str, - root: str, - verbose: bool, -) -> Dict[str, Any]: +def versions_from_parentdir(parentdir_prefix, root, verbose): """Try to determine the version from the parent directory name. Source tarballs conventionally unpack into a directory that includes both @@ -138,14 +113,15 @@ def versions_from_parentdir( """ rootdirs = [] - for _ in range(3): + for i in range(3): dirname = os.path.basename(root) if dirname.startswith(parentdir_prefix): return {"version": dirname[len(parentdir_prefix):], "full-revisionid": None, "dirty": False, "error": None, "date": None} - rootdirs.append(root) - root = os.path.dirname(root) # up a level + else: + rootdirs.append(root) + root = os.path.dirname(root) # up a level if verbose: print("Tried directories %s but none started with prefix %s" % @@ -154,48 +130,41 @@ def versions_from_parentdir( @register_vcs_handler("git", "get_keywords") -def git_get_keywords(versionfile_abs: str) -> Dict[str, str]: +def git_get_keywords(versionfile_abs): """Extract version information from the given file.""" # the code embedded in _version.py can just fetch the value of these # keywords. When used from setup.py, we don't want to import _version.py, # so we do it with a regexp instead. This function is not used from # _version.py. - keywords: Dict[str, str] = {} + keywords = {} try: - with open(versionfile_abs, "r") as fobj: - for line in fobj: - if line.strip().startswith("git_refnames ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["refnames"] = mo.group(1) - if line.strip().startswith("git_full ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["full"] = mo.group(1) - if line.strip().startswith("git_date ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["date"] = mo.group(1) - except OSError: + f = open(versionfile_abs, "r") + for line in f.readlines(): + if line.strip().startswith("git_refnames ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["refnames"] = mo.group(1) + if line.strip().startswith("git_full ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["full"] = mo.group(1) + if line.strip().startswith("git_date ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["date"] = mo.group(1) + f.close() + except EnvironmentError: pass return keywords @register_vcs_handler("git", "keywords") -def git_versions_from_keywords( - keywords: Dict[str, str], - tag_prefix: str, - verbose: bool, -) -> Dict[str, Any]: +def git_versions_from_keywords(keywords, tag_prefix, verbose): """Get version information from git keywords.""" - if "refnames" not in keywords: - raise NotThisMethod("Short version file found") + if not keywords: + raise NotThisMethod("no keywords at all, weird") date = keywords.get("date") if date is not None: - # Use only the last line. Previous lines may contain GPG signature - # information. - date = date.splitlines()[-1] - # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 # -like" string, which we must then edit to make compliant), because @@ -208,11 +177,11 @@ def git_versions_from_keywords( if verbose: print("keywords are unexpanded, not using") raise NotThisMethod("unexpanded keywords, not a git-archive tarball") - refs = {r.strip() for r in refnames.strip("()").split(",")} + refs = set([r.strip() for r in refnames.strip("()").split(",")]) # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of # just "foo-1.0". If we see a "tag: " prefix, prefer those. TAG = "tag: " - tags = {r[len(TAG):] for r in refs if r.startswith(TAG)} + tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)]) if not tags: # Either we're using git < 1.8.3, or there really are no tags. We use # a heuristic: assume all version tags have a digit. The old git %d @@ -221,7 +190,7 @@ def git_versions_from_keywords( # between branches and tags. By ignoring refnames without digits, we # filter out many common branch names like "release" and # "stabilization", as well as "HEAD" and "master". - tags = {r for r in refs if re.search(r'\d', r)} + tags = set([r for r in refs if re.search(r'\d', r)]) if verbose: print("discarding '%s', no digits" % ",".join(refs - tags)) if verbose: @@ -230,11 +199,6 @@ def git_versions_from_keywords( # sorting will prefer e.g. "2.0" over "2.0rc1" if ref.startswith(tag_prefix): r = ref[len(tag_prefix):] - # Filter out refs that exactly match prefix or that don't start - # with a number once the prefix is stripped (mostly a concern - # when prefix is '') - if not re.match(r'\d', r): - continue if verbose: print("picking %s" % r) return {"version": r, @@ -250,12 +214,7 @@ def git_versions_from_keywords( @register_vcs_handler("git", "pieces_from_vcs") -def git_pieces_from_vcs( - tag_prefix: str, - root: str, - verbose: bool, - runner: Callable = run_command -) -> Dict[str, Any]: +def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): """Get version from 'git describe' in the root of the source tree. This only gets called if the git-archive 'subst' keywords were *not* @@ -266,15 +225,8 @@ def git_pieces_from_vcs( if sys.platform == "win32": GITS = ["git.cmd", "git.exe"] - # GIT_DIR can interfere with correct operation of Versioneer. - # It may be intended to be passed to the Versioneer-versioned project, - # but that should not change where we get our version from. - env = os.environ.copy() - env.pop("GIT_DIR", None) - runner = functools.partial(runner, env=env) - - _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root, - hide_stderr=not verbose) + out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root, + hide_stderr=True) if rc != 0: if verbose: print("Directory %s not under git control" % root) @@ -282,57 +234,24 @@ def git_pieces_from_vcs( # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] # if there isn't one, this yields HEX[-dirty] (no NUM) - describe_out, rc = runner(GITS, [ - "describe", "--tags", "--dirty", "--always", "--long", - "--match", f"{tag_prefix}[[:digit:]]*" - ], cwd=root) + describe_out, rc = run_command(GITS, ["describe", "--tags", "--dirty", + "--always", "--long", + "--match", "%s*" % tag_prefix], + cwd=root) # --long was added in git-1.5.5 if describe_out is None: raise NotThisMethod("'git describe' failed") describe_out = describe_out.strip() - full_out, rc = runner(GITS, ["rev-parse", "HEAD"], cwd=root) + full_out, rc = run_command(GITS, ["rev-parse", "HEAD"], cwd=root) if full_out is None: raise NotThisMethod("'git rev-parse' failed") full_out = full_out.strip() - pieces: Dict[str, Any] = {} + pieces = {} pieces["long"] = full_out pieces["short"] = full_out[:7] # maybe improved later pieces["error"] = None - branch_name, rc = runner(GITS, ["rev-parse", "--abbrev-ref", "HEAD"], - cwd=root) - # --abbrev-ref was added in git-1.6.3 - if rc != 0 or branch_name is None: - raise NotThisMethod("'git rev-parse --abbrev-ref' returned error") - branch_name = branch_name.strip() - - if branch_name == "HEAD": - # If we aren't exactly on a branch, pick a branch which represents - # the current commit. If all else fails, we are on a branchless - # commit. - branches, rc = runner(GITS, ["branch", "--contains"], cwd=root) - # --contains was added in git-1.5.4 - if rc != 0 or branches is None: - raise NotThisMethod("'git branch --contains' returned error") - branches = branches.split("\n") - - # Remove the first line if we're running detached - if "(" in branches[0]: - branches.pop(0) - - # Strip off the leading "* " from the list of branches. - branches = [branch[2:] for branch in branches] - if "master" in branches: - branch_name = "master" - elif not branches: - branch_name = None - else: - # Pick the first branch that is returned. Good or bad. - branch_name = branches[0] - - pieces["branch"] = branch_name - # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] # TAG might have hyphens. git_describe = describe_out @@ -349,7 +268,7 @@ def git_pieces_from_vcs( # TAG-NUM-gHEX mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe) if not mo: - # unparsable. Maybe git-describe is misbehaving? + # unparseable. Maybe git-describe is misbehaving? pieces["error"] = ("unable to parse git-describe output: '%s'" % describe_out) return pieces @@ -374,27 +293,26 @@ def git_pieces_from_vcs( else: # HEX: no tags pieces["closest-tag"] = None - out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root) - pieces["distance"] = len(out.split()) # total number of commits + count_out, rc = run_command(GITS, ["rev-list", "HEAD", "--count"], + cwd=root) + pieces["distance"] = int(count_out) # total number of commits # commit date: see ISO-8601 comment in git_versions_from_keywords() - date = runner(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip() - # Use only the last line. Previous lines may contain GPG signature - # information. - date = date.splitlines()[-1] + date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"], + cwd=root)[0].strip() pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) return pieces -def plus_or_dot(pieces: Dict[str, Any]) -> str: +def plus_or_dot(pieces): """Return a + if we don't already have one, else return a .""" if "+" in pieces.get("closest-tag", ""): return "." return "+" -def render_pep440(pieces: Dict[str, Any]) -> str: +def render_pep440(pieces): """Build up version string, with post-release "local version identifier". Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you @@ -419,71 +337,40 @@ def render_pep440(pieces: Dict[str, Any]) -> str: return rendered -def render_pep440_branch(pieces: Dict[str, Any]) -> str: - """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . - - The ".dev0" means not master branch. Note that .dev0 sorts backwards - (a feature branch will appear "older" than the master branch). +def render_pep440_pre(pieces): + """TAG[.post.devDISTANCE] -- No -dirty. Exceptions: - 1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty] + 1: no tags. 0.post.devDISTANCE """ if pieces["closest-tag"]: rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - if pieces["branch"] != "master": - rendered += ".dev0" - rendered += plus_or_dot(pieces) - rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" + if pieces["distance"]: + rendered += ".post.dev%d" % pieces["distance"] else: # exception #1 - rendered = "0" - if pieces["branch"] != "master": - rendered += ".dev0" - rendered += "+untagged.%d.g%s" % (pieces["distance"], - pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" + rendered = "0.post.dev%d" % pieces["distance"] return rendered -def pep440_split_post(ver: str) -> Tuple[str, Optional[int]]: - """Split pep440 version string at the post-release segment. - - Returns the release segments before the post-release and the - post-release version number (or -1 if no post-release segment is present). - """ - vc = str.split(ver, ".post") - return vc[0], int(vc[1] or 0) if len(vc) == 2 else None - - -def render_pep440_pre(pieces: Dict[str, Any]) -> str: - """TAG[.postN.devDISTANCE] -- No -dirty. +def render_pep440_minor(pieces): + """TAG[.DISTANCE] . No -dirty Exceptions: - 1: no tags. 0.post0.devDISTANCE + 1: no tags. 0.DISTANCE """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] if pieces["distance"]: - # update the post release segment - tag_version, post_version = pep440_split_post(pieces["closest-tag"]) - rendered = tag_version - if post_version is not None: - rendered += ".post%d.dev%d" % (post_version + 1, pieces["distance"]) - else: - rendered += ".post0.dev%d" % (pieces["distance"]) - else: - # no commits, use the tag as the version - rendered = pieces["closest-tag"] + rendered += ".%d" % pieces["distance"] else: # exception #1 - rendered = "0.post0.dev%d" % pieces["distance"] + rendered = "0.%d" % pieces["distance"] return rendered -def render_pep440_post(pieces: Dict[str, Any]) -> str: +def render_pep440_post(pieces): """TAG[.postDISTANCE[.dev0]+gHEX] . The ".dev0" means dirty. Note that .dev0 sorts backwards @@ -510,41 +397,12 @@ def render_pep440_post(pieces: Dict[str, Any]) -> str: return rendered -def render_pep440_post_branch(pieces: Dict[str, Any]) -> str: - """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . - - The ".dev0" means not master branch. - - Exceptions: - 1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%d" % pieces["distance"] - if pieces["branch"] != "master": - rendered += ".dev0" - rendered += plus_or_dot(pieces) - rendered += "g%s" % pieces["short"] - if pieces["dirty"]: - rendered += ".dirty" - else: - # exception #1 - rendered = "0.post%d" % pieces["distance"] - if pieces["branch"] != "master": - rendered += ".dev0" - rendered += "+g%s" % pieces["short"] - if pieces["dirty"]: - rendered += ".dirty" - return rendered - - -def render_pep440_old(pieces: Dict[str, Any]) -> str: +def render_pep440_old(pieces): """TAG[.postDISTANCE[.dev0]] . The ".dev0" means dirty. - Exceptions: + Eexceptions: 1: no tags. 0.postDISTANCE[.dev0] """ if pieces["closest-tag"]: @@ -561,7 +419,7 @@ def render_pep440_old(pieces: Dict[str, Any]) -> str: return rendered -def render_git_describe(pieces: Dict[str, Any]) -> str: +def render_git_describe(pieces): """TAG[-DISTANCE-gHEX][-dirty]. Like 'git describe --tags --dirty --always'. @@ -581,7 +439,7 @@ def render_git_describe(pieces: Dict[str, Any]) -> str: return rendered -def render_git_describe_long(pieces: Dict[str, Any]) -> str: +def render_git_describe_long(pieces): """TAG-DISTANCE-gHEX[-dirty]. Like 'git describe --tags --dirty --always -long'. @@ -601,7 +459,7 @@ def render_git_describe_long(pieces: Dict[str, Any]) -> str: return rendered -def render(pieces: Dict[str, Any], style: str) -> Dict[str, Any]: +def render(pieces, style): """Render the given version pieces into the requested style.""" if pieces["error"]: return {"version": "unknown", @@ -615,14 +473,12 @@ def render(pieces: Dict[str, Any], style: str) -> Dict[str, Any]: if style == "pep440": rendered = render_pep440(pieces) - elif style == "pep440-branch": - rendered = render_pep440_branch(pieces) elif style == "pep440-pre": rendered = render_pep440_pre(pieces) + elif style == "pep440-minor": + rendered = render_pep440_minor(pieces) elif style == "pep440-post": rendered = render_pep440_post(pieces) - elif style == "pep440-post-branch": - rendered = render_pep440_post_branch(pieces) elif style == "pep440-old": rendered = render_pep440_old(pieces) elif style == "git-describe": @@ -637,7 +493,7 @@ def render(pieces: Dict[str, Any], style: str) -> Dict[str, Any]: "date": pieces.get("date")} -def get_versions() -> Dict[str, Any]: +def get_versions(): """Get version information or return default if unable to do so.""" # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have # __file__, we can work backwards from there to the root. Some @@ -658,7 +514,7 @@ def get_versions() -> Dict[str, Any]: # versionfile_source is the relative path from the top of the source # tree (where the .git directory might live) to this file. Invert # this to find the root from __file__. - for _ in cfg.versionfile_source.split('/'): + for i in cfg.versionfile_source.split('/'): root = os.path.dirname(root) except NameError: return {"version": "0+unknown", "full-revisionid": None, From 0f0a8871c248a8691b8b810d74f9cba9fde05be1 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 19:04:32 +0200 Subject: [PATCH 11/32] update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9894da86..fcb65ffd 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ bin *.tox-info.json *.ipynb_checkpoints lib +fllog.txt From a35e28c75e87c862dcd51f6656b5b8024ead43c2 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 19:10:46 +0200 Subject: [PATCH 12/32] update make clean paths after moving tests out --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 496fee4e..80fbd0bd 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,8 @@ pypi: test python setup.py sdist bdist twine upload dist/* clean: - rm -rf tests/log/fllog.txt + rm -f tests/log/fllog.txt + rm -f fllog.txt rm -rf build_cmake rm -rf build rm -rf docs/build From 1b1078de14f0b5a21a2408baf9c3a5c73a38004a Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 19:23:01 +0200 Subject: [PATCH 13/32] Correctly calculating the coverage --- .github/workflows/test.yml | 14 -------------- README.md | 4 ++-- pyproject.toml | 10 ++++++++++ tox.ini | 19 +++++++++---------- 4 files changed, 21 insertions(+), 26 deletions(-) create mode 100644 pyproject.toml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b766420a..addec50f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,17 +32,3 @@ jobs: uses: codecov/codecov-action@v2 with: fail_ci_if_error: false - docs: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.9 - uses: actions/setup-python@v2 - with: - python-version: "3.9" - - name: Install dependencies - run: | - python -m pip install --upgrade pip setuptools - pip install tox tox-gh-actions - - name: Run tox - run: tox -e docs diff --git a/README.md b/README.md index b8cf26f9..de40a6f5 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,10 @@ - Coverage + Python Coverage - coverage + Python coverage diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..5d204893 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,10 @@ +[tool.coverage.run] +omit = [ + "efel/_version.py" +] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "raise NotImplementedError" +] diff --git a/tox.ini b/tox.ini index 584cb144..e5017111 100644 --- a/tox.ini +++ b/tox.ini @@ -12,22 +12,21 @@ python = envdir = py3{7,8,9,10,11,}{,-style,-test}: {toxworkdir}/py3 deps = - pytest - pytest-cov - coverage - scipy - style: pycodestyle + pytest>=7.3.1 + coverage>=7.3.0 + scipy>=1.10.1 + style: pycodestyle>=2.11.0 allowlist_externals = make - find extras = neo commands = make clean - - style: pycodestyle --ignore=E402,W503,W504 efel - - test: pytest -sx --cov=efel --cov-report=xml efel/tests + style: pycodestyle --ignore=E402,W503,W504 efel tests + test: coverage erase + test: coverage run -m pytest tests + test: coverage report --show-missing + test: coverage xml [testenv:docs] From a4cd401914e190e09b18ff85475b1221d3850ea9 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 19:40:29 +0200 Subject: [PATCH 14/32] add back bdist_wheel to setup.cfg --- setup.cfg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.cfg b/setup.cfg index 2c02cf5c..56081b02 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,3 +10,6 @@ versionfile_source = efel/_version.py versionfile_build = efel/_version.py tag_prefix = parentdir_prefix = + +[bdist_wheel] +universal = 1 From 50ebfeae847d671b9f61613097ef2430df5d95d5 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 19:50:39 +0200 Subject: [PATCH 15/32] Revert "add back bdist_wheel to setup.cfg" This reverts commit 37da20943310d05b2ef8d4ce5b3292376c7e4b9f. --- setup.cfg | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 56081b02..2c02cf5c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,6 +10,3 @@ versionfile_source = efel/_version.py versionfile_build = efel/_version.py tag_prefix = parentdir_prefix = - -[bdist_wheel] -universal = 1 From 673168c1ed09cddffcdb340be21f11d9684f5d45 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 20:06:47 +0200 Subject: [PATCH 16/32] add back docs to test.yml --- .github/workflows/test.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index addec50f..b766420a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,3 +32,17 @@ jobs: uses: codecov/codecov-action@v2 with: fail_ci_if_error: false + docs: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: "3.9" + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools + pip install tox tox-gh-actions + - name: Run tox + run: tox -e docs From c638a67e185cfdf8e2ef6bd8d2228ef439ce6fe5 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 20:07:08 +0200 Subject: [PATCH 17/32] tox fix envdir --- tox.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index e5017111..298bdd5d 100644 --- a/tox.ini +++ b/tox.ini @@ -9,8 +9,7 @@ python = 3.10: py3 3.11: py3 [testenv] -envdir = - py3{7,8,9,10,11,}{,-style,-test}: {toxworkdir}/py3 +envdir = {toxworkdir}/py3 deps = pytest>=7.3.1 coverage>=7.3.0 From 9ff3a3f580913b08343b8c09b465f43eee381c67 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 20:45:26 +0200 Subject: [PATCH 18/32] tox pytest add -sx flags --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 298bdd5d..2f30d6c4 100644 --- a/tox.ini +++ b/tox.ini @@ -23,7 +23,7 @@ commands = make clean style: pycodestyle --ignore=E402,W503,W504 efel tests test: coverage erase - test: coverage run -m pytest tests + test: coverage run -m pytest -sx tests test: coverage report --show-missing test: coverage xml From 3cc716c1602b782f83a5d36041fedde1bbdb9761 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 21:13:36 +0200 Subject: [PATCH 19/32] use coverage instead of pytest-cov --- tox.ini | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/tox.ini b/tox.ini index e0142909..4289962a 100644 --- a/tox.ini +++ b/tox.ini @@ -9,26 +9,24 @@ python = 3.10: py3 3.11: py3 [testenv] -envdir = - py3{7,8,9,10,11,}{,-style,-test}: {toxworkdir}/py3 +envdir = {toxworkdir}/py3 deps = - pytest - pytest-cov - coverage - scipy - style: pycodestyle + pytest>=7.3.1 + coverage>=7.3.0 + scipy>=1.10.1 + style: pycodestyle>=2.11.0 allowlist_externals = make - find extras = neo -passenv = https_proxy commands = make clean style: pycodestyle --ignore=E402,W503,W504 efel - - test: pytest -sx --cov=efel --cov-report=xml efel/tests + test: coverage erase + test: coverage run -m pytest -sx efel/tests + test: coverage report --show-missing + test: coverage xml [testenv:docs] From 2fa807c2f57551e3fe6c567f352d5d5590857bda Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 21:17:30 +0200 Subject: [PATCH 20/32] revert envdir --- tox.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 4289962a..04d5d3d3 100644 --- a/tox.ini +++ b/tox.ini @@ -9,7 +9,8 @@ python = 3.10: py3 3.11: py3 [testenv] -envdir = {toxworkdir}/py3 +envdir = + py3{7,8,9,10,11,}{,-style,-test}: {toxworkdir}/py3 deps = pytest>=7.3.1 coverage>=7.3.0 From 4fd463ae5e4c7af78a7f105a21264e66195ee2c2 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 21:21:39 +0200 Subject: [PATCH 21/32] revert deps --- tox.ini | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tox.ini b/tox.ini index 04d5d3d3..adc10582 100644 --- a/tox.ini +++ b/tox.ini @@ -12,10 +12,11 @@ python = envdir = py3{7,8,9,10,11,}{,-style,-test}: {toxworkdir}/py3 deps = - pytest>=7.3.1 - coverage>=7.3.0 - scipy>=1.10.1 - style: pycodestyle>=2.11.0 + pytest + pytest-cov + coverage + scipy + style: pycodestyle allowlist_externals = make extras = From 795b22490be0eeddf93f1fdfb4fefd453e229a7e Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 21:25:11 +0200 Subject: [PATCH 22/32] revert pytest --- tox.ini | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tox.ini b/tox.ini index adc10582..1ed7293e 100644 --- a/tox.ini +++ b/tox.ini @@ -25,11 +25,7 @@ commands = make clean style: pycodestyle --ignore=E402,W503,W504 efel - test: coverage erase - test: coverage run -m pytest -sx efel/tests - test: coverage report --show-missing - test: coverage xml - + test: pytest -sx --cov=efel --cov-report=xml efel/tests [testenv:docs] usedevelop=True # to access local rst files From 2b366a362d8c1a507af0726a0efe998bd9665857 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 22:58:49 +0200 Subject: [PATCH 23/32] add usedevelop=True --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 2f30d6c4..f8673105 100644 --- a/tox.ini +++ b/tox.ini @@ -19,6 +19,7 @@ allowlist_externals = make extras = neo +usedevelop=True commands = make clean style: pycodestyle --ignore=E402,W503,W504 efel tests From 6ad686d605c5f3fbea84c2fa46561014436baa6c Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 23:20:16 +0200 Subject: [PATCH 24/32] use pytest-cov back again --- tox.ini | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tox.ini b/tox.ini index f8673105..3588a6fe 100644 --- a/tox.ini +++ b/tox.ini @@ -12,6 +12,7 @@ python = envdir = {toxworkdir}/py3 deps = pytest>=7.3.1 + pytest-cov>=4.1.0 coverage>=7.3.0 scipy>=1.10.1 style: pycodestyle>=2.11.0 @@ -23,11 +24,8 @@ usedevelop=True commands = make clean style: pycodestyle --ignore=E402,W503,W504 efel tests - test: coverage erase - test: coverage run -m pytest -sx tests - test: coverage report --show-missing - test: coverage xml - + test: pytest -sx --cov=efel --cov=tests --cov-report=xml tests + test: coverage report -m [testenv:docs] usedevelop=True # to access local rst files From e7eaf3977936b19ae725f50c7b9e1dc662a5fb04 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 23:53:05 +0200 Subject: [PATCH 25/32] upload coverage only once --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b766420a..10570cb2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,6 +29,7 @@ jobs: run: tox # since python-version is set above it calls py3-etc. not docs - name: "Upload coverage to Codecov" + if: ${{matrix.python-version == '3.11'}} uses: codecov/codecov-action@v2 with: fail_ci_if_error: false From e5c5188ac7805766311fcbf618472074e319a4b5 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Wed, 23 Aug 2023 23:59:43 +0200 Subject: [PATCH 26/32] remove py37 from gh actions --- .github/workflows/build.yml | 2 +- tox.ini | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3eeca12b..419b9270 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,7 +55,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04, macos-latest, windows-latest] - python: [cp37, cp38, cp39, cp310, cp311] + python: [cp38, cp39, cp310, cp311] arch: [x86_64, amd64] exclude: - os: macos-latest diff --git a/tox.ini b/tox.ini index 3588a6fe..207c4308 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,6 @@ envlist = docs,py3-{style,test} minversion = 4 [gh-actions] python = - 3.7: py3 3.8: py3 3.9: py3 3.10: py3 From b29a3bbf93e0b235fe5b5cf62c4c49b3a175417f Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Thu, 24 Aug 2023 02:30:59 +0200 Subject: [PATCH 27/32] report cpp coverage as well as python --- .gitignore | 1 + setup.py | 10 +++++++++- tox.ini | 19 +++++++++++++++---- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index fcb65ffd..2d5b6ec6 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ .vscode *.so coverage.xml +cpp_coverage.xml docs/bin docs/lib docs/source/lib diff --git a/setup.py b/setup.py index 596406c9..a66cfae7 100644 --- a/setup.py +++ b/setup.py @@ -63,9 +63,17 @@ 'cppcore', filename) for filename in cppcore_headers] + +coverage_flags = [] +if os.environ.get('EFEL_COVERAGE_BUILD'): + coverage_flags = ['-fprofile-arcs', '-ftest-coverage'] + cppcore = Extension('efel.cppcore', sources=cppcore_sources, - include_dirs=['efel/cppcore/']) + include_dirs=['efel/cppcore/'], + extra_compile_args=coverage_flags, + extra_link_args=coverage_flags) + setup( name="efel", version=versioneer.get_version(), diff --git a/tox.ini b/tox.ini index 207c4308..0b0ae537 100644 --- a/tox.ini +++ b/tox.ini @@ -9,22 +9,33 @@ python = 3.11: py3 [testenv] envdir = {toxworkdir}/py3 +setenv = + EFEL_COVERAGE_BUILD = 1 + deps = pytest>=7.3.1 - pytest-cov>=4.1.0 - coverage>=7.3.0 scipy>=1.10.1 style: pycodestyle>=2.11.0 + coverage: pytest-cov>=4.1.0 + coverage: coverage>=7.3.0 + coverage: gcovr allowlist_externals = make + rm extras = neo usedevelop=True commands = make clean style: pycodestyle --ignore=E402,W503,W504 efel tests - test: pytest -sx --cov=efel --cov=tests --cov-report=xml tests - test: coverage report -m + test: pytest -sx tests + coverage: python setup.py build_ext --inplace + coverage: pytest -sx --cov=efel --cov=tests --cov-report=xml tests + coverage: gcovr -r . + coverage: gcovr -r . --xml -o cpp_coverage.xml + coverage: rm -f ./*.gcov + coverage: coverage report -m + [testenv:docs] usedevelop=True # to access local rst files From 16b2b58a0289ba179866ac7d757f71fcda98a8c9 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Thu, 24 Aug 2023 02:40:47 +0200 Subject: [PATCH 28/32] performance: separate coverage tox environment --- tox.ini | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/tox.ini b/tox.ini index 0b0ae537..17836a2a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = docs,py3-{style,test} +envlist = docs,py3-{test} minversion = 4 [gh-actions] python = @@ -7,18 +7,32 @@ python = 3.9: py3 3.10: py3 3.11: py3 + + [testenv] -envdir = {toxworkdir}/py3 +envdir = {toxworkdir}/py3-test +deps = + pytest>=7.3.1 + scipy>=1.10.1 + pycodestyle>=2.11.0 +extras = + neo +usedevelop=True +commands = + pycodestyle --ignore=E402,W503,W504 efel tests + pytest -sx tests + + +[testenv:coverage] +envdir = {toxworkdir}/py3-coverage setenv = EFEL_COVERAGE_BUILD = 1 - deps = pytest>=7.3.1 scipy>=1.10.1 - style: pycodestyle>=2.11.0 - coverage: pytest-cov>=4.1.0 - coverage: coverage>=7.3.0 - coverage: gcovr + pytest-cov>=4.1.0 + coverage>=7.3.0 + gcovr allowlist_externals = make rm @@ -27,14 +41,13 @@ extras = usedevelop=True commands = make clean - style: pycodestyle --ignore=E402,W503,W504 efel tests - test: pytest -sx tests - coverage: python setup.py build_ext --inplace - coverage: pytest -sx --cov=efel --cov=tests --cov-report=xml tests - coverage: gcovr -r . - coverage: gcovr -r . --xml -o cpp_coverage.xml - coverage: rm -f ./*.gcov - coverage: coverage report -m + python setup.py build_ext --inplace + pytest -sx --cov=efel --cov=tests --cov-report=xml tests + gcovr -r . + gcovr -r . --xml -o cpp_coverage.xml + rm -f ./*.gcov + coverage report -m + [testenv:docs] From 7f7468054c2244c22f68cfb22f76c9d079836688 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Thu, 24 Aug 2023 02:47:20 +0200 Subject: [PATCH 29/32] performance pytest-xdist for test tox env --- tox.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 17836a2a..850517aa 100644 --- a/tox.ini +++ b/tox.ini @@ -15,12 +15,13 @@ deps = pytest>=7.3.1 scipy>=1.10.1 pycodestyle>=2.11.0 + pytest-xdist>=3.3.1 extras = neo usedevelop=True commands = pycodestyle --ignore=E402,W503,W504 efel tests - pytest -sx tests + pytest -sx -n auto tests [testenv:coverage] From eb39a2a65772da05c8e84d7375bffdc8c016dddb Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Thu, 24 Aug 2023 11:50:35 +0200 Subject: [PATCH 30/32] separate coverage ci action removed unnecessary if check in coverage yaml switch to codecov-action@v3 add .codecov.yml with branch coverage gcov add --branches flag to gcovr branch detection: no codecov.yml gcovr treat pratials as hits gcov to give txt output delete .codecov.yml mention txt format gcovr try json format for gcovr gcovr output -> xml --- .github/workflows/test.yml | 25 +++++++++++++++++++++++-- tox.ini | 4 +--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 10570cb2..8e02e616 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,9 +28,30 @@ jobs: - name: Run tox run: tox # since python-version is set above it calls py3-etc. not docs + coverage: + runs-on: ubuntu-20.04 + strategy: + matrix: + python-version: ["3.11"] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools + pip install tox tox-gh-actions + + - name: Run tox coverage + run: tox -e coverage # specify the coverage environment + - name: "Upload coverage to Codecov" - if: ${{matrix.python-version == '3.11'}} - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v3 with: fail_ci_if_error: false docs: diff --git a/tox.ini b/tox.ini index 850517aa..49c31708 100644 --- a/tox.ini +++ b/tox.ini @@ -44,13 +44,11 @@ commands = make clean python setup.py build_ext --inplace pytest -sx --cov=efel --cov=tests --cov-report=xml tests - gcovr -r . - gcovr -r . --xml -o cpp_coverage.xml + gcovr --print-summary -r . --xml -o cpp_coverage.xml rm -f ./*.gcov coverage report -m - [testenv:docs] usedevelop=True # to access local rst files envdir = {toxworkdir}/docs From 52f4e61071cc0b27729dd97d20369a290dd4bca3 Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Thu, 24 Aug 2023 16:27:04 +0200 Subject: [PATCH 31/32] rename Python coverage-> coverage since we add c++ as well --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index de40a6f5..b8cf26f9 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,10 @@ - Python Coverage + Coverage - Python coverage + coverage From a95e29efd72a787f2739839db33ba6d4565903fe Mon Sep 17 00:00:00 2001 From: Anil Tuncel Date: Thu, 24 Aug 2023 17:01:38 +0200 Subject: [PATCH 32/32] update test.yml comment for clarity --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e02e616..d2a05c2f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: pip install tox tox-gh-actions - name: Run tox - run: tox # since python-version is set above it calls py3-etc. not docs + run: tox # this does not call docs coverage: runs-on: ubuntu-20.04