From a83bbd8c1e5fccba733cd508b0ae2763d4a0bbc0 Mon Sep 17 00:00:00 2001 From: James Gaboardi Date: Wed, 22 Sep 2021 22:09:24 -0400 Subject: [PATCH] access package version --- tools/gitcount.ipynb | 55 ++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/tools/gitcount.ipynb b/tools/gitcount.ipynb index 1332ad1d..fea261b6 100644 --- a/tools/gitcount.ipynb +++ b/tools/gitcount.ipynb @@ -20,19 +20,16 @@ "source": [ "# get date of last tag\n", "from subprocess import Popen, PIPE\n", - "x, err = Popen('git log -1 --tags --simplify-by-decoration --pretty=\"%ai\"| cat', stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True).communicate()\n", + "x, err = Popen(\n", + " 'git log -1 --tags --simplify-by-decoration --pretty=\"%ai\"| cat',\n", + " stdin=PIPE,\n", + " stdout=PIPE,\n", + " stderr=PIPE,\n", + " shell=True\n", + ").communicate()\n", "start_date = x.split()[0].decode('utf-8')" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "err" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -100,7 +97,7 @@ "import ssl\n", "import yaml\n", "\n", - "context = ssl._create_unverified_context()\n" + "context = ssl._create_unverified_context()" ] }, { @@ -109,7 +106,8 @@ "metadata": {}, "outputs": [], "source": [ - "CWD = os.path.abspath(os.path.curdir)" + "CWD = os.path.abspath(os.path.curdir)\n", + "CWD" ] }, { @@ -118,7 +116,10 @@ "metadata": {}, "outputs": [], "source": [ - "CWD" + "since_date = '--since=\"{start}\"'.format(start=start_date)\n", + "since_date\n", + "since = datetime.strptime(start_date+\" 0:0:0\", \"%Y-%m-%d %H:%M:%S\")\n", + "since" ] }, { @@ -127,10 +128,8 @@ "metadata": {}, "outputs": [], "source": [ - "since_date = '--since=\"{start}\"'.format(start=start_date)\n", - "since_date\n", - "since = datetime.strptime(start_date+\" 0:0:0\", \"%Y-%m-%d %H:%M:%S\")\n", - "since" + "# get __version__\n", + "%run ../spopt/_version.py" ] }, { @@ -139,12 +138,7 @@ "metadata": {}, "outputs": [], "source": [ - "# get __version__\n", - "f = \"../{package}/__init__.py\".format(package=package_name)\n", - "\n", - "with open(f, 'r') as initfile:\n", - " exec(initfile.readline())\n", - " " + "__version__ = get_versions()[\"version\"]" ] }, { @@ -193,10 +187,11 @@ "metadata": {}, "outputs": [], "source": [ - "identities = {'Levi John Wolf': ('ljwolf', 'Levi John Wolf'),\n", - " 'Serge Rey': ('Serge Rey', 'Sergio Rey', 'sjsrey', 'serge'),\n", - " 'Wei Kang': ('Wei Kang', 'weikang9009'),\n", - " 'Dani Arribas-Bel': ('Dani Arribas-Bel', 'darribas')\n", + "identities = {\n", + " 'Levi John Wolf': ('ljwolf', 'Levi John Wolf'),\n", + " 'Serge Rey': ('Serge Rey', 'Sergio Rey', 'sjsrey', 'serge'),\n", + " 'Wei Kang': ('Wei Kang', 'weikang9009'),\n", + " 'Dani Arribas-Bel': ('Dani Arribas-Bel', 'darribas')\n", "}\n", "\n", "def regularize_identity(string):\n", @@ -579,9 +574,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python [conda env:spopt]", + "display_name": "Python 3 (ipykernel)", "language": "python", - "name": "conda-env-spopt-py" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -593,7 +588,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.6" + "version": "3.9.7" }, "widgets": { "application/vnd.jupyter.widget-state+json": {