Merge pull request #587 from modoboa/update/install-reqs-process
Use extras instead of requirements file
This commit is contained in:
@@ -89,16 +89,6 @@ def install_package_from_repository(name, url, vcs="git", venv=None, **kwargs):
|
|||||||
utils.exec_cmd(cmd, **kwargs)
|
utils.exec_cmd(cmd, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def install_package_from_remote_requirements(url, venv=None, **kwargs):
|
|
||||||
"""Install a Python package from a file."""
|
|
||||||
cmd = "{} install {} {}".format(
|
|
||||||
get_pip_path(venv),
|
|
||||||
"-r",
|
|
||||||
url
|
|
||||||
)
|
|
||||||
utils.exec_cmd(cmd, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
def setup_virtualenv(path, sudo_user=None):
|
def setup_virtualenv(path, sudo_user=None):
|
||||||
"""Install a virtualenv if needed."""
|
"""Install a virtualenv if needed."""
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
|
|||||||
@@ -81,8 +81,13 @@ class Modoboa(base.Installer):
|
|||||||
python.setup_virtualenv(self.venv_path, sudo_user=self.user)
|
python.setup_virtualenv(self.venv_path, sudo_user=self.user)
|
||||||
packages = ["rrdtool"]
|
packages = ["rrdtool"]
|
||||||
version = self.config.get("modoboa", "version")
|
version = self.config.get("modoboa", "version")
|
||||||
|
extras = "postgresql"
|
||||||
|
if self.dbengine != "postgres":
|
||||||
|
extras = "mysql"
|
||||||
|
if self.devmode:
|
||||||
|
extras += ",dev"
|
||||||
if version == "latest":
|
if version == "latest":
|
||||||
packages += ["modoboa"] + self.extensions
|
packages += [f"modoboa[{extras}]"] + self.extensions
|
||||||
for extension in list(self.extensions):
|
for extension in list(self.extensions):
|
||||||
if extension in compatibility_matrix.REMOVED_EXTENSIONS.keys():
|
if extension in compatibility_matrix.REMOVED_EXTENSIONS.keys():
|
||||||
self.extensions.remove(extension)
|
self.extensions.remove(extension)
|
||||||
@@ -92,7 +97,7 @@ class Modoboa(base.Installer):
|
|||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
matrix = compatibility_matrix.COMPATIBILITY_MATRIX[version]
|
matrix = compatibility_matrix.COMPATIBILITY_MATRIX[version]
|
||||||
packages.append("modoboa=={}".format(version))
|
packages.append(f"modoboa[{extras}]=={version}")
|
||||||
for extension in list(self.extensions):
|
for extension in list(self.extensions):
|
||||||
if not self.is_extension_ok_for_version(extension, version):
|
if not self.is_extension_ok_for_version(extension, version):
|
||||||
self.extensions.remove(extension)
|
self.extensions.remove(extension)
|
||||||
@@ -116,25 +121,6 @@ class Modoboa(base.Installer):
|
|||||||
beta=self.config.getboolean("modoboa", "install_beta")
|
beta=self.config.getboolean("modoboa", "install_beta")
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install version specific modules to the venv
|
|
||||||
modoboa_version = ".".join(str(i) for i in python.get_package_version(
|
|
||||||
"modoboa", self.venv_path, sudo_user=self.user
|
|
||||||
))
|
|
||||||
# Database:
|
|
||||||
db_file = "postgresql"
|
|
||||||
if self.dbengine != "postgres":
|
|
||||||
db_file = "mysql"
|
|
||||||
db_file += "-requirements.txt"
|
|
||||||
|
|
||||||
python.install_package_from_remote_requirements(
|
|
||||||
f"https://raw.githubusercontent.com/modoboa/modoboa/{modoboa_version}/{db_file}",
|
|
||||||
venv=self.venv_path)
|
|
||||||
# Dev mode:
|
|
||||||
if self.devmode:
|
|
||||||
python.install_package_from_remote_requirements(
|
|
||||||
f"https://raw.githubusercontent.com/modoboa/modoboa/{modoboa_version}/dev-requirements.txt",
|
|
||||||
venv=self.venv_path)
|
|
||||||
|
|
||||||
def _deploy_instance(self):
|
def _deploy_instance(self):
|
||||||
"""Deploy Modoboa."""
|
"""Deploy Modoboa."""
|
||||||
target = os.path.join(self.home_dir, "instance")
|
target = os.path.join(self.home_dir, "instance")
|
||||||
|
|||||||
Reference in New Issue
Block a user