recast-hep / recast-atlas

CLI for ATLAS RECAST contributors
https://recast.docs.cern.ch/
Apache License 2.0
5 stars 5 forks source link

build: Use hatchling as build backend #145

Closed matthewfeickert closed 1 month ago

matthewfeickert commented 1 month ago
matthewfeickert commented 1 month ago

I'm unclear why this is failing for the Docker build when it worked for pyhf, but for

docker build -f docker/Dockerfile -t recast/recastatlas:debug-local .

I'm getting

12.02 error: Failed to download and build: `recast-atlas @ file:///code`
12.02   Caused by: Failed to build: `recast-atlas @ file:///code`
12.02   Caused by: Build backend failed to determine metadata through `prepare_metadata_for_build_wheel` with exit status: 1
12.02 --- stdout:
12.02 
12.02 --- stderr:
12.02 WARNING setuptools_scm.run_cmd command git missing: [Errno 2] No such file or directory: 'git'
12.02 ERROR setuptools_scm._get_version_impl command git not found while parsing the scm, using fallbacks
12.02 Traceback (most recent call last):
12.02   File "/tmp/.tmpMG46DF/environments-v0/.tmpOxLtHV/lib/python3.8/site-packages/setuptools_scm/_get_version_impl.py", line 40, in parse_scm_version
12.02     return _entrypoints.version_from_entrypoint(
12.02   File "/tmp/.tmpMG46DF/environments-v0/.tmpOxLtHV/lib/python3.8/site-packages/setuptools_scm/_entrypoints.py", line 57, in version_from_entrypoint
12.02     maybe_version: version.ScmVersion | None = fn(root, config=config)
12.02   File "/tmp/.tmpMG46DF/environments-v0/.tmpOxLtHV/lib/python3.8/site-packages/setuptools_scm/git.py", line 212, in parse
12.02     _require_command("git")
12.02   File "/tmp/.tmpMG46DF/environments-v0/.tmpOxLtHV/lib/python3.8/site-packages/setuptools_scm/_run_cmd.py", line 214, in require_command
12.02     raise CommandNotFoundError(name)
12.02 setuptools_scm._run_cmd.CommandNotFoundError: git
12.02 /tmp/.tmpMG46DF/environments-v0/.tmpOxLtHV/lib/python3.8/site-packages/setuptools_scm/git.py:312: UserWarning: git archive did not support describe output
12.02   warnings.warn("git archive did not support describe output")
12.02 /tmp/.tmpMG46DF/environments-v0/.tmpOxLtHV/lib/python3.8/site-packages/setuptools_scm/git.py:331: UserWarning: unprocessed git archival found (no export subst applied)
12.02   warnings.warn("unprocessed git archival found (no export subst applied)")
12.02 Traceback (most recent call last):
12.02   File "<string>", line 14, in <module>
12.02   File "/tmp/.tmpMG46DF/environments-v0/.tmpOxLtHV/lib/python3.8/site-packages/hatchling/build.py", line 112, in prepare_metadata_for_build_wheel
12.02     directory = os.path.join(metadata_directory, f'{builder.artifact_project_id}.dist-info')
12.02   File "/tmp/.tmpMG46DF/environments-v0/.tmpOxLtHV/lib/python3.8/site-packages/hatchling/builders/wheel.py", line 825, in artifact_project_id
12.02     self.project_id
12.02   File "/tmp/.tmpMG46DF/environments-v0/.tmpOxLtHV/lib/python3.8/site-packages/hatchling/builders/plugin/interface.py", line 374, in project_id
12.02     self.__project_id = f'{self.normalize_file_name_component(self.metadata.core.name)}-{self.metadata.version}'
12.02   File "/tmp/.tmpMG46DF/environments-v0/.tmpOxLtHV/lib/python3.8/site-packages/hatchling/metadata/core.py", line 149, in version
12.02     self._version = self._get_version()
12.02   File "/tmp/.tmpMG46DF/environments-v0/.tmpOxLtHV/lib/python3.8/site-packages/hatchling/metadata/core.py", line 248, in _get_version
12.02     version = self.hatch.version.cached
12.02   File "/tmp/.tmpMG46DF/environments-v0/.tmpOxLtHV/lib/python3.8/site-packages/hatchling/metadata/core.py", line 1466, in cached
12.02     raise type(e)(message) from None
12.02 LookupError: Error getting the version from source `vcs`: setuptools-scm was unable to detect version for /code.
12.02 
12.02 Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.
12.02 
12.02 For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj
12.02 ---
------
Dockerfile:43
--------------------
  42 |     ENV PATH=/usr/local/venv/bin:"${PATH}"
  43 | >>> RUN python3 -m venv /usr/local/venv && \
  44 | >>>     . /usr/local/venv/bin/activate && \
  45 | >>>     cd /code && \
  46 | >>>     python -m pip --no-cache-dir install --upgrade uv && \
  47 | >>>     uv --no-cache pip install --upgrade pip wheel && \
  48 | >>>     uv --no-cache pip install \
  49 | >>>         lxml \
  50 | >>>         cryptography \
  51 | >>>         jq && \
  52 | >>>     uv --no-cache pip install '.[local,kubernetes,reana]' && \
  53 | >>>     recast --help
matthewfeickert commented 1 month ago

Ah, it was because I forgot to ensure that git was installed in the Docker build.