Bytecode in Paths.pyc file is stale after the installation
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 13.6k
- Forks
- 2.9k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
When installing zenmap, one of the resulting bytecode .pyc files (Paths.pyc) is not importable because Paths.py file is updated in function fix_paths here after it was already compiled.
To Reproduce
Run python2 setup.py install --prefix ./proto in the zenmap directory. Resulting ./proto/lib/python2.7/site-packages/zenmapCore/Paths.pyc file will be stale as the corresponding Paths.py has a newer timestamp.
Expected behavior
Paths.pyc file is not stale.
Possible fix
I fixed this by adding py_compile.compile() right after the file is written and that fixes this issue; however, I am not sure whether that is the best way to fix this (the fix_paths should probably be called before the initial compilation begins avoiding this issue).
--- nmap-7.80/zenmap/setup.py
+++ nmap-7.80/zenmap/setup.py
@@ -437,6 +437,9 @@ for dir in dirs:
pf.write(pcontent)
pf.close()
+ import py_compile
+ py_compile.compile(paths_file)
+
# Rewrite the zenmap.desktop and zenmap-root.desktop files to point to
# the installed locations of the su-to-zenmap.sh script and application
# icon.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in zenmap/setup.py, reading fix_paths and the installation loop around the Paths.py rewrite. Reproduce with python2 setup.py install --prefix ./proto in zenmap, then verify that proto/lib/python2.7/site-packages/zenmapCore/Paths.pyc is importable and is not older than Paths.py.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100