Skip to content

Commit b143cf3

Browse files
authored
Merge pull request #8 from Pandananana/publish-pypi
Prepare package for PyPI publishing
2 parents e6bb0b0 + 62edc70 commit b143cf3

11 files changed

Lines changed: 287 additions & 61 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Set up Python
14+
uses: actions/setup-python@v5
15+
with:
16+
python-version: "3.12"
17+
18+
- name: Install build dependencies
19+
run: pip install build
20+
21+
- name: Build package
22+
run: python -m build
23+
24+
- name: Upload dist artifacts
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: dist
28+
path: dist/
29+
30+
publish-testpypi:
31+
needs: build
32+
runs-on: ubuntu-latest
33+
environment: testpypi
34+
permissions:
35+
id-token: write
36+
steps:
37+
- name: Download dist artifacts
38+
uses: actions/download-artifact@v4
39+
with:
40+
name: dist
41+
path: dist/
42+
43+
- name: Publish to TestPyPI
44+
uses: pypa/gh-action-pypi-publish@release/v1
45+
with:
46+
repository-url: https://test.pypi.org/legacy/
47+
48+
publish-pypi:
49+
needs: publish-testpypi
50+
runs-on: ubuntu-latest
51+
environment: pypi
52+
permissions:
53+
id-token: write
54+
steps:
55+
- name: Download dist artifacts
56+
uses: actions/download-artifact@v4
57+
with:
58+
name: dist
59+
path: dist/
60+
61+
- name: Publish to PyPI
62+
uses: pypa/gh-action-pypi-publish@release/v1

‎.github/workflows/test.yml‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install -e ".[dev]"
29+
30+
- name: Run tests
31+
run: pytest -v
32+
33+
build:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: Set up Python
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: "3.12"
42+
43+
- name: Install build dependencies
44+
run: pip install build
45+
46+
- name: Build package
47+
run: python -m build
48+
49+
- name: Check dist contents
50+
run: |
51+
ls -la dist/
52+
pip install twine
53+
twine check dist/*

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,4 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
uv.lock

‎pyproject.toml‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "respsearch"
7+
version = "0.1.0"
8+
description = "Fetch Academic Research Papers from different sources including Google Scholar, ACL, ACM, PMLR, Arxiv, Semantic Scholar, and more"
9+
readme = "README.md"
10+
license = "Apache-2.0"
11+
requires-python = ">=3.9"
12+
authors = [
13+
{ name = "monk1337", email = "aadityaura@gmail.com" }
14+
]
15+
keywords = [
16+
"research",
17+
"papers",
18+
"academic",
19+
"google-scholar",
20+
"arxiv",
21+
"semantic-scholar",
22+
"acl",
23+
"acm",
24+
"pmlr",
25+
]
26+
classifiers = [
27+
"Development Status :: 4 - Beta",
28+
"Intended Audience :: Developers",
29+
"Intended Audience :: Science/Research",
30+
"License :: OSI Approved :: Apache Software License",
31+
"Operating System :: OS Independent",
32+
"Programming Language :: Python :: 3",
33+
"Programming Language :: Python :: 3.9",
34+
"Programming Language :: Python :: 3.10",
35+
"Programming Language :: Python :: 3.11",
36+
"Programming Language :: Python :: 3.12",
37+
"Programming Language :: Python :: 3.13",
38+
"Topic :: Scientific/Engineering",
39+
"Topic :: Scientific/Engineering :: Information Analysis",
40+
]
41+
42+
dependencies = [
43+
"beautifulsoup4",
44+
"requests",
45+
"pandas",
46+
"numpy",
47+
"tqdm",
48+
"google-search-results",
49+
"pybtex",
50+
"latexcodec",
51+
"PyYAML",
52+
"shutup",
53+
]
54+
55+
[project.optional-dependencies]
56+
selenium = [
57+
"selenium",
58+
"trio",
59+
"trio-websocket",
60+
"wsproto",
61+
]
62+
dev = [
63+
"pytest",
64+
"build",
65+
]
66+
67+
[project.urls]
68+
Homepage = "https://github.com/monk1337/resp"
69+
Repository = "https://github.com/monk1337/resp"
70+
Issues = "https://github.com/monk1337/resp/issues"
71+
72+
[tool.hatch.build.targets.wheel]
73+
packages = ["resp"]

‎requirements.txt‎

Lines changed: 0 additions & 33 deletions
This file was deleted.

‎resp/__init__.py‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""RESP: Research Papers Search
2+
3+
Fetch Academic Research Papers from different sources including
4+
Google Scholar, ACL, ACM, PMLR, Arxiv, Semantic Scholar, and more.
5+
"""
6+
7+
__version__ = "0.1.0"
8+
9+
from resp.resp import Resp
10+
from resp.apis.semantic_s import Semantic_Scholar
11+
from resp.apis.arxiv_api import Arxiv
12+
from resp.apis.acm_api import ACM
13+
from resp.apis.serp_api import Serp
14+
15+
__all__ = [
16+
"__version__",
17+
"Resp",
18+
"Semantic_Scholar",
19+
"Arxiv",
20+
"ACM",
21+
"Serp",
22+
]
23+
24+
25+
def connected_papers():
26+
"""Lazy import and instantiate connected_papers (requires selenium extra)."""
27+
try:
28+
from resp.apis.cnnp import connected_papers as _connected_papers
29+
30+
return _connected_papers()
31+
except ImportError as e:
32+
raise ImportError(
33+
"connected_papers requires selenium. "
34+
"Install with: pip install respsearch[selenium]"
35+
) from e

‎resp/apis/cnnp.py‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
from selenium import webdriver
2-
from selenium.webdriver.common.keys import Keys
3-
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
1+
try:
2+
from selenium import webdriver
3+
from selenium.webdriver.common.keys import Keys
4+
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
5+
SELENIUM_AVAILABLE = True
6+
except ImportError:
7+
SELENIUM_AVAILABLE = False
8+
webdriver = None
9+
Keys = None
10+
DesiredCapabilities = None
11+
412
import pandas as pd
513
import glob
614
import time
@@ -17,8 +25,18 @@
1725
shutup.please()
1826

1927

28+
def _check_selenium():
29+
"""Check if selenium is installed and raise helpful error if not."""
30+
if not SELENIUM_AVAILABLE:
31+
raise ImportError(
32+
"connected_papers requires selenium and related packages. "
33+
"Install with: pip install respsearch[selenium]"
34+
)
35+
36+
2037
class connected_papers(object):
2138
def __init__(self, url="https://www.connectedpapers.com"):
39+
_check_selenium()
2240
Path("./Connected_Papers_Data/df_csvs").mkdir(parents=True, exist_ok=True)
2341
Path("./Connected_Papers_Data/connected_downloads").mkdir(
2442
parents=True, exist_ok=True

‎resp/resp.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import pandas as pd
55
from tqdm import tqdm
66
from resp.apis.serp_api import Serp
7-
from resp.apis.cnnp import connected_papers
87

98

109

@@ -85,6 +84,7 @@ def custom_search(self, url, keyword, max_pages = None):
8584

8685
def all_related_papers(self, query):
8786
"""download all related papers from two sources"""
87+
from resp.apis.cnnp import connected_papers
8888

8989
result = []
9090
cp = connected_papers()

‎setup.py‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎tests/__init__.py‎

Whitespace-only changes.

0 commit comments

Comments
 (0)