Skip to content

Commit 181c177

Browse files
committed
hadling the error for requests module
1 parent 1172439 commit 181c177

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

.github/workflows/publish-to-test-pypi.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ jobs:
99
steps:
1010
- uses: actions/checkout@master
1111
- name: Set up Python 3.9
12-
uses: actions/setup-python@v1
12+
uses: actions/setup-python@v3
1313
with:
1414
python-version: "3.9"
1515
- name: Update pip
1616
run: python -m pip install --upgrade pip
1717
- name: Install dependencies
18-
run: >-
19-
python -m
20-
pip install
21-
-r requirements.txt
18+
run: |
19+
pip install -r requirements.txt
20+
pip install .
21+
pip install regex
2222
- name: Install pypa/build
2323
run: >-
2424
python -m

.github/workflows/run_black_and_isort.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
pip install --upgrade pip
2424
pip install -r requirements.txt
2525
pip install .
26+
pip install regex
2627
pip install black isort
2728
- name: Run black and isort
2829
run: |

setup.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
import codecs
44
import os
55

6-
import requests
6+
try:
7+
import requests
8+
requests_installed = True
9+
except ImportError:
10+
requests_installed = False
711

812
#VERSION = '0.0.1'
913
# VERSION = (
@@ -13,12 +17,16 @@
1317
# )
1418

1519
def get_pypi_version():
20+
if not requests_installed:
21+
print("Warning: 'requests' module is not installed. Using default version.")
22+
return "0.0.1"
1623
try:
1724
response = requests.get("https://pypi.org/pypi/easyPythonpi/json")
1825
data = response.json()
1926
return str(data["info"]["version"])
20-
except:
21-
return "0.0.0"
27+
except Exception as e:
28+
print(f"Error fetching version from PyPI: {e}")
29+
return "0.0.1"
2230

2331
def increment_version(version):
2432
major, minor, patch = map(int, version.split('.'))
@@ -82,7 +90,8 @@ def get_version():
8290
description=DESCRIPTION,
8391
long_description_content_type="text/markdown",
8492
packages=find_packages(),
85-
install_requires=["numpy >= 1.19.5", "requests >= 2.25.1"],
93+
install_requires=["numpy >= 1.19.5"] + (["requests >= 2.25.1"] if not requests_installed else []),
94+
setup_requires=["requests >= 2.25.1"],
8695
keywords=['python', 'sorting', 'beginners', 'sockets'],
8796
classifiers=[
8897
"Development Status :: 1 - Planning",

0 commit comments

Comments
 (0)