I am running Pylint on the GitHub actions. Before it runs, it installs the module playsound during the dependencies installation.
The checks all failed with Python 3.8, 3.9, and 3.10.
It seems to fail with the following error:
OSError: could not get source code
Do you have any idea to fix it?
Collecting playsound==1.3.0 (from -r requirements.txt (line 1))
Downloading playsound-1.3.0.tar.gz (7.7 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'error'
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [23 lines of output]
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-uqafiw95/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/tmp/pip-build-env-uqafiw95/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-uqafiw95/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 487, in run_setup
super(_BuildMetaLegacyBackend,
File "/tmp/pip-build-env-uqafiw95/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in run_setup
exec(code, locals())
File "<string>", line 6, in <module>
File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/inspect.py", line 1139, in getsource
lines, lnum = getsourcelines(object)
File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/inspect.py", line 1121, in getsourcelines
lines, lnum = findsource(object)
File "/opt/hostedtoolcache/Python/3.10.11/x64/lib/python3.10/inspect.py", line 958, in findsource
Error: raise OSError('could not get source code')
OSError: could not get source code
[end of output]
What I have tried so far is:
>>> pip uninstall wheel
>>> pip install playsound
>>> pip install wheel
This thread kindly suggested this procedure, but did not work for me.
@Azeem, Thanks for your suggestions! Let me summarize the details of what I have tried so far.
requirements.txt
playsound==1.3.0
.github/workflows/pylint.yml
name: Pylint
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pylint
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')
The installation with this requirements.txt
file works fine in the local environment with Python 3.10.9.
$ pip3 install -r requirements.txt
Collecting playsound==1.3.0
Downloading playsound-1.3.0.tar.gz (7.7 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: playsound
Building wheel for playsound (setup.py) ... done
Created wheel for playsound: filename=playsound-1.3.0-py3-none-any.whl size=7022 sha256=6d5b836046d0875702d97edb41c78ad993e0057fc50dab24783790b6bf83b36d
Stored in directory: /Users/username/Library/Caches/pip/wheels/24/f9/b3/2ed63b5d2a91bbf7da060acdc294c1335db338ec81f0c76e1b
Successfully built playsound
Installing collected packages: playsound
Successfully installed playsound-1.3.0
According to this thread, installing/upgrading wheel
worked.
I tried the same with your use case and it worked fine.
Here's the sample workflow that I used:
name: python_playsound_test
on: workflow_dispatch
jobs:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
mkdir test && cd test
echo 'playsound==1.3.0' > requirements.txt
python --version
pip --version
python -m pip install --upgrade pip
pip install --upgrade wheel
pip install -r requirements.txt
Here's the screenshot where it passed for the matrix: