-1

In this script from one of the linux applications I use, I see words between the "@" sign such as @devel@, and @gtk_major_version@. I would like to know what those are called, their functions in Python, and why the script has ".in" extension instead of ".py".

  • 1
    Possible duplicate of [What does the "at" (@) symbol do in Python?](https://stackoverflow.com/questions/6392739/what-does-the-at-symbol-do-in-python) – Kostas Charitidis Oct 08 '19 at 10:11
  • 4
    In this case, I don't think that '@' is used to make a decorator. Instead, it seems that the file is a template and @VARIABLE@ is made as reference to a variable defined elsewhere. – Stefano Fiorucci - anakin87 Oct 08 '19 at 10:14
  • 1
    This is not valid Python code. It is somehow preprocessed. The preprocessor uses these @...@ syntax. – Michael Butscher Oct 08 '19 at 10:15
  • 1
    Not sure if I'm reading the source code correctly, but it seems like the variables are defined [here](https://github.com/libratbag/piper/blob/d45b95b4339cd9ae2fd17dff5d0244e994189e51/meson.build). Seems to be related to the Meson Build System. – Imma Oct 08 '19 at 10:19
  • @KostasCharitidis no that's at sign in the begining of the word, this is at sign surrounding a word – Anonumous Pomp Oct 08 '19 at 10:33

1 Answers1

5

As mentioned in the comments, this is not Python syntax. Instead, the strings enclosed in @ are template variables that will be filled in by the Meson build system which is popular, e.g. with many projects that use GTK.

I this case the template will be used at build time to generate a script called just piper (with the .in removed) similarly to how autoconf generates files from templates, with the template variables replaced with values determined by the build system.

Using a build configure system to generate a Python script is slightly unusual but not at all unheard of either. I'm sure I've done the same before, albeit with autoconf.

Iguananaut
  • 21,810
  • 5
  • 50
  • 63