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

problems with GIT_DESCRIBE_NUMBER #1087

Closed
elehcim opened this issue Jul 2, 2016 · 9 comments
Closed

problems with GIT_DESCRIBE_NUMBER #1087

elehcim opened this issue Jul 2, 2016 · 9 comments
Labels
locked [bot] locked due to inactivity

Comments

@elehcim
Copy link

elehcim commented Jul 2, 2016

Hello, my recipe is like:

package:
  name: pkg
  version: {{ GIT_DESCRIBE_TAG }}

source:
  git_url: .
  git_rev: conda_pkg

build:
  number: {{ GIT_DESCRIBE_NUMBER }}
...

and is located in a git repo.

user@machine:pkg_git $ git status
On branch conda_pkg
Your branch is up-to-date with 'origin/conda_pkg'.
nothing to commit, working directory clean

If I perform a conda build ., this error is produced:

Traceback (most recent call last):
  File "/home/user/anaconda3/bin/conda-build", line 5, in <module>
    sys.exit(main())
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/main_build.py", line 144, in main
    args_func(args, p)
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/main_build.py", line 389, in args_func
    args.func(args, p)
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/main_build.py", line 287, in execute
    verbose=False, dirty=args.dirty)
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/render.py", line 135, in render_recipe
    verbose=verbose, dirty=dirty)
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/render.py", line 87, in parse_or_try_download
    metadata.parse_again(permit_undefined_jinja=False)
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/metadata.py", line 377, in parse_again
    self.meta = parse(self._get_contents(permit_undefined_jinja), path=self.meta_path)
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/metadata.py", line 666, in _get_contents
    env.globals.update(context_processor(self, path))
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/jinja_context.py", line 130, in context_processor
    ctx = get_environ(m=initial_metadata)
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/environ.py", line 174, in get_dict
    d.update(meta_vars(m))
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/environ.py", line 276, in meta_vars
    d['PKG_BUILDNUM'] = str(meta.build_number())
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/metadata.py", line 454, in build_number
    return int(self.get_value('build/number', 0))
ValueError: invalid literal for int() with base 10: ''

If I substitute:

build:
  number: {{ GIT_DESCRIBE_NUMBER }}

with

build:
  number: 0

it works and the package created is something like pkg-v0.2.2-76_g869cb67.tar.bz2

Stepping into /home/user/anaconda3/lib/python3.5/site-packages/conda_build/metadata.py:454 it seems that GIT_DESCRIBE_NUMBER is None...

Do you have any idea on why GIT_DESCRIBE_NUMBER is not working?
Thanks


$ conda build --version
conda-build 1.21.3

$ conda --version
conda 4.1.6
@msarahan
Copy link
Contributor

msarahan commented Jul 2, 2016

What does git describe --tag show?

How do you create your tags? If you are not annotating them, there might be issues. Note that tags created via the github web interface are lightweight, not annotated tags.

https://git-scm.com/book/en/v2/Git-Basics-Tagging#Annotated-Tags

To retroactively annotate tags:

git checkout <lightweight tag tagged via github>
git tag -a <same tag name>
<enter description/notes>
git push <github repo> --tags

If this does not work, then we have a bug, but I think this is the issue - we test this functionality in our integration tests, and have not seen an issue with the 1.21.3 release.

@elehcim
Copy link
Author

elehcim commented Jul 2, 2016

$ git describe --tag
v0.2.2-78-g3845222

v0.2.2 is annotated

@msarahan
Copy link
Contributor

msarahan commented Jul 2, 2016

OK, are these public repos (the source, and the recipe) that I can clone for debugging purposes?

@elehcim
Copy link
Author

elehcim commented Jul 2, 2016

No, I've created a repo here: https://github.com/elehcim/conda_git_dbg.git for which I can reproduce the issue.

$ conda create -n git_tag python
$ source activate git_tag
$ cd conda_git_dbg
$ git checkout conda_dbg
$ git describe --tag
ttt-1-g628dfb0
$ conda build .
Cloning into '/home/user/anaconda3/conda-bld/work'...
done.
Switched to a new branch 'conda_pkg'
An unexpected error has occurred, please consider sending the
following traceback to the conda GitHub issue tracker at:

    https://github.com/conda/conda-build/issues

Include the output of the command 'conda info' in your report.


Traceback (most recent call last):
  File "/home/user/anaconda3/bin/conda-build", line 5, in <module>
    sys.exit(main())
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/main_build.py", line 144, in main
    args_func(args, p)
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/main_build.py", line 389, in args_func
    args.func(args, p)
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/main_build.py", line 287, in execute
    verbose=False, dirty=args.dirty)
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/render.py", line 135, in render_recipe
    verbose=verbose, dirty=dirty)
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/render.py", line 87, in parse_or_try_download
    metadata.parse_again(permit_undefined_jinja=False)
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/metadata.py", line 377, in parse_again
    self.meta = parse(self._get_contents(permit_undefined_jinja), path=self.meta_path)
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/metadata.py", line 666, in _get_contents
    env.globals.update(context_processor(self, path))
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/jinja_context.py", line 130, in context_processor
    ctx = get_environ(m=initial_metadata)
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/environ.py", line 174, in get_dict
    d.update(meta_vars(m))
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/environ.py", line 276, in meta_vars
    d['PKG_BUILDNUM'] = str(meta.build_number())
  File "/home/user/anaconda3/lib/python3.5/site-packages/conda_build/metadata.py", line 454, in build_number
    return int(self.get_value('build/number', 0))
ValueError: invalid literal for int() with base 10: ''

$ conda info
Current conda install:

             platform : linux-64
        conda version : 4.1.6
    conda-env version : 2.5.1
  conda-build version : 1.21.3
       python version : 3.5.1.final.0
     requests version : 2.9.1
     root environment : /astri03/data1/mastropietro/anaconda3  (writable)
  default environment : /astri03/data1/mastropietro/anaconda3/envs/git_tag
     envs directories : /astri03/data1/mastropietro/anaconda3/envs
        package cache : /astri03/data1/mastropietro/anaconda3/pkgs
         channel URLs : https://repo.continuum.io/pkgs/free/linux-64/
                        https://repo.continuum.io/pkgs/free/noarch/
                        https://repo.continuum.io/pkgs/pro/linux-64/
                        https://repo.continuum.io/pkgs/pro/noarch/
          config file : None
         offline mode : False
    is foreign system : False

@elehcim
Copy link
Author

elehcim commented Jul 2, 2016

I've found a workaround. Changing to:

build:
  number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0)}}

works.

@msarahan
Copy link
Contributor

msarahan commented Jul 2, 2016

OK, thanks. That's helpful for debugging, though it should work either way. I'll update the tests and make sure.

@elehcim
Copy link
Author

elehcim commented Jul 2, 2016

maybe related to #357 ?

@msarahan
Copy link
Contributor

msarahan commented Jul 6, 2016

This should be fixed in conda-build 1.21.4, released yesterday. Closing this issue for now, but please reopen or comment here if you still have issues.

@msarahan msarahan closed this as completed Jul 6, 2016
@github-actions
Copy link

Hi there, thank you for your contribution!

This issue has been automatically locked because it has not had recent activity after being closed.

Please open a new issue if needed.

Thanks!

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Apr 22, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked [bot] locked due to inactivity
Projects
None yet
Development

No branches or pull requests

2 participants