yaml / pyyaml

Canonical source repository for PyYAML
MIT License
2.47k stars 507 forks source link

setup.py failed YAML extension check: no such file or directory: 'yaml/_yaml.c' #713

Closed mmathys closed 1 year ago

mmathys commented 1 year ago

Using:

python setup.py --with-libyaml install

throws me the following error:

...
installing library code to build/bdist.macosx-11.0-arm64/egg
running install_lib
running build_py
running build_ext
building 'yaml._yaml' extension
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/homebrew/Caskroom/miniforge/base/envs/env-test2/include -arch arm64 -fPIC -O2 -isystem /opt/homebrew/Caskroom/miniforge/base/envs/env-test2/include -arch arm64 -I/usr/local/opt/llvm/include -I/opt/homebrew/Caskroom/miniforge/base/envs/env-test2/include/python3.8 -c yaml/_yaml.c -o build/temp.macosx-11.0-arm64-cpython-38/yaml/_yaml.o
clang: error: no such file or directory: 'yaml/_yaml.c'
clang: error: no input files
error: command '/usr/bin/clang' failed with exit code 1

Using: macOS 13.3.1 on M1, Python 3.8.

Also, why is setup.py searching for yaml/_yaml.c? It doesn't seem to exist in the repo.

aplaice commented 1 year ago

AFAIU yaml.c is automatically generated by cython. In order to get yaml/_yaml.c you need to have cython installed. (For instance, pip install cython.)

Cschau0701vip commented 1 year ago

Hi there, We're also getting same issue in our azure CI-CD pipelines. Please find the error logs below:

Searching for pyYAML>=6.0.0
Reading https://pypi.org/simple/pyYAML/
Downloading https://files.pythonhosted.org/packages/36/2b/61d51a2c4f25ef062ae3f74576b01638bebad5e045f747ff12643df63844/PyYAML-6.0.tar.gz#sha256=68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2
Best match: PyYAML 6.0
Processing PyYAML-6.0.tar.gz
Writing /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/easy_install-9fzd5cr8/PyYAML-6.0/setup.cfg
Running PyYAML-6.0/setup.py -q bdist_egg --dist-dir /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/easy_install-9fzd5cr8/PyYAML-6.0/egg-dist-tmp-ks3f36u2
warning: no files found matching 'README'
clang: error: no such file or directory: 'yaml/_yaml.c'
clang: error: no input files
Error compiling module, falling back to pure Python
zip_safe flag not set; analyzing archive contents...
No eggs found in /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/easy_install-9fzd5cr8/PyYAML-6.0/egg-dist-tmp-ks3f36u2 (setup script problem?)
error: The 'pyYAML>=6.0.0' distribution was not found and is required by devops-toolbox
##[error]Bash exited with code '1'.

I've tried installing cython in our pipeline but it didn't work.

Could you please help?

nitzmahone commented 1 year ago

No idea what tooling or version of Python you're using to install there, but it looks positively ancient and clearly doesn't support modern Python packages well, as it's directly invoking setup.py and using easy_install, both of which have been deprecated for years and will make your life difficult. If you use a recent-ish Python with a modern pip, all should "just work", but can't help you with obsolete tooling.

Closing this issue as "working as designed".

nitzmahone commented 1 year ago

... and for the OP, if still struggling with this: we weren't able to support the Apple-provided Python 3.8 with our Apple Silicon wheels, but things will generally build fine on that Python if you have a modern pip and the necessary compilers/libyaml headers installed. It looks like you've got a similar problem- using some kind of ancient tooling that's not PEP517-aware (since it's trying to build an egg instead of a wheel)- use a modern version of pip and/or anything newer than the Apple-provided Python 3.8 to install and it should build everything properly.