Skip to content

Git not available in non editable installs#141

Open
juanep97 wants to merge 2 commits intomainfrom
fix_non_editable
Open

Git not available in non editable installs#141
juanep97 wants to merge 2 commits intomainfrom
fix_non_editable

Conversation

@juanep97
Copy link
Owner

@juanep97 juanep97 commented Oct 7, 2024

No description provided.

@juanep97 juanep97 added the bug Something isn't working label Oct 7, 2024
@juanep97 juanep97 requested a review from morcuended October 7, 2024 00:33
@juanep97 juanep97 changed the title Git will not be available in non editable installs Git not available in non editable installs Oct 7, 2024
@juanep97 juanep97 marked this pull request as ready for review October 7, 2024 03:29
@morcuended
Copy link

It should be possible to access this information directly with iop4.__version__ which follows the commit hashes for the dev versions. And actually, we should try to stick to released tagged versions for the production versions installed.

BTW the current link of the commit is pointing to a non-existing page: This site is currently running IOP4 dipol_exceptions @ v1.1.2-12-g9d12107.

Copy link

@morcuended morcuended left a comment

Choose a reason for hiding this comment

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

Looks good for now. I'll open a new issue as reminder to explore this:

It should be possible to access this information directly with iop4.version which follows the commit hashes for the dev versions. And actually, we should try to stick to released tagged versions for the production versions installed.

@juanep97 juanep97 force-pushed the main branch 4 times, most recently from a3b9847 to 5133fea Compare October 29, 2024 17:18
@juanep97 juanep97 force-pushed the main branch 2 times, most recently from 9c5eb31 to 0378af9 Compare December 22, 2024 03:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request addresses an issue where git commands fail in non-editable package installations (e.g., pip-installed packages) by wrapping git subprocess calls in a try-except block. When git is unavailable or the .git directory is missing, the code now gracefully falls back to "Unknown" values instead of raising an exception.

Changes:

  • Wrapped git subprocess calls in try-except block with fallback values
  • Added error logging when git information cannot be retrieved
  • Set GIT_COMMIT_HASH, GIT_BRANCH, and GIT_DESCRIBE to "Unknown" on failure

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +24 to +32
try:
GIT_COMMIT_HASH = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=os.path.dirname(os.path.realpath(__file__))).decode('ascii').strip()
GIT_BRANCH = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], cwd=os.path.dirname(os.path.realpath(__file__))).decode('ascii').strip()
GIT_DESCRIBE = subprocess.check_output(['git', 'describe', '--always'], cwd=os.path.dirname(os.path.realpath(__file__))).decode('ascii').strip()
except Exception as e:
logger.error(f"Error getting git info: {e}")
GIT_COMMIT_HASH = "Unknown"
GIT_BRANCH = "Unknown"
GIT_DESCRIBE = "Unknown"
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

The same git availability issue exists in docs/conf.py (lines 2-4) but hasn't been fixed there. The git commands in that file will fail in the same non-editable install scenario. Consider applying the same try-except wrapper pattern to docs/conf.py for consistency.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Copy link

Copilot AI commented Feb 24, 2026

@juanep97 I've opened a new pull request, #187, to work on those changes. Once the pull request is ready, I'll request review from you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants