AMR 2.1.1.9103__py3-none-any.whl → 2.1.1.9106__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
AMR/datasets.py CHANGED
@@ -4,31 +4,48 @@ RESET = '\033[0m'
4
4
 
5
5
  print(f"{BLUE}AMR:{RESET} Setting up R environment and AMR datasets...", flush=True)
6
6
 
7
+
8
+ import os
7
9
  from rpy2 import robjects
8
10
  from rpy2.robjects import pandas2ri
9
11
  from rpy2.robjects.packages import importr, isinstalled
10
12
  import pandas as pd
11
- # import importlib.metadata as metadata
13
+ import importlib.metadata as metadata
14
+
15
+ # Get the path to the virtual environment
16
+ venv_path = os.getenv('VIRTUAL_ENV') # Path to the active virtual environment
17
+ if not venv_path:
18
+ raise EnvironmentError("No virtual environment detected. Please activate your Python virtual environment.")
12
19
 
13
- # Check if AMR package is installed in R
20
+ # Define R library path within the venv
21
+ r_lib_path = os.path.join(venv_path, "R_libs")
22
+ # Ensure the R library path exists
23
+ os.makedirs(r_lib_path, exist_ok=True)
24
+ # Set the R library path in .libPaths
25
+ base = importr('base')
26
+ base._libPaths(r_lib_path)
27
+
28
+ # Check if the AMR package is installed in R
14
29
  if not isinstalled('AMR'):
15
30
  utils = importr('utils')
16
- utils.install_packages('AMR', repos='https://msberends.r-universe.dev')
31
+ utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)
17
32
 
18
33
  # Python package version of AMR
19
- python_amr_version = metadata.version('AMR')
34
+ try:
35
+ python_amr_version = metadata.version('AMR')
36
+ except metadata.PackageNotFoundError:
37
+ python_amr_version = None
38
+
20
39
  # R package version of AMR
21
- # r_amr_version = robjects.r('packageVersion("AMR")')[0]
40
+ r_amr_version = robjects.r(f'as.character(packageVersion("AMR", lib.loc = "{r_lib_path}"))')[0]
22
41
 
23
42
  # Compare R and Python package versions
24
- # if r_amr_version != python_amr_version:
25
- # print(f"{BLUE}AMR:{RESET} Version mismatch detected. Updating AMR R package version to {python_amr_version}...", flush=True)
26
- # try:
27
- # # Re-install the specific version of AMR in R
28
- # utils = importr('utils')
29
- # utils.install_packages('AMR', repos='https://msberends.r-universe.dev')
30
- # except Exception as e:
31
- # print(f"{BLUE}AMR:{RESET} Could not update: {e}{RESET}", flush=True)
43
+ if python_amr_version and r_amr_version != python_amr_version:
44
+ try:
45
+ utils = importr('utils')
46
+ utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)
47
+ except Exception as e:
48
+ print(f"{BLUE}AMR:{RESET} Could not update: {e}{RESET}", flush=True)
32
49
 
33
50
  # Activate the automatic conversion between R and pandas DataFrames
34
51
  pandas2ri.activate()
@@ -1,13 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: AMR
3
- Version: 2.1.1.9103
3
+ Version: 2.1.1.9106
4
4
  Summary: A Python wrapper for the AMR R package
5
5
  Home-page: https://github.com/msberends/AMR
6
6
  Author: Dr. Matthijs Berends
7
7
  Author-email: m.s.berends@umcg.nl
8
8
  License: GPL 2
9
9
  Project-URL: Bug Tracker, https://github.com/msberends/AMR/issues
10
- Platform: UNKNOWN
11
10
  Classifier: Programming Language :: Python :: 3
12
11
  Classifier: Operating System :: OS Independent
13
12
  Requires-Python: >=3.6
@@ -187,5 +186,3 @@ With the `AMR` Python package, Python users can now effortlessly call R function
187
186
  By just running `import AMR`, users can seamlessly integrate the robust features of the R `AMR` package into Python workflows.
188
187
 
189
188
  Whether you're cleaning data or analysing resistance patterns, the `AMR` Python package makes it easy to work with AMR data in Python.
190
-
191
-
@@ -0,0 +1,7 @@
1
+ AMR/__init__.py,sha256=Jzrh0SVD8tXP1_sJAnElOPAJcvMgtleTzdSnY3RI3HY,7315
2
+ AMR/datasets.py,sha256=mmbhbTk9MF3F4d50CzIiK01disCRcFOpjdAUo8UHNZg,2502
3
+ AMR/functions.py,sha256=XDN7fo0N3gGnZHYL0pdkG_9jwlsrvj0fo5IqLS7gWBM,43615
4
+ AMR-2.1.1.9106.dist-info/METADATA,sha256=zBIitXz4LjqqV9IozMG0ktLuegaqqglS6YS-XlugWa4,9394
5
+ AMR-2.1.1.9106.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
6
+ AMR-2.1.1.9106.dist-info/top_level.txt,sha256=7K6Mq_X_OHdXOzQM5y06VUadXjYkze6yzufL1d7_6xc,4
7
+ AMR-2.1.1.9106.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.44.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,7 +0,0 @@
1
- AMR/__init__.py,sha256=Jzrh0SVD8tXP1_sJAnElOPAJcvMgtleTzdSnY3RI3HY,7315
2
- AMR/datasets.py,sha256=rZyCubWpEMEHoY0Wmh7HHHo4Exsys8Cq8JobVl5YgHg,2022
3
- AMR/functions.py,sha256=XDN7fo0N3gGnZHYL0pdkG_9jwlsrvj0fo5IqLS7gWBM,43615
4
- AMR-2.1.1.9103.dist-info/METADATA,sha256=6NamjGS5HgvSg_1uDTSXndnwi7H9Vh7qb1XH4FMnWWw,9414
5
- AMR-2.1.1.9103.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
6
- AMR-2.1.1.9103.dist-info/top_level.txt,sha256=7K6Mq_X_OHdXOzQM5y06VUadXjYkze6yzufL1d7_6xc,4
7
- AMR-2.1.1.9103.dist-info/RECORD,,