GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Add support for custom PyPI repository configuration by heckerdj · Pull Request #1260 · actions/setup-python ConversationDescriptionThis PR adds the ability to configure pip to use a custom PyPI repository with authentication credentials through the setup-python action. This addresses the need for users working in enterprise environments where:
Changes
Usage Examplesteps: - uses: actions/checkout@v5 - uses: actions/setup-python@v6 with: python-version: '3.13' pypi-url: ${{ secrets.PYPI_REPO_URL }} pypi-username: ${{ secrets.PYPI_USER }} pypi-password: ${{ secrets.PYPI_PASSWORD }} - run: pip install -r requirements.txt TestingAll unit tests pass successfully:
Fixes #814
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions- Add pypi-url, pypi-username, and pypi-password inputs to action.yml - Implement configurePipRepository() function in utils.ts to create pip.conf/pip.ini - Integrate pip configuration into setup-python.ts workflow - Add comprehensive unit tests for pip configuration functionality - Update README.md with usage examples and documentation - Automatically mask credentials in logs for security Fixes actions#814
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pull request overviewThis PR adds support for configuring pip to use custom PyPI repositories with authentication, enabling users in enterprise environments to work with internal package indices (Nexus, Artifactory, etc.) when public PyPI is blocked or security-scanned packages are required. Key changes:
Reviewed changesCopilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments. Show a summary per file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Co-authored-by: Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pull request overviewCopilot reviewed 5 out of 5 changed files in this pull request and generated 9 comments. 💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Comment on lines
+383
to
+486
|
| } catch (error) { | ||
| core.setFailed( | ||
| `Failed to create pip config file at ${configPath}: ${error}` | ||
| ); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
When core.setFailed() is called, it doesn't throw an error or stop execution. The function continues to execute and returns normally. This means that if the config file write fails, the workflow step will be marked as failed but subsequent operations (like pip install) may still attempt to run. Consider throwing an error after setFailed() or restructuring the error handling to ensure the promise rejects.
| ); | |
| ); | |
| throw error instanceof Error | |
| ? error | |
| : new Error( | |
| `Failed to create pip config file at ${configPath}: ${error}` | |
| ); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| core.setFailed( | ||
| `Failed to create pip config file at ${configPath}: ${error}` |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The error object is being directly interpolated into a string, which may not provide useful information. Error objects should be accessed via their message property or converted to string explicitly for better error reporting.
| core.setFailed( | |
| `Failed to create pip config file at ${configPath}: ${error}` | |
| const errorMessage = | |
| error instanceof Error ? error.message : String(error); | |
| core.setFailed( | |
| `Failed to create pip config file at ${configPath}: ${errorMessage}` |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| export async function configurePipRepository( | ||
| pypiUrl: string, | ||
| username?: string, | ||
| password?: string | ||
| ): Promise<void> { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The function is declared as async but doesn't use any await operations. The async keyword is unnecessary and adds overhead. Either remove the async keyword and change the return type from Promise to void, or if file operations should be asynchronous for consistency, use the async versions of fs methods like fs.promises.writeFile.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const homeDir = process.env.HOME || process.env.USERPROFILE || ''; | ||
| const configDir = IS_WINDOWS | ||
| ? path.join(homeDir, 'pip') | ||
| : path.join(homeDir, '.pip'); | ||
| const configFile = IS_WINDOWS ? 'pip.ini' : 'pip.conf'; | ||
| const configPath = path.join(configDir, configFile); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If both HOME and USERPROFILE environment variables are undefined or empty, homeDir will be an empty string, resulting in config paths like 'pip/pip.ini' or '.pip/pip.conf' in the current working directory instead of the user's home directory. This could cause pip configuration issues. Consider validating that homeDir is not empty and throwing an error or logging a warning if it cannot be determined.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
|
||
| // Write the config file | ||
| try { | ||
| fs.writeFileSync(configPath, configContent, {encoding: 'utf8'}); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The config file is written with destructive writeFileSync, which will overwrite any existing pip configuration. If users have existing pip.conf/pip.ini files with other settings (like trusted-hosts, timeout values, etc.), they will be lost. Consider reading and merging with existing configuration, or at minimum documenting this behavior and warning users.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
Hello, @heckerdj is this PR going to be merged anytime soon? 🙏 This functionality is great and would be really useful to us. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
At least 1 approving review is required to merge this pull request.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Optional ability to set the pypi repository and credentials to be used by pip on the runner
There was an error while loading. Please reload this page.