Skip to content

Add version parsing from Pipfile #1067

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aradkdj
Copy link

@aradkdj aradkdj commented Mar 27, 2025

Description:
Add version parsing from a Pipfile, passed through the python-version-file option.

Related issue:
#574

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

@aradkdj aradkdj requested a review from a team as a code owner March 27, 2025 03:04
@aradkdj aradkdj force-pushed the feature/add-version-parsing-from-Pipfile branch from f387444 to 0fc6a29 Compare May 30, 2025 23:11
@mahabaleshwars
Copy link
Contributor

Hi @aradkdj,
The checks are currently failing on your PR. Could you please address the issues and pull the latest updates from the main branch? Once that's done, we can proceed with the review.

Thanks!

@aradkdj aradkdj force-pushed the feature/add-version-parsing-from-Pipfile branch from 0fc6a29 to c44ab2e Compare June 4, 2025 03:16
@mahabaleshwars
Copy link
Contributor

Hi @aradkdj,
The checks are still failing. Please review the previous feedback comment, and let me know if you need any assistance to move forward.

@mahabaleshwars mahabaleshwars self-assigned this Jun 9, 2025
@aradkdj
Copy link
Author

aradkdj commented Jun 10, 2025

Sure. I took a look at it and could not figure out why it's failing on CI but not on the unit tests. Any pointer would be appreciated

@mahabaleshwars
Copy link
Contributor

Hi @aradkdj,
This issue is occurring due to an incorrect file name specified in the .yml file. It should be 'Pipfile' instead of 'Pipenv'. The logic performs a strict check on the file name:

else if (versionFile.match('Pipfile')) {
  return getVersionInputFromPipfileFile(versionFile);
}

Since 'Pipenv' doesn't match 'Pipfile', the corresponding logic isn't triggered. Please update the file name to resolve the issue.

@aradkdj aradkdj force-pushed the feature/add-version-parsing-from-Pipfile branch from c44ab2e to e87e3e9 Compare June 12, 2025 23:20
@aradkdj
Copy link
Author

aradkdj commented Jun 13, 2025

Sorry I missed that. It should be fixed now

@mahabaleshwars
Copy link
Contributor

Hi @aradkdj,
It looks like some checks are currently failing for this pull request. To help get this PR ready for review, could you please make sure your changes are up to date with the latest changes in setup-python? You can rebase or merge as necessary.

If you need any help interpreting the logs or fixing a specific error, feel free to share the error details here and we can assist further.

@aradkdj
Copy link
Author

aradkdj commented Jun 20, 2025

Merged and checked if the dist changes. But it didn't. If I understand the errors correctly they come from annotations about the installed pip version. Is there anything else I could do to fix it?

@mahabaleshwars
Copy link
Contributor

Hi @aradkdj,
It looks like the issue is still not resolved — your PR branch might be missing the latest changes from main. Please update your forked repo’s main branch with the upstream setup-python, and then merge those changes into your branch.
After updating, please rebuild the dist files and push the changes.

@aradkdj aradkdj force-pushed the feature/add-version-parsing-from-Pipfile branch 2 times, most recently from 4302de9 to 9485ba7 Compare June 25, 2025 17:02
@aradkdj aradkdj force-pushed the feature/add-version-parsing-from-Pipfile branch from 9485ba7 to ee0eb5b Compare July 4, 2025 21:50
@aradkdj aradkdj force-pushed the feature/add-version-parsing-from-Pipfile branch from ee0eb5b to b62f6a8 Compare July 6, 2025 00:45
@aradkdj
Copy link
Author

aradkdj commented Jul 6, 2025

@mahabaleshwars this should be passing now. Sorry for the delay

@HarithaVattikuti HarithaVattikuti requested a review from Copilot July 11, 2025 03:10
Copy link

@Copilot 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 PR adds support for parsing Python versions from a Pipfile via the python-version-file option.

  • Introduces getVersionInputFromPipfileFile and hooks it into getVersionInputFromFile.
  • Updates docs and CI workflows to demonstrate and test Pipfile usage.
  • Adds unit tests covering python_version, python_full_version, and empty Pipfile cases.

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/utils.ts Implement getVersionInputFromPipfileFile and integrate it
docs/advanced-usage.md Document how to use Pipfile with python-version-file
tests/utils.test.ts Add tests for Pipfile parsing scenarios
.github/workflows/test-python.yml Add Pipfile-based setup jobs for python_version and python_full_version
.github/workflows/test-python-freethreaded.yml Add equivalent Pipfile jobs in the freethreaded workflow

* Python version extracted from the Pipfile file.
*/
export function getVersionInputFromPipfileFile(versionFile: string): string[] {
core.debug(`Trying to resolve version form ${versionFile}`);
Copy link
Preview

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

There is a typo in the debug message: "version form" should be "version from".

Suggested change
core.debug(`Trying to resolve version form ${versionFile}`);
core.debug(`Trying to resolve version from ${versionFile}`);

Copilot uses AI. Check for mistakes.

}

core.info(`Extracted ${versions} from ${versionFile}`);
return [extractValue(pipfileConfig, keys)] as string[];
Copy link
Preview

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

This return ignores the previously built versions array and may return [undefined]. It should return versions to properly reuse the filtered values and handle missing versions.

Suggested change
return [extractValue(pipfileConfig, keys)] as string[];
return versions;

Copilot uses AI. Check for mistakes.

*/
export function getVersionInputFromPipfileFile(versionFile: string): string[] {
core.debug(`Trying to resolve version form ${versionFile}`);

Copy link
Preview

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

Consider checking if versionFile exists (e.g., with fs.existsSync) and emitting a warning before calling readFileSync to prevent unhandled exceptions.

Suggested change
if (!fs.existsSync(versionFile)) {
core.warning(`File ${versionFile} does not exist.`);
return [];
}

Copilot uses AI. Check for mistakes.

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.

2 participants