Skip to content

Commit

Permalink
[SCons] Remove special handling for Debian packages
Browse files Browse the repository at this point in the history
Leave rearranging files to the Debian packaging scripts
  • Loading branch information
speth committed Jun 21, 2023
1 parent 6085795 commit d596347
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 74 deletions.
63 changes: 15 additions & 48 deletions SConstruct
Expand Up @@ -627,15 +627,14 @@ config_options = [
'prefix/include/cantera', 'prefix/lib' etc. This layout is best used in
conjunction with "prefix='/usr/local'". 'compact' puts all installed files
in the subdirectory defined by 'prefix'. This layout is best with a prefix
like '/opt/cantera'. 'debian' installs to the stage directory in a layout
used for generating Debian packages. If the Python executable found during
compilation is managed by 'conda', the layout will default to 'conda'
irrespective of operating system. For the 'conda' layout, the Python package
as well as all libraries and header files are installed into the active
'conda' environment. Input data, samples, and other files are installed in
the 'shared/cantera' subdirectory of the active 'conda' environment.""",
like '/opt/cantera'. If the Python executable found during compilation is
managed by 'conda', the layout will default to 'conda' irrespective of
operating system. For the 'conda' layout, the Python package as well as all
libraries and header files are installed into the active 'conda' environment.
Input data, samples, and other files are installed in the 'shared/cantera'
subdirectory of the active 'conda' environment.""",
{"Windows": "compact", "default": "standard"},
("standard", "compact", "debian", "conda")),
("standard", "compact", "conda")),
BoolOption(
"package_build",
"""Used in combination with packaging tools (example: 'conda-build'). If
Expand Down Expand Up @@ -1982,10 +1981,6 @@ if env["matlab_toolbox"] == "y":
# *** Set additional configuration variables ***
# **********************************************

# On Debian-based systems, need to special-case installation to
# /usr/local because of dist-packages vs site-packages
env['debian'] = any(name.endswith('dist-packages') for name in sys.path)

# Identify options selected either on command line or in cantera.conf
selected_options = set(line.split("=")[0].strip()
for line in cantera_conf.splitlines())
Expand All @@ -1998,13 +1993,6 @@ if "msi" in COMMAND_LINE_TARGETS:
selected_options.add("prefix")
selected_options.add("stage_dir")
env["python_package"] = "none"
elif env["layout"] == "debian":
COMMAND_LINE_TARGETS.append("install")
env["stage_dir"] = "stage/cantera"
env["PYTHON_INSTALLER"] = "debian"
env["INSTALL_MANPAGES"] = False
else:
env["PYTHON_INSTALLER"] = "direct"

env["default_prefix"] = True
if "prefix" in selected_options:
Expand Down Expand Up @@ -2092,35 +2080,14 @@ if os.path.abspath(instRoot) == Dir('.').abspath:
logger.error("cannot install Cantera into source directory.")
sys.exit(1)

if env["layout"] == "debian":
base = Path(os.getcwd()) / "debian"
env["inst_root"] = base.as_posix()

env["inst_libdir"] = (base / "cantera-dev" / "usr" / env["libdirname"]).as_posix()
env["inst_incdir"] = (base / "cantera-dev" / "usr" / "include" / "cantera").as_posix()
env["inst_incroot"] = (base / "cantera-dev" / "usr" / "include").as_posix()

env["inst_bindir"] = (base / "cantera-common" / "usr" / "bin").as_posix()
env["inst_datadir"] = (base / "cantera-common" / "usr" / "share" / "cantera" / "data").as_posix()
env["inst_docdir"] = (base / "cantera-common" / "usr" / "share" / "cantera" / "doc").as_posix()
env["inst_sampledir"] = (base / "cantera-common" / "usr" / "share" / "cantera" / "samples").as_posix()
env["inst_mandir"] = (base / "cantera-common" / "usr" / "share" / "man" / "man1").as_posix()

env["inst_matlab_dir"] = (
base / "cantera-matlab" / "usr" /
env["libdirname"] / "cantera" / "matlab" / "toolbox").as_posix()

env["inst_python_bindir"] = (base / "cantera-python" / "usr" / "bin").as_posix()
env["python_prefix"] = (base / "cantera-python3").as_posix()
else:
env["inst_root"] = instRoot
locations = ["libdir", "bindir", "python_bindir", "incdir", "incroot",
"matlab_dir", "datadir", "sampledir", "docdir", "mandir"]
for loc in locations:
if env["prefix"] == ".":
env[f"inst_{loc}"] = (Path(instRoot) / env[f"ct_{loc}"]).as_posix()
else:
env[f"inst_{loc}"] = env[f"ct_{loc}"].replace(env["ct_installroot"], instRoot)
env["inst_root"] = instRoot
locations = ["libdir", "bindir", "python_bindir", "incdir", "incroot",
"matlab_dir", "datadir", "sampledir", "docdir", "mandir"]
for loc in locations:
if env["prefix"] == ".":
env[f"inst_{loc}"] = (Path(instRoot) / env[f"ct_{loc}"]).as_posix()
else:
env[f"inst_{loc}"] = env[f"ct_{loc}"].replace(env["ct_installroot"], instRoot)

if env['use_rpath_linkage']:
env.Append(RPATH=env['ct_libdir'])
Expand Down
20 changes: 7 additions & 13 deletions interfaces/cython/SConscript
Expand Up @@ -163,16 +163,10 @@ if env["stage_dir"]:

install_cmd.extend(("--no-build-isolation", "--no-deps", "-v", "--force-reinstall",
"build/python"))
if localenv['PYTHON_INSTALLER'] == 'direct':
mod_inst = install(localenv.Command, "dummy", mod, " ".join(install_cmd))
env["install_python_action"] = mod_inst
install_locs = get_pip_install_location(localenv["python_cmd"], user_install,
python_prefix)
env["python_module_loc"] = Path(install_locs["platlib"]).as_posix()
env["ct_pyscriptdir"] = Path(install_locs["scripts"]).as_posix()
elif localenv['PYTHON_INSTALLER'] == 'debian':
install(localenv.Command, 'dummy', mod,
'cd build/python && '
'$python_cmd_esc setup.py build --build-lib=. '
'install --install-layout=deb --no-compile --root=${python_prefix}')
env["python_module_loc"] = "<unspecified>"

mod_inst = install(localenv.Command, "dummy", mod, " ".join(install_cmd))
env["install_python_action"] = mod_inst
install_locs = get_pip_install_location(localenv["python_cmd"], user_install,
python_prefix)
env["python_module_loc"] = Path(install_locs["platlib"]).as_posix()
env["ct_pyscriptdir"] = Path(install_locs["scripts"]).as_posix()
26 changes: 13 additions & 13 deletions interfaces/python_minimal/SConscript
Expand Up @@ -34,19 +34,19 @@ localenv.Depends(mod, [make_setup, readme, license, "setup.py", "pyproject.toml"
install_cmd = ["$python_cmd_esc", "-m", "pip", "install"]
user_install = False
python_prefix = None
if localenv["PYTHON_INSTALLER"] == "direct":
if localenv["python_prefix"] == "USER":
# Install to the OS-dependent user site-packages directory
install_cmd.append("--user")
user_install = True
elif localenv["python_prefix"]:
# A specific location for the Cantera python module has been given
install_cmd.extend((f"--prefix={localenv.subst('$python_prefix')}",
"--no-warn-script-location"))
python_prefix = localenv.subst("$python_prefix")
elif not env["default_prefix"]:
install_cmd.append(f"--prefix={env['prefix']}")
python_prefix = env["prefix"]

if localenv["python_prefix"] == "USER":
# Install to the OS-dependent user site-packages directory
install_cmd.append("--user")
user_install = True
elif localenv["python_prefix"]:
# A specific location for the Cantera python module has been given
install_cmd.extend((f"--prefix={localenv.subst('$python_prefix')}",
"--no-warn-script-location"))
python_prefix = localenv.subst("$python_prefix")
elif not env["default_prefix"]:
install_cmd.append(f"--prefix={env['prefix']}")
python_prefix = env["prefix"]

# Get information about installation paths
script = """\
Expand Down

0 comments on commit d596347

Please sign in to comment.