How to install waf?
Asked Answered
P

2

6

I have cloned and built the waf script using:

./waf-light configure

Then to build my project (provided by Gomspace) I need to add waf and the eclipse.py to my path. So far I haven't found better than this setenv script:

WAFROOT=~/git/waf/
export PYTHONPATH=$WAFROOT/waflib/extras/:$PYTHONPATH
export PATH=~/git/waf/:$PATH

Called with:

source setenv

This is somehow a pretty ugly solution. Is there a more elegant way to install waf?

Pineal answered 22/8, 2017 at 8:44 Comment(1)
Why not just use mod_security at your web server level?Sumac
N
1

Fedora (at least Fedora 22) has a yum package for waf, so you could see that it's possible to do a system install of waf, albeit with a hack.

After you run something like python3 ./waf-light configure build, you'll get a file called waf that's actually a Python script with some binary data at the end. If you put it into /usr/bin and run it as non-root, you'll get an error because it fails to create a directory in /usr/bin. If you run it as root, you'll get the new directory and /usr/bin/waf runs normally.

Here's the trick that I learned from examining the find_lib() function in the waf Python script.

  1. Copy the waf to /usr/bin/waf
  2. As root, run /usr/bin/waf. Notice that it creates a directory. You'll see something like /usr/bin/.waf-2.0.19-b2f63c807a4215294bf6005410c74c18
  3. mv that directory to /usr/lib, dropping the . in the directory name, e.g. mv /usr/bin/.waf-2.0.19-b2f63c807a4215294bf6005410c74c18 /usr/lib/waf-2.0.19-b2f63c807a4215294bf6005410c74c18
  4. If you want to use waf with Python3, repeat Steps 2-3 running the Python script /usr/bin/waf under Python3. Under Python3, the directory names will start with .waf3-/waf3- instead instead of .waf-/waf-.
  5. (Optional) Remove the binary data at the end of /usr/bin/waf.
  6. Now, non-root should be able to just use /usr/bin/waf.

That said, here's something to consider, like what another answer said: I believe waf's author intended waf to be embedded in projects so that each project can use its own version of waf without fear that a project will fail to build when there are newer versions of waf. Thus, the one-global-version use case seems to be not officially supported.

Nevels answered 28/11, 2019 at 1:42 Comment(0)
P
5

You don't install waf. The command you found correctly builds waf: /waf-light configure build Then for each project you create, you put the built waf script into that projects root directory. I can't find a reference, but this is the way in which waf:s primary author Thomas Nagy wants the tool to be used. Projects that repackage waf to make the tool installable aren't "officially sanctioned."

There are advantages and disadvantages with non-installation:

Disadvantages:

  • You have to add the semi-binary 100kb large waf file to your repository.
  • Because the file contains binary code, people can have legal objections to distributing it.

Advantages:

  • It doesn't matter if new versions of waf break the old API.
  • Users don't need to install waf before compiling the project -- having Python on the system is enough.
Photosynthesis answered 19/1, 2018 at 16:14 Comment(0)
N
1

Fedora (at least Fedora 22) has a yum package for waf, so you could see that it's possible to do a system install of waf, albeit with a hack.

After you run something like python3 ./waf-light configure build, you'll get a file called waf that's actually a Python script with some binary data at the end. If you put it into /usr/bin and run it as non-root, you'll get an error because it fails to create a directory in /usr/bin. If you run it as root, you'll get the new directory and /usr/bin/waf runs normally.

Here's the trick that I learned from examining the find_lib() function in the waf Python script.

  1. Copy the waf to /usr/bin/waf
  2. As root, run /usr/bin/waf. Notice that it creates a directory. You'll see something like /usr/bin/.waf-2.0.19-b2f63c807a4215294bf6005410c74c18
  3. mv that directory to /usr/lib, dropping the . in the directory name, e.g. mv /usr/bin/.waf-2.0.19-b2f63c807a4215294bf6005410c74c18 /usr/lib/waf-2.0.19-b2f63c807a4215294bf6005410c74c18
  4. If you want to use waf with Python3, repeat Steps 2-3 running the Python script /usr/bin/waf under Python3. Under Python3, the directory names will start with .waf3-/waf3- instead instead of .waf-/waf-.
  5. (Optional) Remove the binary data at the end of /usr/bin/waf.
  6. Now, non-root should be able to just use /usr/bin/waf.

That said, here's something to consider, like what another answer said: I believe waf's author intended waf to be embedded in projects so that each project can use its own version of waf without fear that a project will fail to build when there are newer versions of waf. Thus, the one-global-version use case seems to be not officially supported.

Nevels answered 28/11, 2019 at 1:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.