[lldb-dev] Python packaging change

Mark Peek mark at peek.org
Mon May 14 21:50:11 PDT 2012


On 5/14/12 7:46 PM, Charles Davis wrote:
>
> On May 14, 2012, at 3:13 PM, Mark Peek wrote:
>
>> On 5/14/12 12:31 PM, Charles Davis wrote:
>>>
>>> On May 14, 2012, at 1:16 PM, Mark Peek wrote:
>>>
>>>> I recently updated by tree and had problems running lldb due to Python issues.
>>>> Below is what I've been able to determine is the issue. I thought asking the
>>>> list first for directional advice would make more sense prior to suggesting a
>>>> patch.
>>>>
>>>> This revision changed the Python files into a Python package:
>>>> http://llvm.org/viewvc/llvm-project?view=rev&revision=155514
>>>>
>>>> However, this broke running on FreeBSD since the finish-swig-Python-LLDB.sh
>>>> script is only run from an Xcode build even though the script appears to
>>>> support both LLDB.framework and non-Darwin builds. For non-Darwin builds the
>>>> Python file install is done in source/Interpreter/Makefile (which was not
>>>> changed to support the new packaging and usage).
>>> And now it is. Try this patch.
>>
>> Thank you for the patch. For FreeBSD I had to switch a couple of the echos from using \c in the string to using "echo -n".
> Yeah, I wanted to use "echo -n" but all that did on my computer was write '-n' to the files.

What OS and OS version are you running this on? This is the patch to your 
patch that worked for me:

% diff -u python-packaging.patch.orig python-packaging.patch
--- python-packaging.patch.orig	2012-05-14 21:38:12.000000000 -0700
+++ python-packaging.patch	2012-05-14 13:45:51.000000000 -0700
@@ -74,9 +74,9 @@
  +  $(foreach file,$(LLDB_PACKAGE_$(subpackage)_FILES), \
  +    $(CP) "$(file)" "$(PYTHON_DIR)/$(LLDB_PACKAGE_$(subpackage))"; \
  +  ) \
-+  echo "__all__ = [\c" >$$init_file; \
-+  echo "$(patsubst %,\"%\"$(comma),\
-+    $(basename $(notdir $(LLDB_PACKAGE_$(subpackage)_FILES))))\c" 
 >>$$init_file; \
++  echo -n "__all__ = [" >$$init_file; \
++  echo -n "$(patsubst %,\"%\"$(comma),\
++    $(basename $(notdir $(LLDB_PACKAGE_$(subpackage)_FILES))))" >>$$init_file; \
  +  echo "]" >>$$init_file; \
  +  echo "for x in __all__:" >>$$init_file; \
  +  echo "    __import__('lldb.$(subst 
/,.,$(LLDB_PACKAGE_$(subpackage))).'+x)" >>$$init_file; \

In other words, replace these lines:

   echo "__all__ = [\c" >$$init_file; \
   echo "$(patsubst %,\"%\"$(comma),\
     $(basename $(notdir $(LLDB_PACKAGE_$(subpackage)_FILES))))\c"

with:

   echo -n "__all__ = [" >$$init_file; \
   echo -n "$(patsubst %,\"%\"$(comma),\
     $(basename $(notdir $(LLDB_PACKAGE_$(subpackage)_FILES))))"

>> After that it worked great for the in-tree version.
> That was unexpected, considering that I haven't modified the test makefiles to point to the lldb package yet.

For my tests I manually set PYTHONPATH so it worked for me without complaining 
about import errors which the trunk version has been emitting.

>> Are you going to submit the patch out to lldb-commit?
> Not yet. I need to figure out a portable way to write text to a file without a trailing newline.

Sounds good. Using echo -n should do the trick since that's been around for 
quite some time. Let me know the OS and I might be able to repro to help look 
at it.

Thanks,
Mark



More information about the lldb-dev mailing list