Skip to content

IndexError with my .gitignore file when trying to build a Python package #64

@haimat

Description

@haimat

Problem description

I am trying to package my Python project/library. So first I created a pyproject.toml file, following the official Python docs, using hatchling - no fancy stuff here. Then, after upgrading to the latest build version, I ran this command from within the root folder of my project:

$ python -m build
* Creating venv isolated environment...
* Installing packages in isolated environment... (hatchling)
* Getting build dependencies for sdist...
* Building sdist...
Traceback (most recent call last):
  File "/home/mfb/.local/lib/python3.8/site-packages/pep517/in_process/_in_process.py", line 351, in <module>
    main()
  File "/home/mfb/.local/lib/python3.8/site-packages/pep517/in_process/_in_process.py", line 333, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/home/mfb/.local/lib/python3.8/site-packages/pep517/in_process/_in_process.py", line 302, in build_sdist
    return backend.build_sdist(sdist_directory, config_settings)
  File "/tmp/build-env-bgb1kk5q/lib/python3.8/site-packages/hatchling/build.py", line 21, in build_sdist
    return os.path.basename(next(builder.build(sdist_directory, ['standard'])))
  File "/tmp/build-env-bgb1kk5q/lib/python3.8/site-packages/hatchling/builders/plugin/interface.py", line 144, in build
    artifact = version_api[version](directory, **build_data)
  File "/tmp/build-env-bgb1kk5q/lib/python3.8/site-packages/hatchling/builders/sdist.py", line 156, in build_standard
    for included_file in self.recurse_included_files():
  File "/tmp/build-env-bgb1kk5q/lib/python3.8/site-packages/hatchling/builders/plugin/interface.py", line 168, in recurse_included_files
    yield from self.recurse_project_files()
  File "/tmp/build-env-bgb1kk5q/lib/python3.8/site-packages/hatchling/builders/plugin/interface.py", line 182, in recurse_project_files
    if self.config.include_path(relative_file_path, is_package=is_package):
  File "/tmp/build-env-bgb1kk5q/lib/python3.8/site-packages/hatchling/builders/config.py", line 82, in include_path
    and (explicit or self.path_is_included(relative_path))
  File "/tmp/build-env-bgb1kk5q/lib/python3.8/site-packages/hatchling/builders/config.py", line 90, in path_is_included
    return self.include_spec.match_file(relative_path)
  File "/tmp/build-env-bgb1kk5q/lib/python3.8/site-packages/pathspec/pathspec.py", line 176, in match_file
    return self._match_file(self.patterns, norm_file)
  File "/tmp/build-env-bgb1kk5q/lib/python3.8/site-packages/pathspec/gitignore.py", line 104, in _match_file
    dir_mark = match.match.group('ps_d')
IndexError: no such group

ERROR Backend subprocess exited when trying to invoke build_sdist

I do have a .gitignore file in my root folder, however, it includes only the default Python project template from Github.

Any ideas what is causing this error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions