Open kloczek opened 1 year ago
This appears to be an issue with your environment rather than the CLI. We recommend using v2 and following the documentation here on installing the CLI. You can refer to the source distribution documentation for building and installing from source if that would address your use case.
Again: hardcoding python executable name and not use sys.executable
has nothing to do with my build env.
Please rename temporary your build env python executable name to for example python.foo
and you will see the same fails.
@kloczek could you provide a link to where you're observing hardcoded python values?
From the log you provided, you're trying to run the integration tests that make live calls to AWS services without an account setup.
def add_auth(self, request):
if self.credentials is None:
> raise NoCredentialsError()
E botocore.exceptions.NoCredentialsError: Unable to locate credentials
Please have look on errors like below:
DEBUG awscli.tests.integration:testutils.py:565 stderr: /bin/sh: line 1: python: command not found
BTW units failing with missing credentials: it would be good to skip those units if pytest is executed with -m "not network"
Can you expand on your use case for building/testing when not connected to a network?
Looks like units which are failing with missing credentials generally need access to public network over which are reached some AWS services. Above log was generated on manual build on my devel system however prod packages is intentionally cut off from access to public network. Many other pyton modules test suites already uses pytest mark 'network` convention which allows skip units execution which needs such access. Ergo: I'm asking to use the same convention.
Just tested 1.29.3 and looks lik enow more units are failing.
Define a Custom pytest Mark: You can create a custom pytest mark, let's call it @pytest.mark.requires_network, to indicate that a test requires access to the public network.
python Copy code
import pytest
pytest.mark.requires_network = pytest.mark.skipif( not pytest.config.getoption("--allow-network"), reason="Test requires access to the public network", ) Use the Custom Mark in Tests: In your test functions, use the @pytest.mark.requires_network decorator to mark tests that need network access.
python Copy code import pytest
@pytest.mark.requires_network def test_something_that_needs_network_access():
Configure pytest for Network Access: When running tests in a non-production environment where network access is allowed (e.g., on your development system), you can pass a command-line option to pytest to enable tests that require network access:
bash Copy code pytest --allow-network Configure pytest for Production: In your production environment, you can run pytest without the --allow-network option, and tests marked with @pytest.mark.requires_network will be skipped.
By following this convention, you can ensure that tests that require network access are only executed when explicitly allowed, which helps prevent unintended network access in production environments.
Make sure to document this convention in your test suite's documentation or README file so that team members are aware of how to use it effectively.
I can only add that network
as exact mark name is already used in many other pytest based test suites.
I would highly recommend use exactly that mark name.
Nevertheless this ticket mainly is about hardcoded pyton executable name 😋
Just found that on top of already reported issues in 1.32.9 two new units started failing
Describe the bug in the file for the fit and progress dialogue submission.
Expected Behavior
All is described in ticket. Test suite uses hardcoded python interpreter name. It should be used sys.executable
I apologize for the misunderstanding, Tomasz. As an open-source developer, your contributions are indeed individual but extremely valuable. The changes you’ve suggested regarding the hardcoded Python interpreter name and the network mark name are insightful. I encourage you to raise a pull request with these changes, as it would not only solve the issue but also benefit others who are using the same codebase. Open-source projects thrive on such collaborative efforts. Thank you for your dedication to improving this project.
Best regards, Simardeep Singh
Fork the Repository: Go to the GitHub page of the repository you want to contribute to and click on the ‘Fork’ button at the top right corner. This will create a copy of the repository in your GitHub account.
Clone the Forked Repository: Now, clone the forked repository to your local machine using the command: git clone https://github.com/YourUsername/RepositoryName.git.
Create a New Branch: It’s a good practice to create a new branch for each PR. You can create a new branch using: git checkout -b branch-name.
Make Changes: Navigate to the file where the Python interpreter name is hardcoded and replace it with sys.executable. Also, update the network mark name as per your suggestion.
Commit Your Changes: After making the changes, stage them for a commit using: git add .. Commit the changes with a meaningful commit message: git commit -m "commit message".
Push Changes: Push the changes to your forked repository on GitHub: git push origin branch-name.
Create a Pull Request: Go to your forked repository on GitHub and click on ‘Compare & pull request’ button. Fill in the title and description for the changes you made and then click on ‘Create pull request’.
Remember to clearly describe the changes you’ve made in the PR description. This will make it easier for the maintainers to understand and review your changes.
Sincerely, Simardeep Singh
Describe the bug
Looks like many pytest units are failing because it uses hardcoded
python
orpython.exe
python executable name.Expected Behavior
Instead using
pyhon
orpython.exe
it should be usedsys.executable
.Current Behavior
Here is pytest summary output
Reproduction Steps
I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.
python3 -sBm build -w --no-isolation
build
with--no-isolation
I'm using during all processes only locally installed modulescut off from access to the public network
(pytest is executed with-m "not network"
)Possible Solution
Instead hardcode python executable name it should be used
sys.executable
.Additional Information/Context
In summary there are some pytest warnings as well. Here is fill pytest output as attachment python-awscli.FAIL.txt
CLI version used
1.27.146
Environment details (OS name and version, etc.)
Linux x86/64