carbonplan / cmip6-downscaling

Climate downscaling using CMIP6 data
https://docs.carbonplan.org/cmip6-downscaling
MIT License
169 stars 25 forks source link

Error in pyproject.toml prevents installation #322

Closed fivegrant closed 8 months ago

fivegrant commented 8 months ago

I keep encountering a bug while installing cmip6_downscaling. I have tried three methods of installation

I tried this in the official Docker containers for Python 3.8, 3.10 and 3.12 and got the same result.

Steps to Reproduce

docker pull python:3.12
docker run -it python:3.12 /bin/bash
pip install cmip6_downscaling # once your in the container

Logs

Example of bug running in the 3.8 Container

root@22b0cc920027:/cmip6-downscaling# pip install -e .
Obtaining file:///cmip6-downscaling
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... error
  error: subprocess-exited-with-error

  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> [174 lines of output]
      WARNING setuptools_scm.pyproject_reading toml section missing 'pyproject.toml does not contain a tool.setuptools_scm section'
      /tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/config/_apply_pyprojecttoml.py:75: _MissingDynamic: `readme` defined outside of `pyproject.toml` is ignored.
      !!

              ********************************************************************************
              The following seems to be defined outside of `pyproject.toml`:

              `readme = '<p align="left" >\n<a href=\'https://carbonplan.org\'>\n<picture>\n  <source media="(prefers-color-scheme: dark)" srcset="https://carbonplan-assets.s3.amazonaws.com/monogram/light-small.png">\n  <img alt="CarbonPlan monogram." height="48" src="https://carbonplan-assets.s3.amazonaws.com/monogram/dark-small.png">\n</picture>\n</a>\n</p>\n\n# carbonplan / cmip6-downscaling\n\n**climate downscaling using cmip6 data**\n\n[![CI](https://github.com/carbonplan/cmip6-downscaling/actions/workflows/main.yaml/badge.svg)](https://github.com/carbonplan/cmip6-downscaling/actions/workflows/main.yaml)\n[![PyPI](https://img.shields.io/pypi/v/cmip6-downscaling)](https://pypi.org/project/cmip6-downscaling)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n<img\nsrc=\'https://images.carbonplan.org/highlights/cmip6-downscaling-dark.png\'\n/>\n\nThis repository includes our tools/scripts/models/etc for climate downscaling. This work is described in more detail in a [web article](https://carbonplan.org/research/cmip6-downscaling-explainer) with\na companion [map tool](https://carbonplan.org/research/cmip6-downscaling) to explore the data. We encourage you to reach out if you are interested in using the code or datasets by [opening an issue](https://github.com/carbonplan/cmip6-downscaling/issues/new) or [sending us an email](mailto:hello@carbonplan.org).\n\n## install\n\n```shell\npython -m pip install cmip6_downscaling\n```\n\n## usage\n\n```python\nfrom cmip6_downscaling.methods import ...\n```\n\n## data access\n\nThere are two ways to access the data using Python.\n\nFirst, the entire collection of datasets at daily timescales is available through an `intake` catalog using the following code snippet.\n\n```\nimport intake\ncat = intake.open_esm_datastore(\n  \'https://cpdataeuwest.blob.core.windows.net/cp-cmip/version1/catalogs/global-downscaled-cmip6.json\'\n)\n```\n\nYou can check out this example [Jupyter notebook](https://github.com/carbonplan/cmip6-downscaling/blob/main/notebooks/accessing_data_example.ipynb) to see how to access the data, perform some simple analysis, and download subsets.\n\nYou can also access the data by using the URL of an individual dataset. See [the datasets page](https://github.com/carbonplan/cmip6-downscaling/blob/main/datasets.md) for a table of all available datasets in this collection with storage locations and other metadata. A code snippet showing how to use the URL is shown below:\n\n```\nimport xarray as xr\nxr.open_zarr(\'https://cpdataeuwest.blob.core.windows.net/cp-cmip/version1/data/DeepSD/ScenarioMIP.CCCma.CanESM5.ssp245.r1i1p1f1.day.DeepSD.pr.zarr\')\n```\n\n## license\n\nAll the code in this repository is [MIT](https://choosealicense.com/licenses/mit/)-licensed. Some of the data provided by this API is sourced from content made available under a [CC-BY-4.0](https://choosealicense.com/licenses/cc-by-4.0/) license. We include attribution for this content, and we please request that you also maintain that attribution if using this data.\n\n## about us\n\nCarbonPlan is a nonprofit organization that uses data and science for climate action. We aim to improve the transparency and scientific integrity of climate solutions with open data and tools. Find out more at [carbonplan.org](https://carbonplan.org/) or get in touch by [opening an issue](https://github.com/carbonplan/cmip6-downscaling/issues/new) or [sending us an email](mailto:hello@carbonplan.org).\n'`

              According to the spec (see the link below), however, setuptools CANNOT
              consider this value unless `readme` is listed as `dynamic`.

              https://packaging.python.org/en/latest/specifications/declaring-project-metadata/

              To prevent this problem, you can list `readme` under `dynamic` or alternatively
              remove the `[project]` table from your file and rely entirely on other means of
              configuration.
              ********************************************************************************

      !!
        _handle_missing_dynamic(dist, project_table)
      /tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/config/_apply_pyprojecttoml.py:75: _MissingDynamic: `requires-python` defined outside of `pyproject.toml` is ignored.
      !!

              ********************************************************************************
              The following seems to be defined outside of `pyproject.toml`:

              `requires-python = '>=3.8'`

              According to the spec (see the link below), however, setuptools CANNOT
              consider this value unless `requires-python` is listed as `dynamic`.

              https://packaging.python.org/en/latest/specifications/declaring-project-metadata/

              To prevent this problem, you can list `requires-python` under `dynamic` or alternatively
              remove the `[project]` table from your file and rely entirely on other means of
              configuration.
              ********************************************************************************

      !!
        _handle_missing_dynamic(dist, project_table)
      /tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/config/_apply_pyprojecttoml.py:75: _MissingDynamic: `license` defined outside of `pyproject.toml` is ignored.
      !!

              ********************************************************************************
              The following seems to be defined outside of `pyproject.toml`:

              `license = 'MIT'`

              According to the spec (see the link below), however, setuptools CANNOT
              consider this value unless `license` is listed as `dynamic`.

              https://packaging.python.org/en/latest/specifications/declaring-project-metadata/

              To prevent this problem, you can list `license` under `dynamic` or alternatively
              remove the `[project]` table from your file and rely entirely on other means of
              configuration.
              ********************************************************************************

      !!
        _handle_missing_dynamic(dist, project_table)
      /tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/config/_apply_pyprojecttoml.py:75: _MissingDynamic: `maintainers` defined outside of `pyproject.toml` is ignored.
      !!

              ********************************************************************************
              The following seems to be defined outside of `pyproject.toml`:

              `maintainers = 'CarbonPlan'`

              According to the spec (see the link below), however, setuptools CANNOT
              consider this value unless `maintainers` is listed as `dynamic`.

              https://packaging.python.org/en/latest/specifications/declaring-project-metadata/

              To prevent this problem, you can list `maintainers` under `dynamic` or alternatively
              remove the `[project]` table from your file and rely entirely on other means of
              configuration.
              ********************************************************************************

      !!
        _handle_missing_dynamic(dist, project_table)
      /tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/config/_apply_pyprojecttoml.py:75: _MissingDynamic: `keywords` defined outside of `pyproject.toml` is ignored.
      !!

              ********************************************************************************
              The following seems to be defined outside of `pyproject.toml`:

              `keywords = ['carbon', 'data', 'climate', 'downscaling']`

              According to the spec (see the link below), however, setuptools CANNOT
              consider this value unless `keywords` is listed as `dynamic`.

              https://packaging.python.org/en/latest/specifications/declaring-project-metadata/

              To prevent this problem, you can list `keywords` under `dynamic` or alternatively
              remove the `[project]` table from your file and rely entirely on other means of
              configuration.
              ********************************************************************************

      !!
        _handle_missing_dynamic(dist, project_table)
      /tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/config/_apply_pyprojecttoml.py:75: _MissingDynamic: `dependencies` defined outside of `pyproject.toml` is ignored.
      !!

              ********************************************************************************
              The following seems to be defined outside of `pyproject.toml`:

              `dependencies = ['adlfs>=2022.2.0', 'carbonplan_data', 'carbonplan[styles]', 'cf-xarray>=0.7.3', 'cmip6_preprocessing', 'dask[complete]', 'dask-kubernetes', 'donfig>=0.7.0', 'fsspec', 'intake', 'intake-esm>=2022.9.18', 'intake-xarray', 'ndpyramid==0.0.6', 'pandas', 'prefect==0.15.13', 'rechunker', 'regionmask', 'scikit-downscale>=0.1.2', 'scikit-learn', 'scipy', 'universal-pathlib>=0.0.12', 'xarray>=2022.3.0', 'xarray-datatree==0.0.6', 'xarray_schema>=0.0.3', 'xclim', 'zarr>=2.11.3']`

              According to the spec (see the link below), however, setuptools CANNOT
              consider this value unless `dependencies` is listed as `dynamic`.

              https://packaging.python.org/en/latest/specifications/declaring-project-metadata/

              To prevent this problem, you can list `dependencies` under `dynamic` or alternatively
              remove the `[project]` table from your file and rely entirely on other means of
              configuration.
              ********************************************************************************

      !!
        _handle_missing_dynamic(dist, project_table)
      /tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/config/_apply_pyprojecttoml.py:75: _MissingDynamic: `optional-dependencies` defined outside of `pyproject.toml` is ignored.
      !!

              ********************************************************************************
              The following seems to be defined outside of `pyproject.toml`:

              `optional-dependencies = {'deepsd': ['tensorflow', 'tensorflow-io'], 'analysis': ['cartopy', 'seaborn', 'carbonplan[styles]']}`

              According to the spec (see the link below), however, setuptools CANNOT
              consider this value unless `optional-dependencies` is listed as `dynamic`.

              https://packaging.python.org/en/latest/specifications/declaring-project-metadata/

              To prevent this problem, you can list `optional-dependencies` under `dynamic` or alternatively
              remove the `[project]` table from your file and rely entirely on other means of
              configuration.
              ********************************************************************************

      !!
        _handle_missing_dynamic(dist, project_table)
      Traceback (most recent call last):
        File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/usr/local/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
          return hook(config_settings)
        File "/tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 441, in get_requires_for_build_editable
          return self.get_requires_for_build_wheel(config_settings)
        File "/tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 480, in run_setup
          super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 20, in <module>
        File "/tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
        File "/tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 159, in setup
          dist.parse_config_files()
        File "/tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 627, in parse_config_files
          pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
        File "/tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/config/pyprojecttoml.py", line 67, in apply_configuration
          return _apply(dist, config, filepath)
        File "/tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/config/_apply_pyprojecttoml.py", line 56, in apply
          _apply_project_table(dist, config, root_dir)
        File "/tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/config/_apply_pyprojecttoml.py", line 82, in _apply_project_table
          corresp(dist, value, root_dir)
        File "/tmp/pip-build-env-m7ydq0qd/overlay/lib/python3.8/site-packages/setuptools/config/_apply_pyprojecttoml.py", line 163, in _long_description
          file = val.get("file") or []
      AttributeError: 'NoneType' object has no attribute 'get'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

[notice] A new release of pip is available: 23.0.1 -> 23.3.2
[notice] To update, run: pip install --upgrade pip
fivegrant commented 8 months ago

Hmm, this seems like the same error that's affecting CI: https://github.com/carbonplan/cmip6-downscaling/actions/runs/7481669313/job/20363706596

norlandrhagen commented 8 months ago

@fivegrant thanks for opening this! Going to try to push a fix so that this is installable.

norlandrhagen commented 8 months ago

Main should be working now!

fivegrant commented 8 months ago

Thanks! Works for now when I install via pip install git+https://github.com/carbonplan/cmip6-downscaling