Skip to content
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

fake_libc_include not included in distributed version of library #224

Closed
inglesp opened this issue Dec 4, 2017 · 9 comments
Closed

fake_libc_include not included in distributed version of library #224

inglesp opened this issue Dec 4, 2017 · 9 comments

Comments

@inglesp
Copy link

inglesp commented Dec 4, 2017

The fake_libc_include directory is not included in the version of the library installed from PyPI with pip.

This means that I cannot do something like:

pycparser_path = os.path.basename(pycparser.__file__)
include_path = os.path.join(pycparser_path, 'utils', 'fake_libc_include')
ast = parse_file(filename, use_cpp=True, cpp_args=rf'-I{include_path}')

Instead I have to vendor fake_libc_include (which is not the end of the world!).

Would you consider a patch to fix this?

@inglesp
Copy link
Author

inglesp commented Dec 4, 2017

s/consider/consider accepting/

@eliben
Copy link
Owner

eliben commented Dec 5, 2017

It's listed here: https://github.com/eliben/pycparser/blob/master/MANIFEST.in#L4

And I do see it in the distribution tarball -- are you sure pip doesn't install it?

@inglesp
Copy link
Author

inglesp commented Dec 7, 2017

I'm pretty sure... I've pip installed the libary into a fresh virtualenv, and it's not there:

~/.pyenv/versions/pycparser-test/lib/python3.6/site-packages/pycparser $ tree
.
├── __init__.py
├── __pycache__
│   ├── __init__.cpython-36.pyc
│   ├── _ast_gen.cpython-36.pyc
│   ├── _build_tables.cpython-36.pyc
│   ├── ast_transforms.cpython-36.pyc
│   ├── c_ast.cpython-36.pyc
│   ├── c_generator.cpython-36.pyc
│   ├── c_lexer.cpython-36.pyc
│   ├── c_parser.cpython-36.pyc
│   ├── lextab.cpython-36.pyc
│   ├── plyparser.cpython-36.pyc
│   └── yacctab.cpython-36.pyc
├── _ast_gen.py
├── _build_tables.py
├── _c_ast.cfg
├── ast_transforms.py
├── c_ast.py
├── c_generator.py
├── c_lexer.py
├── c_parser.py
├── lextab.py
├── ply
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-36.pyc
│   │   ├── cpp.cpython-36.pyc
│   │   ├── ctokens.cpython-36.pyc
│   │   ├── lex.cpython-36.pyc
│   │   ├── yacc.cpython-36.pyc
│   │   └── ygen.cpython-36.pyc
│   ├── cpp.py
│   ├── ctokens.py
│   ├── lex.py
│   ├── yacc.py
│   └── ygen.py
├── plyparser.py
└── yacctab.py

3 directories, 35 files

I'm using pip 9.0.1 and Python 3.6.0:

$ pip --version
pip 9.0.1 from /Users/inglesp/.pyenv/versions/3.6.0/envs/pycparser-test/lib/python3.6/site-packages (python 3.6)

This SO answer suggests that pip ignores top-level "non-package" directories, and that a solution would be to move the utils directory inside the pycparser directory.

@eliben
Copy link
Owner

eliben commented Dec 8, 2017

But moving it would break compatibility for projects that rely on it being there :)

I'd say I'm not too excited about making this change, to be completely honest. It's easy enough to distribute this directory with pycparser in some way, I don't know if I'd force it to be installed since it's not strictly necessary for the package (pycparser really wants to see preprocessed source code -- this dir is used by the preprocessor, not pycparser)

@inglesp
Copy link
Author

inglesp commented Dec 9, 2017

Sounds reasonable! Thanks for taking the time to respond.

@drebbe-intrepid
Copy link

If I submit a Pull Request for this feature, would you be willing to add it? I feel like I can add it without breaking anything since its not there to begin with. You'd have to make additions to setup.py as my understanding, the MANIFEST.in is just for the sdist packaging.

@eliben
Copy link
Owner

eliben commented Mar 25, 2021

@drebbe-intrepid I think I prefer not installing it. pycparser itself doesn't need or use it.

@danielv27
Copy link

For anyone still strugling I found this to work for me:

fake_libc_path = files('pycparser').joinpath('utils/fake_libc_include')
ast = parse_file(filename, use_cpp=True,
                 cpp_path='gcc',
                 cpp_args=['-E', r'-I{}'.format(fake_libc_path)])

Hope this helps. Also this only worked on Linux (Mac C libraries seemed to conflict

@dzid26
Copy link

dzid26 commented Jul 1, 2024

For anyone still strugling I found this to work for me:

fake_libc_path = files('pycparser').joinpath('utils/fake_libc_include')
ast = parse_file(filename, use_cpp=True,
                 cpp_path='gcc',
                 cpp_args=['-E', r'-I{}'.format(fake_libc_path)])

Hope this helps. Also this only worked on Linux (Mac C libraries seemed to conflict

I don't know what files does, but even so fake_libc_include is not present on my system. #413

A quick solution for me was this:
https://pypi.org/project/pycparser-fake-libc/

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

No branches or pull requests

5 participants