Skip to content

SetConfigParser and Python 3.12+ Incompatibility #210

Description

@ricco-hub

Following the instructions for pip installation of PSpipe on the master branch, I did the following on my home directory at NERSC:

ml python
pip install --user git+https://github.com/simonsobs/PSpipe.git

For python 3.13.11, I was met with the following error

pip install --user git+https://github.com/simonsobs/PSpipe.git
Collecting git+https://github.com/simonsobs/PSpipe.git
  Cloning https://github.com/simonsobs/PSpipe.git to /tmp/pip-req-build-_2wjscek
  Running command git clone --filter=blob:none --quiet https://github.com/simonsobs/PSpipe.git /tmp/pip-req-build-_2wjscek
  Resolved https://github.com/simonsobs/PSpipe.git to commit cf02c2bab8b743b5877d9d861dbf2975b3d39a42
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [33 lines of output]
      /tmp/pip-req-build-_2wjscek/versioneer.py:564: SyntaxWarning: invalid escape sequence '\s'
        mo = re.search(r'=\s*"(.*)"', line)
      Traceback (most recent call last):
        File "/global/common/software/nersc/pe/conda-envs/26.1.0/python-3.13/nersc-python/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
          main()
          ~~~~^^
        File "/global/common/software/nersc/pe/conda-envs/26.1.0/python-3.13/nersc-python/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
          json_out["return_val"] = hook(**hook_input["kwargs"])
                                   ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
        File "/global/common/software/nersc/pe/conda-envs/26.1.0/python-3.13/nersc-python/lib/python3.13/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-taz9sold/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 333, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-taz9sold/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires
          self.run_setup()
          ~~~~~~~~~~~~~~^^
        File "/tmp/pip-build-env-taz9sold/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 520, in run_setup
          super().run_setup(setup_script=setup_script)
          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-taz9sold/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 317, in run_setup
          exec(code, locals())
          ~~~~^^^^^^^^^^^^^^^^
        File "<string>", line 9, in <module>
        File "/tmp/pip-req-build-_2wjscek/versioneer.py", line 1480, in get_version
          return get_versions()["version"]
                 ~~~~~~~~~~~~^^
        File "/tmp/pip-req-build-_2wjscek/versioneer.py", line 1412, in get_versions
          cfg = get_config_from_root(root)
        File "/tmp/pip-req-build-_2wjscek/versioneer.py", line 342, in get_config_from_root
          parser = configparser.SafeConfigParser()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'configparser' has no attribute 'SafeConfigParser'. Did you mean: 'RawConfigParser'?
      [end of output]
  note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed to build 'git+https://github.com/simonsobs/PSpipe.git' when getting requirements to build wheel

I was able to fix this by doing

git clone https://github.com/simonsobs/PSpipe.git
cd PSpipe
sed -i 's/configparser.SafeConfigParser()/configparser.ConfigParser()/' versioneer.py
sed -i 's/parser.readfp(f)/parser.read_file(f)/' versioneer.py # this fixes another error with a deprecated readfp()
pip install --user .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions