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

DUPLEX_UNKNOWN undefined on redhat #607

Closed
wiggin15 opened this issue Mar 12, 2015 · 12 comments
Closed

DUPLEX_UNKNOWN undefined on redhat #607

wiggin15 opened this issue Mar 12, 2015 · 12 comments
Labels

Comments

@wiggin15
Copy link
Collaborator

When installing the current version on Redhat, we get this error:

psutil/_psutil_linux.c: In function ‘psutil_net_if_stats’:
psutil/_psutil_linux.c:524: error: ‘DUPLEX_UNKNOWN’ undeclared (first use in this function)
psutil/_psutil_linux.c:524: error: (Each undeclared identifier is reported only once
psutil/_psutil_linux.c:524: error: for each function it appears in.)
psutil/_psutil_linux.c: In function ‘init_psutil_linux’:
psutil/_psutil_linux.c:676: error: ‘DUPLEX_UNKNOWN’ undeclared (first use in this function)
error: Setup script exited with error: command 'gcc' failed with exit status 1

The header that should include this definition (linux/ethtool.h) exists, but doesn't include this definition.

@giampaolo
Copy link
Owner

Mmmmm weird. Please paste the output of "make clean; make build". What I fear is that on Red Hat you need to tell the compiler to include linux/ethtool.h from setup.py as in something like this:

diff --git a/setup.py b/setup.py
index 54a70c4..50e6be6 100644
--- a/setup.py
+++ b/setup.py
@@ -122,7 +122,8 @@ elif sys.platform.startswith("linux"):
     extensions = [Extension(
         'psutil._psutil_linux',
         sources=['psutil/_psutil_linux.c'],
-        define_macros=[VERSION_MACRO]),
+        define_macros=[VERSION_MACRO],
+        libraries=["ethtool"]),
         posix_extension,
     ]
 # Solaris

@wiggin15
Copy link
Collaborator Author

Adding ethtool to libraries changes the linking process, but the error is during the compilation process so it doesn't have any effect. The problem is not that ethtool.h is not included (it is), but that that file doesn't include the required constant (I opened the file and checked).
Running make build prints the same output from above.

@giampaolo
Copy link
Owner

I'm looking for the output preceding what you pasted above. Please paste it all.

@wiggin15
Copy link
Collaborator Author

root@host-ci16 (Redhat 6.1) ➜  psutil git:(master) make clean; make build                                                                                                                                                                                    15-03-12 19:07
rm -f `find . -type f -name \*.py[co]`
rm -f `find . -type f -name \*.so`
rm -f `find . -type f -name .\*~`
rm -f `find . -type f -name \*.orig`
rm -f `find . -type f -name \*.bak`
rm -f `find . -type f -name \*.rej`
rm -rf `find . -type d -name __pycache__`
rm -rf *.core
rm -rf *.egg-info
rm -rf *\estfile*
rm -rf .tox
rm -rf build
rm -rf dist
rm -rf docs/_build
rm -f `find . -type f -name \*.py[co]`
rm -f `find . -type f -name \*.so`
rm -f `find . -type f -name .\*~`
rm -f `find . -type f -name \*.orig`
rm -f `find . -type f -name \*.bak`
rm -f `find . -type f -name \*.rej`
rm -rf `find . -type d -name __pycache__`
rm -rf *.core
rm -rf *.egg-info
rm -rf *\estfile*
rm -rf .tox
rm -rf build
rm -rf dist
rm -rf docs/_build
python setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/psutil
copying psutil/__init__.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_compat.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pssunos.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pslinux.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pswindows.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psbsd.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psosx.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psposix.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_common.py -> build/lib.linux-x86_64-2.7/psutil
running build_ext
building 'psutil._psutil_linux' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/psutil
gcc -pthread -fno-strict-aliasing -I/root/python/include -I/root/python/include/gnutls -I/root/python/include/graphviz -I/root/python/include/libexslt -I/root/python/include/libxml2 -I/root/python/include/libxslt -I/root/python/include/ncurses -I/root/python/include/openssl -I/root/python/include/readline -I/root/python/include/sasl -I/root/python/lib64/libffi-3.0.13/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSUTIL_VERSION=300 -I/root/python/include/python2.7 -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_linux.o
psutil/_psutil_linux.c: In function ‘psutil_net_if_stats’:
psutil/_psutil_linux.c:524: error: ‘DUPLEX_UNKNOWN’ undeclared (first use in this function)
psutil/_psutil_linux.c:524: error: (Each undeclared identifier is reported only once
psutil/_psutil_linux.c:524: error: for each function it appears in.)
psutil/_psutil_linux.c: In function ‘init_psutil_linux’:
psutil/_psutil_linux.c:676: error: ‘DUPLEX_UNKNOWN’ undeclared (first use in this function)
error: command 'gcc' failed with exit status 1
make: *** [build] Error 1

I tested this on Redhat 6.1 and Redhat 5.6. It does work on Redhat 7.0 (probably a newer version of kernel-headers package)

@giampaolo
Copy link
Owner

Mmmm... you said the constants are defined in linux/ethtool.h right? In this case I guess have no idea.

@giampaolo
Copy link
Owner

The compiler complains about DUPLEX_UNKNOWN only though. DUPLEX_HALF and DUPLEX_FULL seem to be there. That's also weird. Maybe those red hat versions are missing DUPLEX_UNKNOWN?

@wiggin15
Copy link
Collaborator Author

Yes, exactly.
Adding these lines fixes the issue:

#ifndef DUPLEX_UNKNOWN
#define DUPLEX_UNKNOWN      0xff
#endif

@giampaolo
Copy link
Owner

Cool. I'll fix that.

@giampaolo
Copy link
Owner

In the meantime can you try to do that and see if tests pass?

@giampaolo
Copy link
Owner

Fixed. Can you confirm it works (also run "make test")?

@wiggin15
Copy link
Collaborator Author

Looks like there's some work ahead...

root@host-ci80 (Redhat 5.6) ➜  psutil git:(master) make test                                                                                                                                                                                                   15-03-15 10:38
rm -f `find . -type f -name \*.py[co]`
rm -f `find . -type f -name \*.so`
rm -f `find . -type f -name .\*~`
rm -f `find . -type f -name \*.orig`
rm -f `find . -type f -name \*.bak`
rm -f `find . -type f -name \*.rej`
rm -rf `find . -type d -name __pycache__`
rm -rf *.core
rm -rf *.egg-info
rm -rf *\estfile*
rm -rf .tox
rm -rf build
rm -rf dist
rm -rf docs/_build
python setup.py build
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/psutil
copying psutil/_compat.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pssunos.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/__init__.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_common.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psposix.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psosx.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pslinux.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psbsd.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pswindows.py -> build/lib.linux-x86_64-2.7/psutil
running build_ext
building 'psutil._psutil_linux' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/psutil
gcc -pthread -fno-strict-aliasing -I/root/python/include -I/root/python/include/gnutls -I/root/python/include/graphviz -I/root/python/include/libexslt -I/root/python/include/libxml2 -I/root/python/include/libxslt -I/root/python/include/ncurses -I/root/python/include/openssl -I/root/python/include/readline -I/root/python/include/sasl -I/root/python/lib64/libffi-3.0.13/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSUTIL_VERSION=300 -I/root/python/include/python2.7 -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_linux.o
psutil/_psutil_linux.c: In function ‘psutil_proc_cpu_affinity_get’:
psutil/_psutil_linux.c:365: warning: ‘py_cpu_num’ is used uninitialized in this function
gcc -pthread -shared -L/root/python/lib64 -Wl,-rpath,$ORIGIN,-rpath,$ORIGIN/../lib64,-rpath-link,$ORIGIN,-rpath-link,$ORIGIN/../lib64 -Wl,-rpath,$ORIGIN/../.. -L/root/python/lib64/engines -L/root/python/lib64/gettext -L/root/python/lib64/graphviz -L/root/python/lib64/libffi-3.0.13 -L/root/python/lib64/libxslt-plugins -L/root/python/lib64/pkgconfig -L/root/python/lib64/python2.7 -L/root/python/lib64/sasl2 build/temp.linux-x86_64-2.7/psutil/_psutil_linux.o -L/root/python/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/psutil/_psutil_linux.so
building 'psutil._psutil_posix' extension
gcc -pthread -fno-strict-aliasing -I/root/python/include -I/root/python/include/gnutls -I/root/python/include/graphviz -I/root/python/include/libexslt -I/root/python/include/libxml2 -I/root/python/include/libxslt -I/root/python/include/ncurses -I/root/python/include/openssl -I/root/python/include/readline -I/root/python/include/sasl -I/root/python/lib64/libffi-3.0.13/include -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/root/python/include/python2.7 -c psutil/_psutil_posix.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_posix.o
gcc -pthread -shared -L/root/python/lib64 -Wl,-rpath,$ORIGIN,-rpath,$ORIGIN/../lib64,-rpath-link,$ORIGIN,-rpath-link,$ORIGIN/../lib64 -Wl,-rpath,$ORIGIN/../.. -L/root/python/lib64/engines -L/root/python/lib64/gettext -L/root/python/lib64/graphviz -L/root/python/lib64/libffi-3.0.13 -L/root/python/lib64/libxslt-plugins -L/root/python/lib64/pkgconfig -L/root/python/lib64/python2.7 -L/root/python/lib64/sasl2 build/temp.linux-x86_64-2.7/psutil/_psutil_posix.o -L/root/python/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/psutil/_psutil_posix.so
python setup.py build_ext -i
running build_ext
copying build/lib.linux-x86_64-2.7/psutil/_psutil_linux.so -> psutil
copying build/lib.linux-x86_64-2.7/psutil/_psutil_posix.so -> psutil
python setup.py install --user; \

running install
/root/python/lib64/python2.7/site-packages/setuptools-12.1-py2.7.egg/pkg_resources/__init__.py:2512: PEP440Warning: 'infi.vendata.jslave (0.6.25.post15.g6488ad1)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
/root/python/lib64/python2.7/site-packages/setuptools-12.1-py2.7.egg/pkg_resources/__init__.py:2512: PEP440Warning: 'infi.os-info (0.0.1.post2.g25a28bb)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
running bdist_egg
running egg_info
creating psutil.egg-info
writing psutil.egg-info/PKG-INFO
writing top-level names to psutil.egg-info/top_level.txt
writing dependency_links to psutil.egg-info/dependency_links.txt
writing manifest file 'psutil.egg-info/SOURCES.txt'
reading manifest file 'psutil.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '*' found under directory 'docs/_build'
writing manifest file 'psutil.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
running build_ext
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/psutil
copying build/lib.linux-x86_64-2.7/psutil/_compat.py -> build/bdist.linux-x86_64/egg/psutil
copying build/lib.linux-x86_64-2.7/psutil/_pssunos.py -> build/bdist.linux-x86_64/egg/psutil
copying build/lib.linux-x86_64-2.7/psutil/__init__.py -> build/bdist.linux-x86_64/egg/psutil
copying build/lib.linux-x86_64-2.7/psutil/_psutil_linux.so -> build/bdist.linux-x86_64/egg/psutil
copying build/lib.linux-x86_64-2.7/psutil/_common.py -> build/bdist.linux-x86_64/egg/psutil
copying build/lib.linux-x86_64-2.7/psutil/_psposix.py -> build/bdist.linux-x86_64/egg/psutil
copying build/lib.linux-x86_64-2.7/psutil/_psosx.py -> build/bdist.linux-x86_64/egg/psutil
copying build/lib.linux-x86_64-2.7/psutil/_psutil_posix.so -> build/bdist.linux-x86_64/egg/psutil
copying build/lib.linux-x86_64-2.7/psutil/_pslinux.py -> build/bdist.linux-x86_64/egg/psutil
copying build/lib.linux-x86_64-2.7/psutil/_psbsd.py -> build/bdist.linux-x86_64/egg/psutil
copying build/lib.linux-x86_64-2.7/psutil/_pswindows.py -> build/bdist.linux-x86_64/egg/psutil
byte-compiling build/bdist.linux-x86_64/egg/psutil/_compat.py to _compat.pyc
byte-compiling build/bdist.linux-x86_64/egg/psutil/_pssunos.py to _pssunos.pyc
byte-compiling build/bdist.linux-x86_64/egg/psutil/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/psutil/_common.py to _common.pyc
byte-compiling build/bdist.linux-x86_64/egg/psutil/_psposix.py to _psposix.pyc
byte-compiling build/bdist.linux-x86_64/egg/psutil/_psosx.py to _psosx.pyc
byte-compiling build/bdist.linux-x86_64/egg/psutil/_pslinux.py to _pslinux.pyc
byte-compiling build/bdist.linux-x86_64/egg/psutil/_psbsd.py to _psbsd.pyc
byte-compiling build/bdist.linux-x86_64/egg/psutil/_pswindows.py to _pswindows.pyc
creating stub loader for psutil/_psutil_linux.so
creating stub loader for psutil/_psutil_posix.so
byte-compiling build/bdist.linux-x86_64/egg/psutil/_psutil_linux.py to _psutil_linux.pyc
byte-compiling build/bdist.linux-x86_64/egg/psutil/_psutil_posix.py to _psutil_posix.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying psutil.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying psutil.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying psutil.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying psutil.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
psutil.__init__: module references __file__
creating dist
creating 'dist/psutil-3.0.0-py2.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing psutil-3.0.0-py2.7-linux-x86_64.egg
removing '/root/.local/lib64/python2.7/site-packages/psutil-3.0.0-py2.7-linux-x86_64.egg' (and everything under it)
creating /root/.local/lib64/python2.7/site-packages/psutil-3.0.0-py2.7-linux-x86_64.egg
Extracting psutil-3.0.0-py2.7-linux-x86_64.egg to /root/.local/lib64/python2.7/site-packages
psutil 3.0.0 is already the active version in easy-install.pth

Installed /root/.local/lib64/python2.7/site-packages/psutil-3.0.0-py2.7-linux-x86_64.egg
Processing dependencies for psutil==3.0.0
Finished processing dependencies for psutil==3.0.0
python test/test_psutil.py
test_PAGESIZE (__main__.TestSystemAPIs) ... ok
test_boot_time (__main__.TestSystemAPIs) ... ok
test_cpu_count (__main__.TestSystemAPIs) ... FAIL
test_disk_io_counters (__main__.TestSystemAPIs) ... ok
test_disk_partitions (__main__.TestSystemAPIs) ... ok
test_disk_usage (__main__.TestSystemAPIs) ... ok
test_disk_usage_unicode (__main__.TestSystemAPIs) ... ok
test_net_connections (__main__.TestSystemAPIs) ... ok
test_net_if_addrs (__main__.TestSystemAPIs) ... FAIL
test_net_if_stats (__main__.TestSystemAPIs) ... ERROR
test_net_io_counters (__main__.TestSystemAPIs) ... ok
test_pid_exists (__main__.TestSystemAPIs) ... ok
test_pid_exists_2 (__main__.TestSystemAPIs) ... ok
test_pids (__main__.TestSystemAPIs) ... ok
test_process_iter (__main__.TestSystemAPIs) ... ok
test_process_iter_against_pids (__main__.TestSystemAPIs) ... ok
test_swap_memory (__main__.TestSystemAPIs) ... ok
test_sys_cpu_percent (__main__.TestSystemAPIs) ... ok
test_sys_cpu_times (__main__.TestSystemAPIs) ... ok
test_sys_cpu_times2 (__main__.TestSystemAPIs) ... ok
test_sys_cpu_times_percent (__main__.TestSystemAPIs) ... ok
test_sys_per_cpu_percent (__main__.TestSystemAPIs) ... ok
test_sys_per_cpu_times (__main__.TestSystemAPIs) ... ok
test_sys_per_cpu_times2 (__main__.TestSystemAPIs) ... ok
test_sys_per_cpu_times_percent (__main__.TestSystemAPIs) ... ok
test_test (__main__.TestSystemAPIs) ... ok
test_users (__main__.TestSystemAPIs) ... ok
test_virtual_memory (__main__.TestSystemAPIs) ... ok
test_wait_procs (__main__.TestSystemAPIs) ... ok
test_wait_procs_no_timeout (__main__.TestSystemAPIs) ... ok
test_Popen (__main__.TestProcess) ... ok
test_as_dict (__main__.TestProcess) ... ok
test_children (__main__.TestProcess) ... ok
test_children_duplicates (__main__.TestProcess) ... ok
test_children_recursive (__main__.TestProcess) ... ok
test_cmdline (__main__.TestProcess) ... ok
test_connection_constants (__main__.TestProcess) ... ok
test_connection_fromfd (__main__.TestProcess) ... ok
test_connections (__main__.TestProcess) ... ok
test_connections_unix (__main__.TestProcess) ... ok
test_cpu_affinity (__main__.TestProcess) ... make: *** [test] Segmentation fault

(note that there are errors and fails besides the segfault)
Also, the tests are failing anyway (see your Travis status: https://travis-ci.org/giampaolo/psutil), and the tests don't work under user root due to Permission Denied errors in the limited user tests.
I'll try to fix everything, and make a pull request.

mrjefftang added a commit to mrjefftang/psutil that referenced this issue Mar 24, 2015
* master:
  use 'with open' to make sure file is closed
  test_process_create_time: always test against the rounded time too
  don't test physical cpu count on systems that don't include it
  don't test num_ctx_switches on unsupported kernels
  fix compilation warning about possible misuse of XDECREF
  fix race condition in wait_for_file
  fix flake8 error
  fix permission errors when running from /root
  fix giampaolo#607: DUPLEX_UNKNOWN is not defined on old RedHat versions
  fix giampaolo#606: Process.parent() may swallow NoSuchProcess exceptions (#race-condition)
  attempt to fix xargs on OSX
  giampaolo#602: move pre-commit hook into a separate file
  fix giampaolo#602: add GIT pre-commit hook
  fix failing test on Windows
  C styling: if unification
  forgot to close the handle
  fix giampaolo#599 (Windows): process name() can now be determined for all PIDs
  add test
  windows: refactoring of the alternative process info implementation
  fix typo in documentation
@wiggin15
Copy link
Collaborator Author

I just found out that the fix was inside an unrelated #ifdef, so the build still fails on Centos 4.8.
I committed a fix to our local branch here: Infinidat@dda5df9

I prefer to open a pull request after #610 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants