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

3.1.0: missing functionality to allow build module without git repo #82

Closed
kloczek opened this issue Apr 1, 2024 · 5 comments
Closed

Comments

@kloczek
Copy link

kloczek commented Apr 1, 2024

Trying to package pg8000 I fond that one functionality is missing.

In case of building package which uses versioningit from sdist tar ball and from autogenerated tar ball from git tag all other modules like setuptools-scm, pdm-backend or hatch-vcs is possible to inject module version over env variable.
setuptools-scm uses $SETUPTOOLS_SCM_PRETEND_VERSION, pdm-backend uses $PDM_BUILD_SCM_VERSION and hatch-vcs uses $PBR_VERSION.

Looking on versioningit code I cannot find similar functionality 🤔
It causes that for example on building pg8000 using pep517 based build procedure it fails with

+ /usr/bin/python3 -sBm build -w --no-isolation
* Getting build dependencies for wheel...
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/versioningit/git.py", line 152, in ensure_is_repo
    self.read(
  File "/usr/lib/python3.9/site-packages/versioningit/git.py", line 184, in read
    return readcmd("git", *args, cwd=str(self.path), **kwargs)
  File "/usr/lib/python3.9/site-packages/versioningit/util.py", line 71, in readcmd
    s = runcmd(*args, stdout=subprocess.PIPE, text=True, **kwargs).stdout
  File "/usr/lib/python3.9/site-packages/versioningit/util.py", line 66, in runcmd
    return subprocess.run(arglist, **kwargs)
  File "/usr/lib64/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', 'rev-parse', '--is-inside-work-tree']' returned non-zero exit status 128.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/versioningit/core.py", line 260, in run
    description = self.do_vcs()
  File "/usr/lib/python3.9/site-packages/versioningit/core.py", line 324, in do_vcs
    description = self.vcs(project_dir=self.project_dir)
  File "/usr/lib/python3.9/site-packages/versioningit/methods.py", line 162, in __call__
    return self.method(params=self.params, **kwargs)
  File "/usr/lib/python3.9/site-packages/versioningit/git.py", line 229, in describe_git
    repo.ensure_is_repo()
  File "/usr/lib/python3.9/site-packages/versioningit/git.py", line 162, in ensure_is_repo
    raise NotVCSError(f"{self.path} is not in a Git repository")
versioningit.errors.NotVCSError: /home/tkloczko/rpmbuild/BUILD/pg8000-1.31.0 is not in a Git repository

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/versioningit/core.py", line 548, in get_version_from_pkg_info
    Path(project_dir, "PKG-INFO").read_text(encoding="utf-8")
  File "/usr/lib64/python3.9/pathlib.py", line 1266, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib64/python3.9/pathlib.py", line 1252, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/lib64/python3.9/pathlib.py", line 1120, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/tkloczko/rpmbuild/BUILD/pg8000-1.31.0/PKG-INFO'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/versioningit/hook.py", line 23, in setuptools_finalizer
    report = vgit.run(write=True, fallback=True)
  File "/usr/lib/python3.9/site-packages/versioningit/core.py", line 283, in run
    version=get_version_from_pkg_info(self.project_dir)
  File "/usr/lib/python3.9/site-packages/versioningit/core.py", line 551, in get_version_from_pkg_info
    raise NotSdistError(f"{project_dir} does not contain a PKG-INFO file")
versioningit.errors.NotSdistError: /home/tkloczko/rpmbuild/BUILD/pg8000-1.31.0 does not contain a PKG-INFO file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
    main()
  File "/usr/lib/python3.9/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/usr/lib/python3.9/site-packages/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
    return hook(config_settings)
  File "/usr/lib/python3.9/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=['wheel'])
  File "/usr/lib/python3.9/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
    self.run_setup()
  File "/usr/lib/python3.9/site-packages/setuptools/build_meta.py", line 311, in run_setup
    exec(code, locals())
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.9/site-packages/setuptools/__init__.py", line 103, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 147, in setup
    _setup_distribution = dist = klass(attrs)
  File "/usr/lib/python3.9/site-packages/setuptools/dist.py", line 303, in __init__
    _Distribution.__init__(self, dist_attrs)
  File "/usr/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 283, in __init__
    self.finalize_options()
  File "/usr/lib/python3.9/site-packages/setuptools/dist.py", line 654, in finalize_options
    ep(self)
  File "/usr/lib/python3.9/site-packages/versioningit/hook.py", line 28, in setuptools_finalizer
    raise RuntimeError(
RuntimeError:
versioningit could not find a version for the project in /home/tkloczko/rpmbuild/BUILD/pg8000-1.31.0!

You may be installing from a shallow clone, in which case you need to unshallow it first.

Alternatively, you may be installing from a Git archive, which is not supported by default.  Install from a git+https://... URL instead.



ERROR Backend subprocess exited when trying to invoke get_requires_for_build_wheel
@jwodder
Copy link
Owner

jwodder commented Apr 9, 2024

versioningit can only be used for projects that are built from one or more of the following:

  • a Git or Mercurial repository
  • an sdist
  • a Mercurial archive
  • (git-archive vcs method only) a Git archive created from a Git repository that was prepared as described in the documentation

Regarding support for fetching the version from an environment variable, see #45.

Do you have any remaining questions or specific feature requests, or can this issue be closed now?

@jwodder
Copy link
Owner

jwodder commented Apr 23, 2024

Closing due to lack of response from OP.

@jwodder jwodder closed this as not planned Won't fix, can't repro, duplicate, stale Apr 23, 2024
@kloczek
Copy link
Author

kloczek commented Sep 12, 2024

Why not use more often used setuptools-scm? 🤔

@jwodder
Copy link
Owner

jwodder commented Sep 12, 2024

@kloczek I'm not sure I understand your question. If you just want a comparison of versioningit vs. setuptools-scm, see #46.

@kloczek
Copy link
Author

kloczek commented Sep 13, 2024

seuptools-scm provides reading dynamically version from got repo metadata and has additionally abilities to work with source tree without git metadata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants