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

Add option to include whole repository #443

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LecrisUT
Copy link

  • Added a section archiver with two options:
    • method ('git'/'tar'): How to create the tar ball
    • include_git (boolean): Whether to include .git folder

Still needs to be exposed to CLI as well. Please help me on that part.

Closes: #441

- Added a section archiver with two options:
  - method ('git'/'tar'): How to create the tar ball
  - include_git (boolean): Whether to include .git folder

Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
@LecrisUT
Copy link
Author

This one seems to error when running method=tar because of tarfixer. But at least include_git seems to work locally :)

@LecrisUT
Copy link
Author

Epel 7/8 seem to be using old python version. would really prefer the match: case instead of this. @FrostyX can you advise on what tarfixer does?

Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
@LecrisUT
Copy link
Author

Oh no, we have to make the code compatible all the way to python 2.7 😢

Copy link
Member

@FrostyX FrostyX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @LecrisUT,
thank you for the PR.

I was finally able to take a look.

if add_git_folder:
tar_append_cmd = f"tar --append -f {initial_tar} --transform 's|^{relative_git_dir}|{prefix}/|' {relative_git_dir}/.git"
run_command(tar_append_cmd)
elif method == 'tar':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some issues when using

[archiver]
method = tar

Traceback:

Traceback (most recent call last):
  File "/home/jkadlcik/git/tito/src/tito/cli.py", line 919, in <module>
    main()
  File "/home/jkadlcik/git/tito/src/tito/cli.py", line 910, in main
    CLI().main(sys.argv[1:])
  File "/home/jkadlcik/git/tito/src/tito/cli.py", line 209, in main
    return module.main(argv)
           ^^^^^^^^^^^^^^^^^
  File "/home/jkadlcik/git/tito/src/tito/cli.py", line 392, in main
    return builder.run(self.options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jkadlcik/git/tito/src/tito/builder/main.py", line 160, in run
    self.tgz()
  File "/home/jkadlcik/git/tito/src/tito/builder/main.py", line 577, in tgz
    self._setup_sources()
  File "/home/jkadlcik/git/tito/src/tito/builder/main.py", line 610, in _setup_sources
    create_tgz(self.git_root, self.tgz_dir, self.git_commit_id,
  File "/home/jkadlcik/git/tito/src/tito/common.py", line 895, in create_tgz
    tarfixer.fix()
  File "/home/jkadlcik/git/tito/src/tito/tar.py", line 325, in fix
    self.process_chunk(chunk)
  File "/home/jkadlcik/git/tito/src/tito/tar.py", line 292, in process_chunk
    chunk_props[member] = int(chunk_props[member], 8)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 8: ''

Reproducible when you run tito build --tgz within this project.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, that's where I wanted some help because I don't understand what the tarfixer does and why it fails like that.

@@ -427,6 +427,10 @@ def __init__(self, name=None, tag=None, build_dir=None,
self.tgz_dir = tgz_base
self.artifacts = []

# Details of how to make the tar repo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain these options in man tito.props?

@@ -427,6 +427,10 @@ def __init__(self, name=None, tag=None, build_dir=None,
self.tgz_dir = tgz_base
self.artifacts = []

# Details of how to make the tar repo
self.tgz_method = self.config.get('archiver', 'method', fallback='git')
self.tgz_include_git = self.config.getboolean('archiver', 'include_git', fallback=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the situations when

  • building a tarball from the last commit is useful
  • building a tarball from the code as is, even with uncommitted changes, is useful

but I can't imagine a situation when using a tarball from the last commit but also containing the .git directory is needed. Do you have a use-case for this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this was my problems when building scikit-build-core. It uses setuptools_scm that can detect the tags from the .git folder. They offer an alternative via .gitattributes and generating a .git_archival.txt file, but that also fails without #445. There could be similar projects, in which case that would be the easiest for prototyping or quickly setting up a build system.

Of course these would be discouraged for production releases.

@FrostyX
Copy link
Member

FrostyX commented Feb 28, 2023

Oh no, we have to make the code compatible all the way to python 2.7 cry

Yeah, that's always fun 😄
It's because we are releasing tito also for EPEL7.

But in your case it looks like an easyfix

Compiling /builddir/build/BUILDROOT/tito-tito.0.6.22.1-1.20230224162713711612.pr443.8.g7bce5fd.el7.x86_64/usr/lib/python2.7/site-packages/tito/common.py ...
  File "/usr/lib/python2.7/site-packages/tito/common.py", line 876
    tar_append_cmd = f"tar --append -f {initial_tar}  --transform 's|^{relative_git_dir}|{prefix}/|' {relative_git_dir}/.git"
                                                                                                                            ^
SyntaxError: invalid syntax

IIRC Python 2.7 doesn't have f-strings yet.

@FrostyX
Copy link
Member

FrostyX commented Feb 28, 2023

can you advise on what tarfixer does?

Please take a look here
https://github.com/rpm-software-management/tito/blob/master/src/tito/tar.py#L28-L60

@LecrisUT
Copy link
Author

can you advise on what tarfixer does?

Please take a look here https://github.com/rpm-software-management/tito/blob/master/src/tito/tar.py#L28-L60

Yeah, I've understood the basics that it is to fix the timestamps so that the tars are identical. But I don't quite understand why it would depend if the tar ball was created via git archive or tar -cf. Maybe we need to specify additional flags to indicate it's a gunzip?

Although, wouldn't this be irrelevant if we include the whole .git folder that is not properly versioned? Should we completely bypass it for these two methods?

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 this pull request may close these issues.

Flag to run with uncommitted changes
2 participants