Skip to content

Commit

Permalink
CI(full): Fix sdist
Browse files Browse the repository at this point in the history
  • Loading branch information
wtdcode committed Dec 21, 2024
1 parent 8c0e034 commit bcc90e0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ jobs:

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.config.os }}-${{ strategy.job-index }}
name: cibw-wheels-${{ matrix.config.os }}-${{ strategy.job-index }}-all
path: ./wheelhouse/*.whl

make_sdist:
Expand Down
26 changes: 22 additions & 4 deletions build_mdbx.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,33 @@

def ensure_dependency():
subprocess.check_call(["cmake", "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if sys.platform == "win32" or sys.platform == "darwin":
subprocess.check_call(["ninja", "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

def have_git():
try:
subprocess.check_call(["git", "--version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
return True
except Exception as e:
return False

def build(setup_kws: dict):
ensure_dependency()
debug = "DEBUG" in os.environ
pwd = Path(__file__).parent.resolve()
out_lib = pwd / "mdbx" / "lib"
libmdbx_source = pwd / "libmdbx"
dist_folder = libmdbx_source / "dist"

# If there is already dist
if not dist_folder.exists():
if sys.platform in ["linux", "linux2", "darwin"]:
subprocess.check_call(["make", "dist"], cwd=libmdbx_source)

if have_git() and (libmdbx_source / ".git").exists():
source_folder = libmdbx_source
elif dist_folder.exists():
source_folder = dist_folder
else:
raise RuntimeError("Either we need git or we must have a dist available. Did you init submodules?")

tmpdir = None
if debug:
Expand Down Expand Up @@ -55,7 +73,7 @@ def build(setup_kws: dict):
]

cmake_gen += [
"-S", str(libmdbx_source.absolute()), "-B", str(tmpdir_path.absolute())
"-S", str(source_folder.absolute()), "-B", str(tmpdir_path.absolute())
]
cmake_gen += build_type
subprocess.check_call(
Expand All @@ -69,7 +87,7 @@ def build(setup_kws: dict):
if out_lib.exists():
shutil.rmtree(out_lib)
os.makedirs(out_lib, exist_ok=True)
shutil.copy(libmdbx_source / "LICENSE", out_lib)
shutil.copy(source_folder / "LICENSE", out_lib)

if sys.platform != "win32":
subprocess.check_call(
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ packages = [
{include = "mdbx"}
]
include = [
{ path = "libmdbx/*", format = "sdist"},
{ path = "libmdbx/dist/*", format = "sdist"},
{ path = "mdbx/lib/*", format = "wheel" },
]

exclude = [
{ path = "libmdbx/.git", format = "sdist"},
{ path = "libmdbx/dist/build", format = "sdist"},
]

[tool.poetry.build]
Expand Down

0 comments on commit bcc90e0

Please sign in to comment.