__pycache__ and clang

38 views
Skip to first unread message

axeoth

unread,
May 27, 2011, 7:02:34 AM5/27/11
to fbuild
Hello,

I am quite new in fbuild, while having some (not very much) experience
with scons and read something about waf.
AFAIK, __pycache__ is newly introduced in python3. I dunno how things
worked before, but I particularily don't like the __pycache__ folder
(or any .pyc files) to clutter my project folder (yes, I know about
svn:ignore and so on, I just don't like it, is a supplimentary clutter
and stress). I hate to say it, but scons, while also written in
python, does not put any __pycache__ or .pyc files into the project
folder.
So, my first question: could the __pycache__/.pyc be put somewhere
else, let's say in the fbuild installation folder or in the /tmp
folder of the machine?

Second, on my machine I have both gcc and clang installed. For some
reason (namely, support of designated initializers in clang++), I
would like to sometime force using clang over gcc/g++ when building.
Currently, I use:
static = fbuild.builders.c.guess_static(ctx)
to construct the builder, and this finds gcc or g++ and sticks with
it.
So, my second question: it is possible to force using clang/clang++
over gcc/g++ in fbuild and, if yes, how?

Thanks!

Felix (no, is not a joke)

Erick Tryzelaar

unread,
May 27, 2011, 10:40:55 AM5/27/11
to fbu...@googlegroups.com
On Fri, May 27, 2011 at 4:02 AM, axeoth <axe...@gmail.com> wrote:
> Hello,

Good morning!

> I am quite new in fbuild, while having some (not very much) experience
> with scons and read something about waf.
> AFAIK, __pycache__ is newly introduced in python3. I dunno how things
> worked before, but I particularily don't like the __pycache__ folder
> (or any .pyc files) to clutter my project folder (yes, I know about
> svn:ignore and so on, I just don't like it, is a supplimentary clutter
> and stress). I hate to say it, but scons, while also written in
> python, does not put any __pycache__ or .pyc files into the project
> folder.
> So, my first question: could the __pycache__/.pyc be put somewhere
> else, let's say in the fbuild installation folder or in the /tmp
> folder of the machine?

Unfortunately it looks like the __pycache__ directories can't be moved
around. I may be able to do what scons/waf does, and allow for the
starter file to be "fbuildroot" instead of "fbuildroot.py", which I
think will not generate the __pycache__ file. I'll look into it.


> Second, on my machine I have both gcc and clang installed. For some
> reason (namely, support of designated initializers in clang++), I
> would like to sometime force using clang over gcc/g++ when building.
> Currently, I use:
> static = fbuild.builders.c.guess_static(ctx)
> to construct the builder, and this finds gcc or g++ and sticks with
> it.
> So, my second question: it is possible to force using clang/clang++
> over gcc/g++ in fbuild and, if yes, how?

It is! Or at least it will be. I was actually just in the middle of
adding clang support, which I just pushed out.

To use it, you can either call fbuild.builders.c.clang.static
directly, or you can extend the platform set to consider using clang
if it's available. You can do that by:

platform = fbuild.builders.platform.guess_platform(ctx)
platform = platform.union(['clang', 'clang++'])
static = fbuild.builders.c.guess_static(ctx)

and if clang exists and doesn't fail to configure, it will prefer it
over the system compiler. Please let me know if that doesn't work for
you.


> Thanks!
>
> Felix (no, is not a joke)

:) Thanks for trying out fbuild!

axeoth

unread,
May 27, 2011, 11:06:43 AM5/27/11
to fbuild
Hello again and many thanks for answering so fast.

It is nice that you are exploring different ways to get rid of the
__pycache__ folder.

Unfortunately, it appears that there is no clang support at all in my
fbuild.

The first solution, i.e.:

static=fbuild.builders.c.clang.static(ctx)

fails with:

>>fbuild
Traceback (most recent call last):
File "/usr/local/bin/fbuild", line 156, in <module>
sys.exit(main())
File "/usr/local/bin/fbuild", line 132, in main
result = build(ctx)
File "/usr/local/bin/fbuild", line 82, in build
target.function(ctx)
File "/home/USER/eclipse-workspace/PROJECT/fbuildroot.py", line 26,
in build
static=fbuild.builders.c.clang.static(ctx)
AttributeError: 'module' object has no attribute 'clang'

and the second one, i.e.:

platform = fbuild.builders.platform.guess_platform(ctx)
platform = platform.union(['clang', 'clang++'])
static = fbuild.builders.c.guess_static(ctx)

fails with:

>>fbuild
Traceback (most recent call last):
File "/usr/local/bin/fbuild", line 156, in <module>
sys.exit(main())
File "/usr/local/bin/fbuild", line 132, in main
result = build(ctx)
File "/usr/local/bin/fbuild", line 82, in build
target.function(ctx)
File "/home/USER/eclipse-workspace/PROJECT/fbuildroot.py", line 26,
in build
platform = fbuild.builders.platform.guess_platform(ctx)
AttributeError: 'module' object has no attribute 'guess_platform'

I should also stress out that in my fbuild distribution there is no
folder named "clang" in the fbuild/lib/fbuild/builders/c or in the
fbuild/lib/fbuild/builders/cxx folders. There are only gcc/ and,
respectively, gxx/ subfolders there. This although I am (or I should
be) using the latest version from the github.com.

BTW, my fbuild --version returns 0.2, although i just git-pull(ed) the
latest version. This version creates, indeed, folders clang/ and
clangxx/ under fbuild/lib/fbuild/builders/c (and cxx/) directories,
but such folders are not created under the fbuild/build/lib/fbuild/
builders/c/ (and cxx/) folders (nothe the "build" difference).

Of course I called sudo python3 setup.py install, but with no use.

Thanks again,

Felix



Erick Tryzelaar

unread,
May 27, 2011, 11:12:02 AM5/27/11
to fbu...@googlegroups.com
On Fri, May 27, 2011 at 8:06 AM, axeoth <axe...@gmail.com> wrote:
>
> BTW, my fbuild --version returns 0.2, although i just git-pull(ed) the
> latest version. This version creates, indeed, folders clang/ and
> clangxx/ under fbuild/lib/fbuild/builders/c (and cxx/) directories,
> but such folders are not created under the fbuild/build/lib/fbuild/
> builders/c/ (and cxx/) folders (nothe the "build" difference).
>
> Of course I called sudo python3 setup.py install, but with no use.

Hm, maybe you're pointing at a different github page? What does "git
remote -v" say? It should say something like:

git://github.com/felix-lang/fbuild.git

axeoth

unread,
May 27, 2011, 11:33:45 AM5/27/11
to fbuild
It says:

>>git remote -v
origin https://github.com/felix-lang/fbuild.git (fetch)
origin https://github.com/felix-lang/fbuild.git (push)

while:

>>git pull
Already up-to-date.

:(

axeoth

unread,
May 27, 2011, 12:51:01 PM5/27/11
to fbuild
Worse, the fbuild.builders.c.gcc.static(ctx) and the static =
fbuild.builders.c.guess_static(ctx) are no longer working, but fail:

>>fbuild
Traceback (most recent call last):
File "/usr/local/bin/fbuild", line 156, in <module>
sys.exit(main())
File "/usr/local/bin/fbuild", line 132, in main
result = build(ctx)
File "/usr/local/bin/fbuild", line 82, in build
target.function(ctx)
File "/home/USER/eclipse-workspace/PROJECT/fbuildroot.py", line 25,
in build
static=fbuild.builders.c.gcc.static(ctx)
AttributeError: 'module' object has no attribute 'gcc'

>>fbuild
Traceback (most recent call last):
File "/usr/local/bin/fbuild", line 156, in <module>
sys.exit(main())
File "/usr/local/bin/fbuild", line 132, in main
result = build(ctx)
File "/usr/local/bin/fbuild", line 82, in build
target.function(ctx)
File "/home/felix/eclipse-workspace/nessie/fbuildroot.py", line 26,
in build
static = fbuild.builders.c.guess_static(ctx)
File "/usr/local/lib/python3.2/dist-packages/fbuild/builders/c/
__init__.py", line 405, in guess_static
), *args, **kwargs)
File "/usr/local/lib/python3.2/dist-packages/fbuild/builders/c/
__init__.py", line 368, in _guess_builder
platform = fbuild.builders.platform.platform(ctx, platform)
AttributeError: 'module' object has no attribute 'platform'


Erick Tryzelaar

unread,
May 27, 2011, 3:57:09 PM5/27/11
to fbu...@googlegroups.com
On Fri, May 27, 2011 at 9:51 AM, axeoth <axe...@gmail.com> wrote:
> Worse, the fbuild.builders.c.gcc.static(ctx) and the static =
> fbuild.builders.c.guess_static(ctx) are no longer working, but fail:

Oops, I missed a function rename in fbuild.builders.c.guess_static.
Could you try again?

axeoth

unread,
May 27, 2011, 6:19:26 PM5/27/11
to fbuild
Hello again,

Is partly corrected now, meaning that
fbuild.builders.c.guess_static(ctx) works and identifies gcc.

However, attemtping to use fbuild.builders.c.clang.static(ctx) still
fails:

>>fbuild
Traceback (most recent call last):
File "/usr/local/bin/fbuild", line 156, in <module>
sys.exit(main())
File "/usr/local/bin/fbuild", line 132, in main
result = build(ctx)
File "/usr/local/bin/fbuild", line 82, in build
target.function(ctx)
File "/home/USER/eclipse-workspace/PROJECT/fbuildroot.py", line 25,
in build
static=fbuild.builders.c.clang.static(ctx)
AttributeError: 'module' object has no attribute 'clang'

Erick Tryzelaar

unread,
May 27, 2011, 10:42:58 PM5/27/11
to fbu...@googlegroups.com
On Fri, May 27, 2011 at 3:19 PM, axeoth <axe...@gmail.com> wrote:
> Hello again,
>
> Is partly corrected now, meaning that
> fbuild.builders.c.guess_static(ctx) works and identifies gcc.
>
> However, attemtping to use fbuild.builders.c.clang.static(ctx) still
> fails:
>
>>>fbuild
> Traceback (most recent call last):
>  File "/usr/local/bin/fbuild", line 156, in <module>
>    sys.exit(main())
>  File "/usr/local/bin/fbuild", line 132, in main
>    result = build(ctx)
>  File "/usr/local/bin/fbuild", line 82, in build
>    target.function(ctx)
>  File "/home/USER/eclipse-workspace/PROJECT/fbuildroot.py", line 25,
> in build
>    static=fbuild.builders.c.clang.static(ctx)
> AttributeError: 'module' object has no attribute 'clang'

Oh! I know, you're installing fbuild, not running it out of the
checkout directory. I forgot to add clang to the MANIFEST. I just
fixed that. Also, can also just call $FBUILD_GIT_DIR/fbuild-light and
it should run fine without needing installation if you plan on
tracking the git repository.

Let me know if you're still having problems.

-e

axeoth

unread,
May 28, 2011, 3:44:58 AM5/28/11
to fbuild
Hello again,

Yes, I was installing fbuild using:

>>sudo python3 setup.py install

However, the latest git-pull still does not work. More exactly:

Trying to run against:

def build(ctx):
static=fbuild.builders.c.clang.static(ctx)

it gives:

>>fbuild
Traceback (most recent call last):
File "/usr/local/bin/fbuild", line 156, in <module>
sys.exit(main())
File "/usr/local/bin/fbuild", line 132, in main
result = build(ctx)
File "/usr/local/bin/fbuild", line 82, in build
target.function(ctx)
File "/home/USER/eclipse-workspace/PROJECT/fbuildroot.py", line 28,
in build
static=fbuild.builders.c.clang.static(ctx)
AttributeError: 'module' object has no attribute 'clang'

OTOH, while tryng to run ./fbuild-light (from the git folder), I
encountered:

>>./fbuild-light
/usr/bin/env: python3.1: No such file or directory

which is true, since I use python3.2 (Ubuntu Natty).

However, for the last error (the one with fbuild-light) there is a
proposed patch at:

https://github.com/felix-lang/fbuild/pull/4

Many thanks again.

I should also add that I am not in hurry, so take your time.

Erick Tryzelaar

unread,
May 29, 2011, 12:45:58 AM5/29/11
to fbu...@googlegroups.com
On Sat, May 28, 2011 at 12:44 AM, axeoth <axe...@gmail.com> wrote:
> Hello again,
>
> Yes, I was installing fbuild using:
>
>>>sudo python3 setup.py install
>
> However, the latest git-pull still does not work. More exactly:
>
> Trying to run against:
>
> def build(ctx):
>        static=fbuild.builders.c.clang.static(ctx)
>
> it gives:
>
>>>fbuild
> Traceback (most recent call last):
>  File "/usr/local/bin/fbuild", line 156, in <module>
>    sys.exit(main())
>  File "/usr/local/bin/fbuild", line 132, in main
>    result = build(ctx)
>  File "/usr/local/bin/fbuild", line 82, in build
>    target.function(ctx)
>  File "/home/USER/eclipse-workspace/PROJECT/fbuildroot.py", line 28,
> in build
>    static=fbuild.builders.c.clang.static(ctx)
> AttributeError: 'module' object has no attribute 'clang'

I think I finally tracked down what was going on, and pushed a fix.
Thanks for your patience.


> OTOH, while tryng to run ./fbuild-light (from the git folder), I
> encountered:
>
>>>./fbuild-light
> /usr/bin/env: python3.1: No such file or directory
>
> which is true, since I use python3.2 (Ubuntu Natty).
>
> However, for the last error (the one with fbuild-light) there is a
> proposed patch at:
>
> https://github.com/felix-lang/fbuild/pull/4
>
> Many thanks again.
>
> I should also add that I am not in hurry, so take your time.

And thanks for the patches! I committed them, with a slight
modification for the install location. http://github.com/felix-lang is
now the official parent project so I just removed references to
http://github.com/erickt.

Felix TOTIR

unread,
May 29, 2011, 5:36:59 AM5/29/11
to fbu...@googlegroups.com
Thank you very much for the effort.

Unfortunately, it still seems not being fixed (see below).

Before of that, some comments:

1. AFAIR, fbuild-light used to come with the "+x" attribute enabled,
now is not and must be enabled manually.

2. The new official path (http://github.com/felix-lang) does just
partially appear into the README.markdown file. The specific problem
that I encountered was not about the "erickt" part, but about the
protocol (git:// vs. http:// or https://). My firewall forbids me
accessing the git:// protocol. The first does not work, while the last
two work:
git clone git://github.com/felix-lang/fbuild.git
git clone http://github.com/felix-lang/fbuild.git
git clone https://github.com/felix-lang/fbuild.git

3. Just after cloning, I run:
cd fbuild
sudo python3 setup.py install
in order to install fbuild, but I also tried with fbuild-light from
the fbuild/ directory.

Now, back to the bug:

===fbuildroot.py===
def build(ctx):
static = fbuild.builders.c.clang.static(ctx)
===============
>>fbuild #trying fbuild


Traceback (most recent call last):
File "/usr/local/bin/fbuild", line 156, in <module>
sys.exit(main())
File "/usr/local/bin/fbuild", line 132, in main
result = build(ctx)
File "/usr/local/bin/fbuild", line 82, in build
target.function(ctx)
File "/home/USER/eclipse-workspace/PROJECT/fbuildroot.py", line 28, in build
static = fbuild.builders.c.clang.static(ctx)
AttributeError: 'module' object has no attribute 'clang'


>>/home/.common/_develop/fbuild/fbuild-light #trying fbuild-light


Traceback (most recent call last):

File "/home/.common/_develop/fbuild/fbuild-light", line 13, in <module>
exec(compile(f.read(), fbuild_exename, 'exec'))
File "/home/.common/_develop/fbuild/bin/fbuild", line 156, in <module>
sys.exit(main())
File "/home/.common/_develop/fbuild/bin/fbuild", line 132, in main
result = build(ctx)
File "/home/.common/_develop/fbuild/bin/fbuild", line 82, in build


target.function(ctx)
File "/home/USER/eclipse-workspace/PROJECT/fbuildroot.py", line 28, in build
static = fbuild.builders.c.clang.static(ctx)
AttributeError: 'module' object has no attribute 'clang'

>>clang #test if clang is really installed
clang: error: no input files

Please, take into account that I new to both python and fbuild and, as
such, I could make a mistake when installing (although I follow the
instructions).

Cordially,

Felix

axeoth

unread,
May 29, 2011, 5:44:28 AM5/29/11
to fbuild
I should add also that with an fbuildroot.py containing:

static = fbuild.builders.c.gcc.static(ctx)

I still receive the error:

fbuild
Traceback (most recent call last):
File "/usr/local/bin/fbuild", line 156, in <module>
sys.exit(main())
File "/usr/local/bin/fbuild", line 132, in main
result = build(ctx)
File "/usr/local/bin/fbuild", line 82, in build
target.function(ctx)
File "/home/USER/eclipse-workspace/PROJECT/fbuildroot.py", line 28,
in build
static = fbuild.builders.c.gcc.static(ctx)
AttributeError: 'module' object has no attribute 'gcc'

which is strange (do I make a syntax error?).

However, while working with:

static = fbuild.builders.c.guess_static(ctx)

it seems to work well.

Erick Tryzelaar

unread,
May 29, 2011, 10:49:20 AM5/29/11
to fbu...@googlegroups.com
On Sun, May 29, 2011 at 2:36 AM, Felix TOTIR <axe...@gmail.com> wrote:
> Thank you very much for the effort.
>
> Unfortunately, it still seems not being fixed (see below).
>
> Before of that, some comments:
>
> 1. AFAIR, fbuild-light used to come with the "+x" attribute enabled,
> now is not and must be enabled manually.

How odd. I fixed it. You may need to manually change the attribute
though on fbuild-light and bin/fbuild because it looks like git pull
isn't updating it for me.


> 2. The new official path (http://github.com/felix-lang) does just
> partially appear into the README.markdown file. The specific problem
> that I encountered was not about the "erickt" part, but about the
> protocol (git:// vs. http:// or https://). My firewall forbids me
> accessing the git:// protocol. The first does not work, while the last
> two work:
> git clone git://github.com/felix-lang/fbuild.git
> git clone http://github.com/felix-lang/fbuild.git
> git clone https://github.com/felix-lang/fbuild.git

Good point, I'll just point everyone to the http instead.


> Now, back to the bug:
>
> ===fbuildroot.py===
> def build(ctx):
>        static = fbuild.builders.c.clang.static(ctx)

Is this your full fbuildroot? Are you also doing any imports? Is it
anything more than this?

import fbuild.builders.c.clang


def build(ctx):
static = fbuild.builders.c.clang.static(ctx)

----

Oh, maybe I reproduced your situation. Are you doing this?

import fbuild.builders.c


def build(ctx):
static = fbuild.builders.c.clang.static(ctx)


Notice the import doesn't have clang or gcc at the end of it. If so,
that's the problem :) Just change it to "fbuild.builders.c.clang" and
it should hopefully work.

axeoth

unread,
May 29, 2011, 3:13:35 PM5/29/11
to fbuild
Many thanks! It finally works.
Explanations below.

On May 29, 4:49 pm, Erick Tryzelaar <erick.tryzel...@gmail.com> wrote:
> On Sun, May 29, 2011 at 2:36 AM, Felix TOTIR <axe...@gmail.com> wrote:
> > Thank you very much for the effort.
>
> > Unfortunately, it still seems not being fixed (see below).
>
> > Before of that, some comments:
>
> > 1. AFAIR, fbuild-light used to come with the "+x" attribute enabled,
> > now is not and must be enabled manually.
>
> How odd. I fixed it. You may need to manually change the attribute
> though on fbuild-light and bin/fbuild because it looks like git pull
> isn't updating it for me.

I just had a fresh git-clone and fbuild-light is still not executable;
maybe setup.py should also set its "+x" attribute. Please nothe that
"AFAIR", so I am not sure about previous executable attribute of
fbuild-light. However, I think it would be better to be marked as
executable.

>
> > 2. The new official path (http://github.com/felix-lang) does just
> > partially appear into the README.markdown file. The specific problem
> > that I encountered was not about the "erickt" part, but about the
> > protocol (git:// vs. http:// or https://). My firewall forbids me
> > accessing the git:// protocol. The first does not work, while the last
> > two work:
> > git clone git://github.com/felix-lang/fbuild.git
> > git clonehttp://github.com/felix-lang/fbuild.git
> > git clonehttps://github.com/felix-lang/fbuild.git
>
> Good point, I'll just point everyone to the http instead.

Many thanks! For me it was a blocking issue.

>
> > Now, back to the bug:
>
> > ===fbuildroot.py===
> > def build(ctx):
> >        static = fbuild.builders.c.clang.static(ctx)
>
> Is this your full fbuildroot? Are you also doing any imports? Is it
> anything more than this?
>
> import fbuild.builders.c.clang
> def build(ctx):
>     static = fbuild.builders.c.clang.static(ctx)
>
> ----
>
> Oh, maybe I reproduced your situation. Are you doing this?
>
> import fbuild.builders.c
> def build(ctx):
>     static = fbuild.builders.c.clang.static(ctx)

Yes! That was the problem, I had an import of fbuild.builders.c
(without any final .clang or .gcc). I assumed that will import
everything inside the fbuild.builders.c module, but it seems I am
wrong. A Python expected behavior?

>
> Notice the import doesn't have clang or gcc at the end of it. If so,
> that's the problem :) Just change it to "fbuild.builders.c.clang" and
> it should hopefully work.

You are right! Changing into import fbuild.builders.c.clang did the
trick!

Many thanks and sorry for being so inexact in my description.

I look forward for new versions of fbuild and, if I can help, I will
always give a helping hand (unfortunately I am not a Python guru...).

Felix

Erick Tryzelaar

unread,
May 31, 2011, 10:53:43 AM5/31/11
to fbu...@googlegroups.com
On Sun, May 29, 2011 at 12:13 PM, axeoth <axe...@gmail.com> wrote:
> I just had a fresh git-clone and fbuild-light is still not executable;
> maybe setup.py should also set its "+x" attribute. Please nothe that
> "AFAIR", so I am not sure about previous executable attribute of
> fbuild-light. However, I think it would be better to be marked as
> executable.

Ack, I forgot to push. I just did and it should *hopefully* be
executable now. I'm sorry about that.

> Yes! That was the problem, I had an import of fbuild.builders.c
> (without any final .clang or .gcc). I assumed that will import
> everything inside the fbuild.builders.c module, but it seems I am
> wrong. A Python expected behavior?

Not necessarily. You can do that in python, but I think most people
don't to avoid cluttering up the namespace (which is why I'm not doing
it).

> You are right! Changing into import fbuild.builders.c.clang did the
> trick!
>
> Many thanks and sorry for being so inexact in my description.

Great! I'm glad it's working for you now. Please let me know if you need help.


> I look forward for new versions of fbuild and, if I can help, I will
> always give a helping hand (unfortunately I am not a Python guru...).

Thanks for the offer. I'd appreciate the help :) Please let me know if
you run into more problems.

Reply all
Reply to author
Forward
0 new messages