Repository: Becksteinlab/GromacsWrapper (language: python)

Issue:
Python 3.12: No module named 'pkg_resources'
```
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/gromacs/__init__.py", line 218, in <module>
    from . import config
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/gromacs/config.py", line 266, in <module>
    from pkg_resources import resource_filename, resource_listdir
ModuleNotFoundError: No module named 'pkg_resources'
```

`pkg_resources` is a part of `setuptools`, and https://github.com/python/cpython/issues/95299 removes `setuptools` from Python environments. It needs to be manually added to the requirements.


Discussion / hints:
Probably better to replace it with `importlib` anyway.
p.s.: PRs welcome :-)
'importlib' is not my forte, so i'm not going to venture into this, unless with a help from ChatGPT... For now can we get started with declaring the dependency on `setuptools`? That's easy enough to add. 

I've had issues reproducing the bug because setuptools are installed (somehow) when creating a developer env using the `test_env.yaml`

Fix patch:
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 8190a5a1..a90873fa 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -26,7 +26,7 @@ jobs:
       fail-fast: false
       matrix:
         os: [ubuntu-latest]
-        python-version: ["3.8", "3.9", "3.10", "3.11"]
+        python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
         gromacs-version: ["2023.1"]
         # Test other GROMACS versions selectively on a recent Python.
         # On macOS only test one GROMACS version and two Python versions
@@ -50,14 +50,17 @@ jobs:
           - os: ubuntu-latest
             python-version: "3.11"
             gromacs-version: "2022.4"
-          # explicitly include a few macOS runners
+          # explicitly include a few macOS runners: MUST use 2018.6:
           # (conda-forge GROMACS >= 2021 is compiled to use rdtscp CPU instruction but these
           # are not available in the macOS GitHub runner so we need to use a different GROMACS
-          # version. Try 2018.5 from bioconda. (2021.5 worked previously but not anymore.)
+          # version. 2018.5 from bioconda works. (2021.5 worked previously but not anymore.)
           # Locally 2023.1 was successfully tested on Intel macOS 13.5.)
           - os: macOS-latest
             python-version: "3.11"
             gromacs-version: "2018.6"
+          - os: macOS-latest
+            python-version: "3.12"
+            gromacs-version: "2018.6"
             
 
     env:
diff --git a/AUTHORS b/AUTHORS
index dd9fd338..b9f14057 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -63,6 +63,11 @@ year of their first commit. GitHub handle is optional.
 ----
 
 - Yury Polyachenko (@polyachenkoya)
+
+2023
+----
+
+- Jinzhe Zeng (@njzjz)
   
 We gratefully acknowledge code fixes contributed by
 @quantifiedcode-bot from Quantified Code https://www.quantifiedcode.com
diff --git a/CHANGES b/CHANGES
index 76dcc98a..a533a43e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3,11 +3,13 @@
 ==============================
 
 2023-xx-xx      0.9.0
-orbeckst, jandom
+orbeckst, jandom, njzjz
 
+* officially support Python 3.12 (PR #271, issue #263)
 * removed support for legacy Python (<= 3.7) (#259)
 * fixed GROMACS TOP reader not reading angle parameters from topology
   file (#261)
+* fixed Python 3.12: No module named ('pkg_resources' #263)
 * fixed AttributeDict does not support hasattr (#214)
 
 
diff --git a/README.rst b/README.rst
index 65181b0d..47f83186 100644
--- a/README.rst
+++ b/README.rst
@@ -12,7 +12,7 @@
 A primitive Python wrapper around the Gromacs_ tools. The library is
 tested with GROMACS 4.6.5, 2018.x, 2019.x, 2020.x, 2021.x, 2022.x,
 2023.x (and 5.x and 2016.x should also work). It supports Python
-3.8--3.11 on Linux and macOS.
+3.8--3.12 on Linux and macOS.
 
 GromacsWrapper also provides a small library (cook book) of often-used
 recipes and helper functions to set up MD simulations.
diff --git a/ci/readthedocs/requirements.txt b/ci/readthedocs/requirements.txt
index 939d390c..2b20832a 100644
--- a/ci/readthedocs/requirements.txt
+++ b/ci/readthedocs/requirements.txt
@@ -2,4 +2,4 @@ numpy>=1.0
 matplotlib
 pandas
 numkit>=1.0
-
+setuptools; python_version >= "3.12"
diff --git a/doc/sphinx/source/installation.txt b/doc/sphinx/source/installation.txt
index 85b826e8..a3221188 100644
--- a/doc/sphinx/source/installation.txt
+++ b/doc/sphinx/source/installation.txt
@@ -70,12 +70,12 @@ If your prefer to download manually, get the latest stable release
 from https://github.com/Becksteinlab/GromacsWrapper/releases and
 either ::
 
-  pip install GromacsWrapper-0.8.3.tar.gz
+  pip install GromacsWrapper-0.8.5.tar.gz
 
 or install from the unpacked source::
 
-  tar -zxvf GromacsWrapper-0.8.3.tar.gz
-  cd GromacsWrapper-0.8.3
+  tar -zxvf GromacsWrapper-0.8.5.tar.gz
+  cd GromacsWrapper-0.8.5
   pip install .
 
 
@@ -111,7 +111,7 @@ Python_ >= 3.8 and GROMACS_ (4.6.x, 2016, 2018, 2019, 2020, 2021,
 System requirements
 -------------------
 
-Tested with Python 3.8--3.11 on Linux and Mac OS X. Earlier Python
+Tested with Python 3.8--3.12 on Linux and Mac OS X. Earlier Python
 versions were only supported until release 0.8.5.
 
 
diff --git a/setup.py b/setup.py
index a597758e..4a7098af 100644
--- a/setup.py
+++ b/setup.py
@@ -39,6 +39,7 @@
         "Programming Language :: Python :: 3.9",
         "Programming Language :: Python :: 3.10",
         "Programming Language :: Python :: 3.11",
+        "Programming Language :: Python :: 3.12",
         "Topic :: Scientific/Engineering :: Bio-Informatics",
         "Topic :: Scientific/Engineering :: Chemistry",
         "Topic :: Software Development :: Libraries :: Python Modules",
@@ -66,6 +67,7 @@
         "matplotlib",
         "numkit",  # numerical helpers
         "numpy>=1.0",
+        'setuptools; python_version >= "3.12"',  # contains 'pkg_resources' for versioneer
     ],
     tests_require=["pytest", "pandas>=0.17"],
     zip_safe=True,


Test patch:
diff --git a/ci/conda-envs/test_env.yaml b/ci/conda-envs/test_env.yaml
index 20c28775..3222e3d5 100644
--- a/ci/conda-envs/test_env.yaml
+++ b/ci/conda-envs/test_env.yaml
@@ -7,3 +7,4 @@ dependencies:
 - matplotlib
 - pandas>=0.17
 - numkit>=1.0
+- setuptools