File: setup.py

package info (click to toggle)
libfiu 1.2-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 768 kB
  • sloc: ansic: 2,633; python: 973; makefile: 599; sh: 309
file content (52 lines) | stat: -rw-r--r-- 1,566 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
import sys
import tempfile
from setuptools import setup, Extension
from setuptools.command.build_py import build_py


# We need to generate the fiu_ctrl.py file from fiu_ctrl.in.py, replacing some
# environment variables in its contents.
class generate_and_build_py(build_py):
    def run(self):
        if not self.dry_run:
            self.generate_fiu_ctrl()
        build_py.run(self)

    def generate_fiu_ctrl(self):
        prefix = os.environ.get("PREFIX", "/usr/local/")
        plibpath = os.environ.get("PLIBPATH", prefix + "/lib/")

        contents = open("fiu_ctrl.in.py", "rt").read()
        contents = contents.replace("@@PLIBPATH@@", plibpath)

        # Create/update the file atomically, we don't want to accidentally use
        # partially written files.
        out = tempfile.NamedTemporaryFile(
            mode="wt", delete=False, dir=".", prefix="tmp-fiu_ctrl.py"
        )
        out.write(contents)
        out.close()
        os.rename(out.name, "fiu_ctrl.py")


fiu_ll = Extension(
    "fiu_ll",
    sources=["fiu_ll.c"],
    libraries=["fiu"],
    # These two allow us to build without having libfiu installed,
    # assuming we're in the libfiu source tree
    include_dirs=["../../libfiu/"],
    library_dirs=["../../libfiu/"],
)

setup(
    name="fiu",
    description="libfiu bindings",
    author="Alberto Bertogli",
    author_email="albertito@blitiri.com.ar",
    url="http://blitiri.com.ar/p/libfiu",
    py_modules=["fiu", "fiu_ctrl"],
    ext_modules=[fiu_ll],
    cmdclass={"build_py": generate_and_build_py},
)