Skip to content

Commit

Permalink
chore: upgrade to py 3.12
Browse files Browse the repository at this point in the history
Signed-off-by: David Wallace <[email protected]>
  • Loading branch information
David Wallace committed Jan 26, 2025
1 parent 8cb7833 commit 51a26d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ https://github.com/MyPyDavid/raman-fitting/wiki
A release is now available on PyPI, installation can be done with these commands in a terminal.
``` bash
# Setting up and activating a virtual environment
python -m venv env # python 3.11 is recommended
python -m venv env # python 3.12 is recommended
source env/bin/activate

# Installation from PyPI
Expand Down Expand Up @@ -110,7 +110,7 @@ The current version is v0.8.0

### Dependencies

- python >= 3.11
- python >= 3.12
- lmfit >= 1.2.0
- pandas >= 2.0.0
- scipy >= 1.10.1
Expand Down
29 changes: 10 additions & 19 deletions src/raman_fitting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
__package_name__ = __current_package_name__

import importlib.util
import sys

try:
from ._version import __version__
Expand All @@ -24,30 +25,20 @@
except Exception:
__version__ = "catch_exception_version"

import sys
import warnings

# This code is written for Python 3.11 and higher
if sys.version_info.major < 3 and sys.version_info.minor < 11:
raise RuntimeError(f"{__package_name__} requires Python 3.11 or higher.")

# Let users know if they're missing any hard dependencies
hard_dependencies = ("numpy", "pandas", "scipy", "matplotlib", "lmfit", "pydantic")
soft_dependencies = {}
missing_dependencies = []
# This code is written for Python 3.12 and higher
if sys.version_info.major < 3 and sys.version_info.minor < 12:
raise RuntimeError(f"{__package_name__} requires Python 3.12 or higher.")

# Let users know if they're missing any dependencies
dependencies: set = {"numpy", "pandas", "scipy", "matplotlib", "lmfit", "pydantic"}
missing_dependencies = set()

for dependency in hard_dependencies:
for dependency in dependencies:
if not importlib.util.find_spec(dependency):
missing_dependencies.append(dependency)
missing_dependencies.add(dependency)

if missing_dependencies:
raise ImportError(f"Missing required dependencies {missing_dependencies}")

for dependency in soft_dependencies:
if not importlib.util.find_spec(dependency):
warnings.warn(
f"Missing important package {dependency}. {soft_dependencies[dependency]}"
)

del hard_dependencies, soft_dependencies, dependency, missing_dependencies
del dependencies, dependency, missing_dependencies

0 comments on commit 51a26d1

Please sign in to comment.