AMR 2.1.1.9103__py3-none-any.whl → 2.1.1.9109__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
@@ -2,33 +2,48 @@ BLUE = '\033[94m'
2
2
  GREEN = '\033[32m'
3
3
  RESET = '\033[0m'
4
4
 
5
- print(f"{BLUE}AMR:{RESET} Setting up R environment and AMR datasets...", flush=True)
6
-
5
+ import os
7
6
  from rpy2 import robjects
8
7
  from rpy2.robjects import pandas2ri
9
8
  from rpy2.robjects.packages import importr, isinstalled
10
9
  import pandas as pd
11
- # import importlib.metadata as metadata
10
+ import importlib.metadata as metadata
11
+
12
+ # Get the path to the virtual environment
13
+ venv_path = os.getenv('VIRTUAL_ENV') # Path to the active virtual environment
14
+
15
+ # Define R library path within the venv
16
+ r_lib_path = os.path.join(venv_path, "R_libs")
17
+ # Ensure the R library path exists
18
+ os.makedirs(r_lib_path, exist_ok=True)
19
+ # Set the R library path in .libPaths
20
+ base = importr('base')
21
+ base._libPaths(r_lib_path)
12
22
 
13
- # Check if AMR package is installed in R
23
+ # Check if the AMR package is installed in R
14
24
  if not isinstalled('AMR'):
15
25
  utils = importr('utils')
16
- utils.install_packages('AMR', repos='https://msberends.r-universe.dev')
26
+ utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)
17
27
 
18
28
  # Python package version of AMR
19
- python_amr_version = metadata.version('AMR')
29
+ try:
30
+ python_amr_version = metadata.version('AMR')
31
+ except metadata.PackageNotFoundError:
32
+ python_amr_version = None
33
+
20
34
  # R package version of AMR
21
- # r_amr_version = robjects.r('packageVersion("AMR")')[0]
35
+ r_amr_version = robjects.r(f'as.character(packageVersion("AMR", lib.loc = "{r_lib_path}"))')[0]
22
36
 
23
37
  # 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)
38
+ if python_amr_version and r_amr_version != python_amr_version:
39
+ try:
40
+ print(f"{BLUE}AMR:{RESET} Updating package version{RESET}", flush=True)
41
+ utils = importr('utils')
42
+ utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)
43
+ except Exception as e:
44
+ print(f"{BLUE}AMR:{RESET} Could not update: {e}{RESET}", flush=True)
45
+
46
+ print(f"{BLUE}AMR:{RESET} Setting up R environment and AMR datasets...", flush=True)
32
47
 
33
48
  # Activate the automatic conversion between R and pandas DataFrames
34
49
  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.9109
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=QbYkTe8Rl96tgADIZJfSwa9Y-eEFfb4faI6qw7y0szs,2451
3
+ AMR/functions.py,sha256=XDN7fo0N3gGnZHYL0pdkG_9jwlsrvj0fo5IqLS7gWBM,43615
4
+ AMR-2.1.1.9109.dist-info/METADATA,sha256=V-rxOr1ZpV19QgdvxFWatZPZ8CxytABo5akm2JhqqWs,9394
5
+ AMR-2.1.1.9109.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
6
+ AMR-2.1.1.9109.dist-info/top_level.txt,sha256=7K6Mq_X_OHdXOzQM5y06VUadXjYkze6yzufL1d7_6xc,4
7
+ AMR-2.1.1.9109.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,,