Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 24 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,69 +13,71 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade pip
pip install build
python -m build
python -m pip install --upgrade twine
python -m twine check dist/*

- name: 'Upload Artifact'
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
path: dist/
test:
name: Test Coverage
name: Test on Python ${{ matrix.python-version }}
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@v3
- name: Set up Python 3
uses: actions/setup-python@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install responses
pip install coverage
python ${{ github.workspace }}/setup.py install
pip install responses coverage
pip install .
- name: Run Tests
run: |
python -m coverage run -m unittest
python -m coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

if: matrix.python-version == '3.14'
uses: codecov/codecov-action@v4

publish:
if: startsWith(github.ref, 'refs/tags/v')
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist
path: dist
- name: Set up Python 3
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"
- name: Publish packages to PyPi
run: |
python -m pip install --upgrade twine
set -ex
export VERSION=$(python3 setup.py --version)
export VERSION=$(python3 -c "import re; print(re.search(r'version=[\"\\x27](.*?)[\"\\x27]', open('setup.py').read()).group(1))")
python -m twine upload --verbose dist/razorpay-$VERSION-py3-none-any.whl dist/razorpay-$VERSION.tar.gz
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}

33 changes: 0 additions & 33 deletions .github/workflows/python.yml

This file was deleted.

32 changes: 9 additions & 23 deletions razorpay/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,16 @@ def _update_user_agent_header(self, options):

def _get_version(self):
version = ""
try: # nosemgrep : gitlab.bandit.B110
# Try importlib.metadata first (modern approach)
try:
import importlib.metadata
from importlib.metadata import PackageNotFoundError
version = importlib.metadata.version("razorpay")
except ImportError:
# Fall back to pkg_resources
import pkg_resources
from pkg_resources import DistributionNotFound
version = pkg_resources.require("razorpay")[0].version
except (PackageNotFoundError, DistributionNotFound, NameError): # pragma: no cover
# PackageNotFoundError: importlib.metadata couldn't find the package
# DistributionNotFound: pkg_resources couldn't find the package
# NameError: in case the exception classes aren't defined due to import issues

# If all else fails, use the hardcoded version from the package
version = "1.4.3"

try:
import importlib.metadata
version = importlib.metadata.version("razorpay")
except importlib.metadata.PackageNotFoundError: # pragma: no cover
version = "2.0.1"
warnings.warn(
"Could not detect razorpay package version. Using fallback version."
"This may indicate an installation issue.",
UserWarning,
stacklevel=4
"Could not detect razorpay package version. Using fallback version. "
"This may indicate an installation issue.",
UserWarning,
stacklevel=4
)
return version

Expand Down
14 changes: 6 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
url="https://github.com/razorpay/razorpay-python",
author="Team Razorpay",
license="MIT",
install_requires=["requests"],
python_requires='>=3.11',
install_requires=["requests>=2.28.0"],
include_package_data=True,
package_dir={'razorpay': 'razorpay', 'razorpay.resources': 'razorpay/resources'},
packages=['razorpay', 'razorpay.resources'],
Expand All @@ -21,15 +22,12 @@
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",

# List of supported Python versions
# Make sure that this is reflected in .github/workflows/python.yml as well
"Programming Language :: Python",
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',

'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'Programming Language :: Python :: 3.14',
"Topic :: Software Development :: Libraries :: Python Modules",
]
)
Loading