From 63201f2afebd7a9bd2c0e8040dc922cfbcfac796 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Tue, 27 Aug 2024 18:06:31 +0200 Subject: [PATCH 1/4] Support for pyproject.toml - move script to `src/sortgs` - add `__init__.py` - remove requirements.txt and setup.py --- pyproject.toml | 28 ++++++++++++++++++++++++++++ requirements.txt | 5 ----- setup.py | 27 --------------------------- src/sortgs/__init__.py | 1 + sortgs.py => src/sortgs/sortgs.py | 0 5 files changed, 29 insertions(+), 32 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 setup.py create mode 100644 src/sortgs/__init__.py rename sortgs.py => src/sortgs/sortgs.py (100%) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f8dd9a8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,28 @@ +[project] +name='sortgs' +version='1.0.3' +authors=[{name='Fernando Marcos Wittmann'}] +description='A Python tool to rank Google Scholar publications by citations.' +readme = 'README.md' +urls={github='https://github.com/WittmannF/sort-google-scholar'} +dependencies=[ + 'beautifulsoup4', + 'matplotlib', + 'pandas', + 'requests', + 'selenium', +] +scripts = {sortgs='sortgs:main'} +classifiers=[ + 'Programming Language :: Python :: 3', + 'License :: OSI Approved :: MIT License', + 'Operating System :: OS Independent', +] +requires-python='>=3.8' + +[build-system] +requires = ['setuptools'] +build-backend = "setuptools.build_meta" + +[tool.setuptools.packages.find] +where =["src"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index abc45fe..0000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -requests -beautifulsoup4 -pandas -matplotlib -selenium diff --git a/setup.py b/setup.py deleted file mode 100644 index 81cc3d8..0000000 --- a/setup.py +++ /dev/null @@ -1,27 +0,0 @@ -from setuptools import setup - -setup( - name='sortgs', - version='1.0.3', - author='Fernando Marcos Wittmann', - #author_email='fernando.wittmann[at]gmail[dot]com', - description='A Python tool to rank Google Scholar publications by citations.', - long_description=open('README.md').read(), - long_description_content_type='text/markdown', - url='https://github.com/WittmannF/sort-google-scholar', - py_modules=['sortgs'], # Assuming your script is named sortgs.py - install_requires=[ - # your dependencies here - ], - entry_points={ - 'console_scripts': [ - 'sortgs=sortgs:main', # This line sets up the command line tool - ], - }, - classifiers=[ - 'Programming Language :: Python :: 3', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - ], - python_requires='>=3.6', -) diff --git a/src/sortgs/__init__.py b/src/sortgs/__init__.py new file mode 100644 index 0000000..8bc4318 --- /dev/null +++ b/src/sortgs/__init__.py @@ -0,0 +1 @@ +from sortgs.sortgs import main diff --git a/sortgs.py b/src/sortgs/sortgs.py similarity index 100% rename from sortgs.py rename to src/sortgs/sortgs.py From 5d7f4b051aee14f1f6e3950c37a640b907a39895 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Tue, 27 Aug 2024 18:06:31 +0200 Subject: [PATCH 2/4] Make tests runnable --- test/test_sortgs.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test_sortgs.py b/test/test_sortgs.py index ccf117a..39d9518 100644 --- a/test/test_sortgs.py +++ b/test/test_sortgs.py @@ -8,13 +8,13 @@ class TestSortGS(unittest.TestCase): @classmethod def setUpClass(self): '''run once before all tests''' - os.system("python sortgs.py --debug --kw 'machine learning' --nresults 10 --endyear 2022") + os.system("sortgs --debug --kw 'machine learning' --nresults 10 --endyear 2022") self.df_top_10=pd.read_csv('machine_learning.csv') - os.system("python sortgs.py --debug --kw 'machine learning' --nresults 20 --endyear 2022") + os.system("sortgs --debug --kw 'machine learning' --nresults 20 --endyear 2022") self.df_top_20=pd.read_csv('machine_learning.csv') - os.system("python sortgs.py --debug --kw 'machine learning' --nresults 20 --endyear 2022 --sortby 'cit/year'") + os.system("sortgs --debug --kw 'machine learning' --nresults 20 --endyear 2022 --sortby 'cit/year'") self.df_top_sorted_cit_per_year=pd.read_csv('machine_learning.csv') # Repeat the above, but testing the cli command @@ -55,7 +55,7 @@ def test_cit_per_year_sorted(self): [2896, 782, 571, 352, 302]]) def test_csv_exists(self): - os.system("python sortgs.py --debug --kw 'machine learning' --nresults 10") + os.system("sortgs --debug --kw 'machine learning' --nresults 10") self.assertTrue(os.path.exists('machine_learning.csv')) def test_cli_get_10_results(self): @@ -88,4 +88,4 @@ def test_cli_cit_per_year_sorted(self): if __name__=='__main__': - unittest.main() \ No newline at end of file + unittest.main() From 4bf9ed694c00940e7b63fadf152a2102d920f1b7 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Thu, 29 Aug 2024 19:03:18 +0200 Subject: [PATCH 3/4] Fix CI --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 618bf7e..93deb3b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt - name: Install the package run: pip install -e . - name: Test with unittest From e659cbf163790d8fec80bdaac32647ca8cc66cb1 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Thu, 29 Aug 2024 19:03:26 +0200 Subject: [PATCH 4/4] Remove unused imports --- test/test_sortgs.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/test_sortgs.py b/test/test_sortgs.py index 39d9518..9899ab7 100644 --- a/test/test_sortgs.py +++ b/test/test_sortgs.py @@ -1,7 +1,5 @@ -import unittest -from unittest.mock import patch -import sortgs import os +import unittest import pandas as pd class TestSortGS(unittest.TestCase):