Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Use hatchling as build backend #145

Merged
merged 10 commits into from
Jun 16, 2024

Conversation

matthewfeickert
Copy link
Member

@matthewfeickert matthewfeickert commented Jun 16, 2024

  • Migrate to using hatchling as the build backend.
    • Include all build metadata in pyproject.toml.
    • Remove setup.py, setup.cfg, and MANIFEST.in.
    • Remove package_data as not needed.
  • Remove MANIFEST check from CI.
    • Remove check-manifest install in CI workflow.
    • Remove MANIFEST check step from CI.
  • Add git to Dockerfile to ensure hach-vcs can work.
  • Add .git_archival.txt to add archival options to support auto versioning.

* Migrate to using hatchling as the build backend.
   - Include all build metadata in pyproject.toml.
   - Remove setup.py, setup.cfg, and MANIFEST.in.
   - Remove package_data as not needed.
* Remove MANIFEST check from CI.
   - Remove check-manifest install in CI workflow.
   - Remove MANIFEST check step from CI.
@matthewfeickert
Copy link
Member Author

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
Copy link
Member Author

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

@matthewfeickert matthewfeickert merged commit 0fb609f into main Jun 16, 2024
10 checks passed
@matthewfeickert matthewfeickert deleted the build/use-hatchling-for-build branch June 16, 2024 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant