Rename module to opensearchpy
To avoid conflict with an existing package by name 'opensearch' being present Signed-off-by: Rushi Agrawal <[email protected]>
This commit is contained in:
+21
-21
@@ -25,7 +25,7 @@
|
||||
# under the License.
|
||||
|
||||
"""A command line tool for building and verifying releases
|
||||
Can be used for building both 'opensearch' and 'opensearchX' dists.
|
||||
Can be used for building both 'opensearchpy' and 'opensearchpyX' dists.
|
||||
Only requires 'name' in 'setup.py' and the directory to be changed.
|
||||
"""
|
||||
|
||||
@@ -70,7 +70,7 @@ def run(*argv, expect_exit_code=0):
|
||||
|
||||
def test_dist(dist):
|
||||
with set_tmp_dir() as tmp_dir:
|
||||
dist_name = re.match(r"^(opensearch\d*)-", os.path.basename(dist)).group(1)
|
||||
dist_name = re.match(r"^(opensearchpy\d*)-", os.path.basename(dist)).group(1)
|
||||
|
||||
# Build the venv and install the dist
|
||||
run("python", "-m", "venv", os.path.join(tmp_dir, "venv"))
|
||||
@@ -117,18 +117,18 @@ def test_dist(dist):
|
||||
|
||||
# Only need to test 'async_types' for non-aliased package
|
||||
# since 'aliased_types' tests both async and sync.
|
||||
if dist_name == "opensearch":
|
||||
if dist_name == "opensearchpy":
|
||||
run(
|
||||
venv_python,
|
||||
"-m",
|
||||
"mypy",
|
||||
"--strict",
|
||||
os.path.join(base_dir, "test_opensearch/test_types/async_types.py"),
|
||||
os.path.join(base_dir, "test_opensearchpy/test_types/async_types.py"),
|
||||
)
|
||||
|
||||
# Ensure that the namespaces are correct for the dist
|
||||
for suffix in ("", "1", "2", "5", "6", "7", "8", "9", "10"):
|
||||
distx_name = f"opensearch{suffix}"
|
||||
distx_name = f"opensearchpy{suffix}"
|
||||
run(
|
||||
venv_python,
|
||||
"-c",
|
||||
@@ -136,15 +136,15 @@ def test_dist(dist):
|
||||
expect_exit_code=256 if distx_name != dist_name else 0,
|
||||
)
|
||||
|
||||
# Check that sync types work for 'opensearch' and
|
||||
# that aliased types work for 'opensearchX'
|
||||
if dist_name == "opensearch":
|
||||
# Check that sync types work for 'opensearchpy' and
|
||||
# that aliased types work for 'opensearchpyX'
|
||||
if dist_name == "opensearchpy":
|
||||
run(
|
||||
venv_python,
|
||||
"-m",
|
||||
"mypy",
|
||||
"--strict",
|
||||
os.path.join(base_dir, "test_opensearch/test_types/sync_types.py"),
|
||||
os.path.join(base_dir, "test_opensearchpy/test_types/sync_types.py"),
|
||||
)
|
||||
else:
|
||||
run(
|
||||
@@ -152,7 +152,7 @@ def test_dist(dist):
|
||||
"-m",
|
||||
"mypy",
|
||||
"--strict",
|
||||
os.path.join(base_dir, "test_opensearch/test_types/aliased_types.py"),
|
||||
os.path.join(base_dir, "test_opensearchpy/test_types/aliased_types.py"),
|
||||
)
|
||||
|
||||
# Uninstall the dist, see that we can't import things anymore
|
||||
@@ -166,11 +166,11 @@ def test_dist(dist):
|
||||
|
||||
|
||||
def main():
|
||||
run("git", "checkout", "--", "setup.py", "opensearch/")
|
||||
run("git", "checkout", "--", "setup.py", "opensearchpy/")
|
||||
run("rm", "-rf", "build/", "dist/*", "*.egg-info", ".eggs")
|
||||
|
||||
# Grab the major version to be used as a suffix.
|
||||
version_path = os.path.join(base_dir, "opensearch/_version.py")
|
||||
version_path = os.path.join(base_dir, "opensearchpy/_version.py")
|
||||
with open(version_path) as f:
|
||||
version = re.search(
|
||||
r"^__versionstr__\s+=\s+[\"\']([^\"\']+)[\"\']", f.read(), re.M
|
||||
@@ -228,12 +228,12 @@ def main():
|
||||
|
||||
# Rename the module to fit the suffix.
|
||||
shutil.move(
|
||||
os.path.join(base_dir, "opensearch"),
|
||||
os.path.join(base_dir, "opensearch%s" % suffix),
|
||||
os.path.join(base_dir, "opensearchpy"),
|
||||
os.path.join(base_dir, "opensearchpy%s" % suffix),
|
||||
)
|
||||
|
||||
# Ensure that the version within 'opensearch/_version.py' is correct.
|
||||
version_path = os.path.join(base_dir, f"opensearch{suffix}/_version.py")
|
||||
# Ensure that the version within 'opensearchpy/_version.py' is correct.
|
||||
version_path = os.path.join(base_dir, f"opensearchpy{suffix}/_version.py")
|
||||
with open(version_path) as f:
|
||||
version_data = f.read()
|
||||
version_data = re.sub(
|
||||
@@ -251,11 +251,11 @@ def main():
|
||||
setup_py = f.read()
|
||||
with open(setup_py_path, "w") as f:
|
||||
f.truncate()
|
||||
assert 'package_name = "opensearch"' in setup_py
|
||||
assert 'package_name = "opensearchpy"' in setup_py
|
||||
f.write(
|
||||
setup_py.replace(
|
||||
'package_name = "opensearch"',
|
||||
'package_name = "opensearch%s"' % suffix,
|
||||
'package_name = "opensearchpy"',
|
||||
'package_name = "opensearchpy%s"' % suffix,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -263,9 +263,9 @@ def main():
|
||||
run("python", "setup.py", "sdist", "bdist_wheel")
|
||||
|
||||
# Clean up everything.
|
||||
run("git", "checkout", "--", "setup.py", "opensearch/")
|
||||
run("git", "checkout", "--", "setup.py", "opensearchpy/")
|
||||
if suffix:
|
||||
run("rm", "-rf", "opensearch%s/" % suffix)
|
||||
run("rm", "-rf", "opensearchpy%s/" % suffix)
|
||||
|
||||
# Test everything that got created
|
||||
dists = os.listdir(os.path.join(base_dir, "dist"))
|
||||
|
||||
+10
-10
@@ -145,7 +145,7 @@ class Module:
|
||||
def filepath(self):
|
||||
return (
|
||||
CODE_ROOT
|
||||
/ f"opensearch/_async/client/{self.namespace}.py{'i' if self.is_pyi else ''}"
|
||||
/ f"opensearchpy/_async/client/{self.namespace}.py{'i' if self.is_pyi else ''}"
|
||||
)
|
||||
|
||||
|
||||
@@ -185,8 +185,8 @@ class API:
|
||||
# Try setting doc refs like 'current' and 'master' to our branches ref.
|
||||
if BRANCH_NAME is not None:
|
||||
revised_url = re.sub(
|
||||
"/opensearch/reference/[^/]+/",
|
||||
f"/opensearch/reference/{BRANCH_NAME}/",
|
||||
"/opensearchpy/reference/[^/]+/",
|
||||
f"/opensearchpy/reference/{BRANCH_NAME}/",
|
||||
self.doc_url,
|
||||
)
|
||||
if is_valid_url(revised_url):
|
||||
@@ -339,9 +339,9 @@ def download_artifact(version):
|
||||
resp = http.request(
|
||||
"GET", f"https://artifacts-api.elastic.co/v1/versions/{version}"
|
||||
)
|
||||
packages = json.loads(resp.data)["version"]["builds"][0]["projects"]["opensearch"][
|
||||
"packages"
|
||||
]
|
||||
packages = json.loads(resp.data)["version"]["builds"][0]["projects"][
|
||||
"opensearchpy"
|
||||
]["packages"]
|
||||
for package in packages:
|
||||
if re.match(r"^rest-resources-zip-.*\.zip$", package):
|
||||
zip_url = packages[package]["url"]
|
||||
@@ -411,14 +411,14 @@ def dump_modules(modules):
|
||||
}
|
||||
rules = [
|
||||
unasync.Rule(
|
||||
fromdir="/opensearch/_async/client/",
|
||||
todir="/opensearch/client/",
|
||||
fromdir="/opensearchpy/_async/client/",
|
||||
todir="/opensearchpy/client/",
|
||||
additional_replacements=additional_replacements,
|
||||
),
|
||||
]
|
||||
|
||||
filepaths = []
|
||||
for root, _, filenames in os.walk(CODE_ROOT / "opensearch/_async"):
|
||||
for root, _, filenames in os.walk(CODE_ROOT / "opensearchpy/_async"):
|
||||
for filename in filenames:
|
||||
if (
|
||||
filename.rpartition(".")[-1]
|
||||
@@ -431,7 +431,7 @@ def dump_modules(modules):
|
||||
filepaths.append(os.path.join(root, filename))
|
||||
|
||||
unasync.unasync_files(filepaths, rules)
|
||||
blacken(CODE_ROOT / "opensearch")
|
||||
blacken(CODE_ROOT / "opensearchpy")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user