mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix setup.py called with salt args
This commit is contained in:
parent
179532f902
commit
b35db04826
3 changed files with 42 additions and 3 deletions
1
changelog/64114.fixed.md
Normal file
1
changelog/64114.fixed.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix running setup.py when passing in --salt-config-dir and --salt-cache-dir arguments.
|
7
setup.py
7
setup.py
|
@ -5,10 +5,10 @@ The setup script for salt
|
||||||
|
|
||||||
# pylint: disable=file-perms,resource-leakage
|
# pylint: disable=file-perms,resource-leakage
|
||||||
import setuptools # isort:skip
|
import setuptools # isort:skip
|
||||||
|
|
||||||
import distutils.dist
|
import distutils.dist
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
@ -170,8 +170,9 @@ if os.path.exists(SALT_VERSION_HARDCODED):
|
||||||
with open(SALT_VERSION_HARDCODED, encoding="utf-8") as rfh:
|
with open(SALT_VERSION_HARDCODED, encoding="utf-8") as rfh:
|
||||||
SALT_VERSION = rfh.read().strip()
|
SALT_VERSION = rfh.read().strip()
|
||||||
else:
|
else:
|
||||||
exec(compile(open(SALT_VERSION_MODULE).read(), SALT_VERSION_MODULE, "exec"))
|
SALT_VERSION = (
|
||||||
SALT_VERSION = str(__saltstack_version__) # pylint: disable=undefined-variable
|
subprocess.check_output([sys.executable, SALT_VERSION_MODULE]).decode().strip()
|
||||||
|
)
|
||||||
# pylint: enable=W0122
|
# pylint: enable=W0122
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,14 @@ Tests for building and installing salt
|
||||||
"""
|
"""
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
import salt.utils.files
|
||||||
import salt.utils.path
|
import salt.utils.path
|
||||||
import salt.utils.platform
|
import salt.utils.platform
|
||||||
import salt.version
|
import salt.version
|
||||||
|
@ -457,3 +459,38 @@ def test_setup_install(virtualenv, cache_dir, use_static_requirements, src_dir):
|
||||||
installed_salt_path = installed_salt_path[0] / "salt"
|
installed_salt_path = installed_salt_path[0] / "salt"
|
||||||
salt_generated_version_file_path = installed_salt_path / "_version.txt"
|
salt_generated_version_file_path = installed_salt_path / "_version.txt"
|
||||||
assert salt_generated_version_file_path.is_file()
|
assert salt_generated_version_file_path.is_file()
|
||||||
|
|
||||||
|
|
||||||
|
def test_salt_install_args(
|
||||||
|
virtualenv, cache_dir, use_static_requirements, src_dir, tmp_path
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
test building with `install` command with --salt-*
|
||||||
|
args. For example, --salt-config-dir and --salt-cache-dir.
|
||||||
|
"""
|
||||||
|
cache_dir = tmp_path / "cache_dir"
|
||||||
|
config_dir = tmp_path / "config_dir"
|
||||||
|
# Let's create the testing virtualenv
|
||||||
|
with virtualenv as venv:
|
||||||
|
venv.run(venv.venv_python, "setup.py", "clean", cwd=src_dir)
|
||||||
|
env = os.environ.copy()
|
||||||
|
env["GENERATE_SALT_SYSPATHS"] = "True"
|
||||||
|
ret = venv.run(
|
||||||
|
venv.venv_python,
|
||||||
|
"setup.py",
|
||||||
|
"--salt-config-dir",
|
||||||
|
str(config_dir),
|
||||||
|
"--salt-cache-dir",
|
||||||
|
str(cache_dir),
|
||||||
|
"install",
|
||||||
|
cwd=src_dir,
|
||||||
|
env=env,
|
||||||
|
)
|
||||||
|
assert ret.returncode == 0
|
||||||
|
syspath = pathlib.Path(src_dir, "build", "lib", "salt", "_syspaths.py")
|
||||||
|
assert syspath.exists()
|
||||||
|
with salt.utils.files.fopen(syspath) as fp:
|
||||||
|
data = fp.read()
|
||||||
|
assert str(cache_dir) in data
|
||||||
|
assert str(config_dir) in data
|
||||||
|
venv.run(venv.venv_python, "setup.py", "clean", cwd=src_dir)
|
||||||
|
|
Loading…
Add table
Reference in a new issue