Skip to content

Commit

Permalink
[7.x] Update build_dists.py to build namespaced packages
Browse files Browse the repository at this point in the history
Co-authored-by: Seth Michael Larson <seth.larson@elastic.co>
  • Loading branch information
github-actions[bot] and sethmlarson committed Sep 21, 2020
1 parent 7802eee commit 6250aac
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion utils/build_dists.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,41 @@ def test_dist(dist):

def main():
run("rm", "-rf", "build/", "dist/", "*.egg-info", ".eggs")
run("python", "setup.py", "sdist", "bdist_wheel")

# Grab the major version to be used as a suffix.
setup_py_path = os.path.join(base_dir, "setup.py")
with open(setup_py_path) as f:
major_version = re.search(r"^VERSION = \((\d+),", f.read(), re.M).group(1)

for suffix in ("", major_version):
run("rm", "-rf", "build/", "*.egg-info", ".eggs")

# Rename the module to fit the suffix.
shutil.move(
os.path.join(base_dir, "elasticsearch"),
os.path.join(base_dir, "elasticsearch%s" % suffix),
)

# Rewrite setup.py with the new name.
with open(setup_py_path) as f:
setup_py = f.read()
with open(setup_py_path, "w") as f:
f.truncate()
f.write(
setup_py.replace(
'name="elasticsearch",', 'name="elasticsearch%s",' % suffix
)
)

# Build the sdist/wheels
run("python", "setup.py", "sdist", "bdist_wheel")

# Clean up everything.
run("git", "checkout", "--", "setup.py", "elasticsearch/")
if suffix:
run("rm", "-rf", "elasticsearch%s/" % suffix)

# Test everything that got created
for dist in os.listdir(os.path.join(base_dir, "dist")):
test_dist(os.path.join(base_dir, "dist", dist))

Expand Down

0 comments on commit 6250aac

Please sign in to comment.