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

versioningit use makes packaging impossible #25

Closed
mgorny opened this issue Aug 14, 2023 · 5 comments
Closed

versioningit use makes packaging impossible #25

mgorny opened this issue Aug 14, 2023 · 5 comments

Comments

@mgorny
Copy link

mgorny commented Aug 14, 2023

The new 0.6.4 release started using versioningit. Unfortunately, this makes packaging hard to impossible for Linux distributions since versioningit refuses to support using GitHub archives (see jwodder/versioningit#45), and this is the only source we can use that includes the test suite.

Could you please consider switching to a more portable alternative such as setuptools-scm?

@bakert
Copy link
Member

bakert commented Aug 14, 2023

Oh, that's a shame. I'm not 100% clear on why we added it or what it does for us but I'll look into removing it.

Cc @sarnold who added it in case he has an opinion about this.

@bakert
Copy link
Member

bakert commented Aug 20, 2023

@mgorny I read the issue you referenced but it doesn't seem to have anything to do with GitHub archives. Can you elaborate a bit more? Thanks!

@mgorny
Copy link
Author

mgorny commented Aug 20, 2023

Perhaps the bug is more focused on the "usual" solution that the problem itself. Versioningit doesn't work with GitHub archives:

$ wget -q https://github.com/PennyDreadfulMTG/pystache/archive/v0.6.4.tar.gz
$ tar -xf v0.6.4.tar.gz
$ cd pystache-0.6.4
$ python -m build -w
* Creating virtualenv isolated environment...
* Installing packages in isolated environment... (setuptools>=42, versioningit >= 1.1.1)
* Getting build dependencies for wheel...
Traceback (most recent call last):
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/versioningit/git.py", line 146, in ensure_is_repo
    self.read(
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/versioningit/git.py", line 178, in read
    return readcmd("git", *args, cwd=str(self.path), **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/versioningit/util.py", line 71, in readcmd
    s = runcmd(*args, stdout=subprocess.PIPE, text=True, **kwargs).stdout
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/versioningit/util.py", line 66, in runcmd
    return subprocess.run(arglist, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/subprocess.py", line 571, 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 "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/versioningit/core.py", line 257, in run
    description = self.do_vcs()
                  ^^^^^^^^^^^^^
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/versioningit/core.py", line 321, in do_vcs
    description = self.vcs(project_dir=self.project_dir)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/versioningit/methods.py", line 162, in __call__
    return self.method(params=self.params, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/versioningit/git.py", line 225, in describe_git
    repo.ensure_is_repo()
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/versioningit/git.py", line 156, in ensure_is_repo
    raise NotVCSError(f"{self.path} is not in a Git repository")
versioningit.errors.NotVCSError: /tmp/pystache-0.6.4 is not in a Git repository

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/versioningit/core.py", line 539, in get_version_from_pkg_info
    Path(project_dir, "PKG-INFO").read_text(encoding="utf-8")
  File "/usr/lib/python3.12/pathlib.py", line 1028, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/pathlib.py", line 1014, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pystache-0.6.4/PKG-INFO'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/versioningit/hook.py", line 23, in setuptools_finalizer
    report = vgit.run(write=True, fallback=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/versioningit/core.py", line 280, in run
    version=get_version_from_pkg_info(self.project_dir)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/versioningit/core.py", line 542, in get_version_from_pkg_info
    raise NotSdistError(f"{project_dir} does not contain a PKG-INFO file")
versioningit.errors.NotSdistError: /tmp/pystache-0.6.4 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.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
    main()
  File "/usr/lib/python3.12/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.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
    return hook(config_settings)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/setuptools/build_meta.py", line 355, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=['wheel'])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/setuptools/build_meta.py", line 325, in _get_build_requires
    self.run_setup()
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/setuptools/build_meta.py", line 341, in run_setup
    exec(code, locals())
  File "<string>", line 6, in <module>
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/setuptools/__init__.py", line 107, in setup
    return distutils.core.setup(**attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 147, in setup
    _setup_distribution = dist = klass(attrs)
                                 ^^^^^^^^^^^^
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/setuptools/dist.py", line 485, in __init__
    _Distribution.__init__(
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 283, in __init__
    self.finalize_options()
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/setuptools/dist.py", line 926, in finalize_options
    ep(self)
  File "/tmp/build-env-3jknpl1u/lib/python3.12/site-packages/versioningit/hook.py", line 28, in setuptools_finalizer
    raise RuntimeError(
RuntimeError: 
versioningit could not find a version for the project in /tmp/pystache-0.6.4!

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

This is normal because there's no way it can detect the version from that. Other packages such as setuptools-scm and pdm-backend provide an ability to provide the version externally via an environment variable to support these archives. That's what was requested in the bug.

mgorny added a commit to mgorny/pystache that referenced this issue Aug 24, 2023
Switch from the versioningit package to more commonly used
setuptools-scm.  It serves the same purpose but it is more mature
and it supports building from GitHub archives.

Fixes PennyDreadfulMTG#25
@bakert
Copy link
Member

bakert commented Aug 26, 2023

Fixed by @sarnold in #28

@bakert bakert closed this as completed Aug 26, 2023
@mgorny
Copy link
Author

mgorny commented Aug 27, 2023

Thanks!

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

Successfully merging a pull request may close this issue.

2 participants