|
1 | | -# Copyright (c) Facebook, Inc. and its affiliates. |
2 | | -# |
3 | | -# This source code is licensed under the MIT license found in the |
4 | | -# LICENSE file in the root directory of this source tree. |
5 | | -import glob |
6 | | -import os |
7 | | -import subprocess |
8 | | - |
9 | 1 | from setuptools import find_packages, setup |
10 | 2 | from setuptools.dist import Distribution |
11 | 3 |
|
12 | | -libs = list(glob.glob("./bitsandbytes/libbitsandbytes*.*")) |
13 | | -libs = [os.path.basename(p) for p in libs] |
14 | | -print("libs:", libs) |
15 | | - |
16 | | - |
17 | | -def get_git_commit_hash(): |
18 | | - return subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]).decode("utf-8").strip() |
19 | | - |
20 | | - |
21 | | -def is_git_tagged_commit(): |
22 | | - tags = subprocess.check_output(["git", "tag", "--points-at", "HEAD"]).decode("utf-8").strip() |
23 | | - return bool(tags) |
24 | | - |
25 | | - |
26 | | -def get_latest_semver_tag(): |
27 | | - tags = subprocess.check_output(["git", "tag"], text=True).splitlines() |
28 | | - semver_tags = [tag for tag in tags if tag.count(".") == 2 and all(part.isdigit() for part in tag.split("."))] |
29 | | - if not semver_tags: |
30 | | - print("No valid semantic version tags found, use 1.0.0 defaultly") |
31 | | - semver_tags = ["1.0.0"] |
32 | | - return sorted(semver_tags, key=lambda s: list(map(int, s.split("."))))[-1] |
33 | | - |
34 | | - |
35 | | -def write_version_file(version, filepath="bitsandbytes/_version.py"): |
36 | | - with open(filepath, "w") as f: |
37 | | - f.write(f'__version__ = "{version}"\n') |
38 | | - |
39 | | - |
40 | | -def get_version_and_write_to_file(): |
41 | | - latest_semver_tag = get_latest_semver_tag() |
42 | | - version = latest_semver_tag if is_git_tagged_commit() else f"{latest_semver_tag}.dev+{get_git_commit_hash()}" |
43 | | - write_version_file(version) |
44 | | - return version |
45 | | - |
46 | 4 |
|
47 | | -# Tested with wheel v0.29.0 |
| 5 | +# Tested with wheel v0.45.1 |
48 | 6 | class BinaryDistribution(Distribution): |
49 | 7 | def has_ext_modules(self): |
50 | 8 | return True |
51 | 9 |
|
52 | 10 |
|
53 | | -setup(version=get_version_and_write_to_file(), packages=find_packages(), distclass=BinaryDistribution) |
| 11 | +setup(packages=find_packages(), distclass=BinaryDistribution) |
0 commit comments