Skip to content

Commit

Permalink
fix: make docs path if not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelgold committed Jan 7, 2024
1 parent 2670236 commit 436e833
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 179 deletions.
2 changes: 1 addition & 1 deletion blender
Submodule blender updated 56 files
+1 −1 GNUmakefile
+73 −19 doc/manpage/blender.1.py
+4 −4 intern/cycles/blender/attribute_convert.h
+1 −1 intern/cycles/device/optix/device_impl.cpp
+8 −16 intern/cycles/kernel/CMakeLists.txt
+1 −1 intern/cycles/kernel/closure/bsdf_sheen.h
+15 −0 intern/cycles/kernel/sample/mapping.h
+3 −3 intern/cycles/util/thread.cpp
+1 −1 intern/cycles/util/thread.h
+78 −14 intern/ghost/intern/GHOST_SystemWayland.cc
+21 −12 intern/ghost/intern/GHOST_WindowWayland.cc
+1 −0 scripts/presets/keyconfig/keymap_data/blender_default.py
+5 −0 scripts/startup/bl_ui/space_view3d_toolbar.py
+1 −1 source/blender/blenkernel/BKE_blender_version.h
+18 −0 source/blender/blenkernel/intern/data_transfer.cc
+1 −0 source/blender/blenkernel/intern/key.cc
+2 −2 source/blender/blenkernel/intern/mesh_boolean_convert.cc
+1 −1 source/blender/blenkernel/intern/particle.cc
+0 −9 source/blender/blenloader/intern/readfile.cc
+1 −1 source/blender/draw/engines/eevee_next/shaders/eevee_light_culling_tile_comp.glsl
+4 −4 source/blender/draw/engines/eevee_next/shaders/eevee_lightprobe_irradiance_bounds_comp.glsl
+5 −5 source/blender/draw/engines/eevee_next/shaders/eevee_shadow_tag_update_comp.glsl
+5 −5 source/blender/draw/engines/eevee_next/shaders/eevee_shadow_tilemap_bounds_comp.glsl
+4 −4 source/blender/draw/engines/workbench/shaders/workbench_shadow_visibility_comp.glsl
+3 −1 source/blender/draw/engines/workbench/workbench_engine.cc
+24 −0 source/blender/draw/intern/DRW_gpu_wrapper.hh
+1 −1 source/blender/draw/intern/draw_command.cc
+9 −1 source/blender/draw/intern/draw_command.hh
+5 −0 source/blender/draw/intern/draw_manager.cc
+9 −9 source/blender/draw/intern/shaders/common_intersect_lib.glsl
+4 −4 source/blender/draw/intern/shaders/draw_visibility_comp.glsl
+4 −0 source/blender/editors/interface/interface_handlers.cc
+1 −1 source/blender/editors/object/object_add.cc
+0 −2 source/blender/editors/render/render_opengl.cc
+2 −2 source/blender/editors/sculpt_paint/paint_image_2d.cc
+11 −4 source/blender/editors/sculpt_paint/paint_image_proj.cc
+5 −0 source/blender/editors/space_node/space_node.cc
+3 −2 source/blender/editors/space_sequencer/sequencer_preview_draw.cc
+5 −0 source/blender/editors/space_sequencer/sequencer_retiming.cc
+17 −15 source/blender/editors/space_sequencer/sequencer_timeline_draw.cc
+25 −1 source/blender/editors/space_view3d/view3d_select.cc
+4 −0 source/blender/editors/transform/transform.cc
+6 −0 source/blender/editors/transform/transform_mode_snapsource.cc
+22 −13 source/blender/editors/transform/transform_snap_object.cc
+1 −0 source/blender/freestyle/intern/system/PythonInterpreter.h
+6 −0 source/blender/gpu/opengl/gl_backend.cc
+1 −0 source/blender/makesrna/intern/rna_ID.cc
+1 −1 source/blender/makesrna/intern/rna_fcurve.cc
+3 −1 source/blender/modifiers/intern/MOD_array.cc
+5 −1 source/blender/python/generic/idprop_py_ui_api.cc
+15 −0 source/blender/python/intern/bpy_capi_utils.cc
+4 −9 source/blender/python/intern/bpy_capi_utils.h
+6 −6 source/blender/python/intern/bpy_interface_run.cc
+3 −12 source/blender/python/intern/bpy_rna.cc
+12 −6 source/blender/sequencer/intern/strip_retiming.cc
+4 −6 source/creator/CMakeLists.txt
8 changes: 7 additions & 1 deletion workspace/generate_package_index.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pathlib import Path
import typer
from github import Github

Expand All @@ -22,8 +23,13 @@ def main(token: str, repository: str):

html_index += "</body></html>"

# Ensure the docs directory exists
docs_path = Path('docs')
docs_path.mkdir(parents=True, exist_ok=True)

# Write the HTML index to a file
with open('docs/index.html', 'w') as file:
index_path = docs_path / 'index.html'
with index_path.open('w') as file:
file.write(html_index)

print("Package index generated successfully.")
Expand Down
211 changes: 35 additions & 176 deletions workspace/make_stubs_wheel.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,39 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2022-2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later

"""
Make Python wheel package (`*.whl`) file from Blender built with 'WITH_PYTHON_MODULE' enabled.
Example
=======
If the "bpy" module was build on Linux using the command:
make bpy lite
The command to package it as a wheel is:
./build_files/utils/make_bpy_wheel.py ../build_linux_bpy_lite/bin --output-dir=./
This will create a `*.whl` file in the current directory.
"""

import argparse
import make_utils
import os
import re
import sys
import platform
import string
import setuptools
import sys

from typing import (
Generator,
List,
Optional,
Sequence,
Tuple,
)
from pathlib import Path

# ------------------------------------------------------------------------------
# Long Description
# Argument Parser

long_description = """# Blender
def argparse_create() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"install_dir",
metavar='INSTALL_DIR',
type=str,
help="The installation directory containing the \"bpy\" package.",
)
parser.add_argument(
"--output-dir",
metavar='OUTPUT_DIR',
default=None,
help="The destination directory for the '*.whl' file (use INSTALL_DIR when omitted).",
required=False,
)

return parser

# ------------------------------------------------------------------------------
long_description = """# Blender
[Blender](https://www.blender.org) is the free and open source 3D creation suite. It supports the entirety of the 3D pipeline—modeling, rigging, animation, simulation, rendering, compositing and motion tracking, even video editing.
This package provides Blender as a Python module for use in studio pipelines, web services, scientific research, and more.
Expand All @@ -68,85 +60,11 @@
Thanks to Tyler Alden Gubala for maintaining the original version of this package."""

# ------------------------------------------------------------------------------
# Generic Functions


def find_dominating_file(
path: str,
search: Sequence[str],
) -> str:
while True:
for d in search:
if os.path.exists(os.path.join(path, d)):
return os.path.join(path, d)
path_next = os.path.normpath(os.path.join(path, ".."))
if path == path_next:
break
path = path_next
return ""


# ------------------------------------------------------------------------------
# CMake Cache Access

def cmake_cache_var_iter(filepath_cmake_cache: str) -> Generator[Tuple[str, str, str], None, None]:
import re
re_cache = re.compile(r"([A-Za-z0-9_\-]+)?:?([A-Za-z0-9_\-]+)?=(.*)$")
with open(filepath_cmake_cache, "r", encoding="utf-8") as cache_file:
for l in cache_file:
match = re_cache.match(l.strip())
if match is not None:
var, type_, val = match.groups()
yield (var, type_ or "", val)


def cmake_cache_var(filepath_cmake_cache: str, var: str) -> Optional[str]:
for var_iter, type_iter, value_iter in cmake_cache_var_iter(filepath_cmake_cache):
if var == var_iter:
return value_iter
return None


def cmake_cache_var_or_exit(filepath_cmake_cache: str, var: str) -> str:
value = cmake_cache_var(filepath_cmake_cache, var)
if value is None:
sys.stderr.write("Unable to find %r in %r, abort!\n" % (var, filepath_cmake_cache))
sys.exit(1)
return value


# ------------------------------------------------------------------------------
# Argument Parser

def argparse_create() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
"install_dir",
metavar='INSTALL_DIR',
type=str,
help="The installation directory containing the \"bpy\" package.",
)
parser.add_argument(
"--build-dir",
metavar='BUILD_DIR',
default=None,
help="The build directory containing 'CMakeCache.txt' (search parent directories of INSTALL_DIR when omitted).",
required=False,
)
parser.add_argument(
"--output-dir",
metavar='OUTPUT_DIR',
default=None,
help="The destination directory for the '*.whl' file (use INSTALL_DIR when omitted).",
required=False,
)

return parser
# Main Function


# ------------------------------------------------------------------------------
# Main Function

def main() -> None:

Expand All @@ -156,105 +74,46 @@ def main() -> None:
install_dir = os.path.abspath(args.install_dir)
output_dir = os.path.abspath(args.output_dir) if args.output_dir else install_dir

if args.build_dir:
build_dir = os.path.abspath(args.build_dir)
filepath_cmake_cache = os.path.join(build_dir, "CMakeCache.txt")
del build_dir
if not os.path.exists(filepath_cmake_cache):
sys.stderr.write("File not found %r, abort!\n" % filepath_cmake_cache)
sys.exit(1)
else:
filepath_cmake_cache = find_dominating_file(install_dir, ("CMakeCache.txt",))
if not filepath_cmake_cache:
# Should never fail.
sys.stderr.write("Unable to find CMakeCache.txt in or above %r, abort!\n" % install_dir)
sys.exit(1)

# Get the major and minor Python version.
python_version = cmake_cache_var_or_exit(filepath_cmake_cache, "PYTHON_VERSION")
python_version_number = (
tuple(int("".join(c for c in digit if c in string.digits)) for digit in python_version.split(".")) +
# Support version without a minor version "3" (add zero).
tuple((0, 0, 0))
)
python_version_str = "%d.%d" % python_version_number[:2]

# Get Blender version.
blender_version_str = str(make_utils.parse_blender_version())

# Set platform tag following conventions.
if sys.platform == "darwin":
target = cmake_cache_var_or_exit(filepath_cmake_cache, "CMAKE_OSX_DEPLOYMENT_TARGET").split(".")
machine = cmake_cache_var_or_exit(filepath_cmake_cache, "CMAKE_OSX_ARCHITECTURES")
platform_tag = "macosx_%d_%d_%s" % (int(target[0]), int(target[1]), machine)
platform_tag = "macosx_10_15_x86_64" # Example tag, adjust as needed
elif sys.platform == "win32":
platform_tag = "win_%s" % (platform.machine().lower())
platform_tag = "win_amd64" # Example tag, adjust as needed
elif sys.platform == "linux":
glibc = os.confstr("CS_GNU_LIBC_VERSION")
if glibc is None:
sys.stderr.write("Unable to find \"CS_GNU_LIBC_VERSION\", abort!\n")
sys.exit(1)
glibc = "%s_%s" % tuple(glibc.split()[1].split(".")[:2])
platform_tag = "manylinux_%s_%s" % (glibc, platform.machine().lower())
platform_tag = "manylinux1_x86_64" # Example tag, adjust as needed
else:
sys.stderr.write("Unsupported platform: %s, abort!\n" % (sys.platform))
sys.exit(1)

os.chdir(install_dir)


# Include only .pyi files recursively.
def package_files(root_dir: str) -> List[str]:
paths = []
for path, dirs, files in os.walk(root_dir):
paths += [os.path.join("..", path, f) for f in files if f.endswith('.pyi')]
return paths

# Ensure this wheel is marked platform specific.
class BinaryDistribution(setuptools.dist.Distribution):
def has_ext_modules(self) -> bool:
return True

# Build wheel.
sys.argv = [sys.argv[0], "bdist_wheel"]

setuptools.setup(
name="bpygold",
version=blender_version_str,
install_requires=["cython", "numpy", "requests", "zstandard"],
python_requires="==%d.%d.*" % (python_version_number[0], python_version_number[1]),
version="4.0.1", # Example version, adjust as needed
packages=["bpy"],
package_data={"": package_files(build_dir)}, # Update this path
distclass=BinaryDistribution,
distclass=setuptools.dist.Distribution,
options={"bdist_wheel": {"plat_name": platform_tag}},

description="Blender as a Python module",
long_description=long_description,

long_description_content_type='text/markdown',
license="GPL-3.0",
author="Michael Gold",
author_email="[email protected]",
url="https://mike.gold"
author="Michael Gold", # Adjust as needed
author_email="[email protected]", # Adjust as needed
url="https://mike.gold" # Adjust as needed
)

# Ensure output directory exists and move wheel file there.
if not os.path.exists(output_dir):
os.makedirs(output_dir)

# Move wheel to output directory.
dist_dir = os.path.join(install_dir, "dist")
for f in os.listdir(dist_dir):
if f.endswith(".whl"):
blender_py = "cp%d%d" % (python_version_number[0], python_version_number[1])

# No apparent way to override this ABI version with setuptools, so rename.
sys_py = "cp%d%d" % (sys.version_info.major, sys.version_info.minor)
if hasattr(sys, "abiflags"):
sys_py_abi = sys_py + sys.abiflags
renamed_f = f.replace(sys_py_abi, blender_py).replace(sys_py, blender_py)
else:
renamed_f = f.replace(sys_py, blender_py)

os.rename(os.path.join(dist_dir, f), os.path.join(output_dir, renamed_f))
if f.endswith(".pyi"):
os.rename(os.path.join(dist_dir, f), os.path.join(output_dir, f))


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion workspace/make_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def __str__(self) -> str:


def parse_blender_version() -> BlenderVersion:
blender_srcdir = Path(__file__).absolute().parent.parent.parent
blender_srcdir = Path.cwd() / "../blender"
version_path = blender_srcdir / "source/blender/blenkernel/BKE_blender_version.h"

version_info = {}
Expand Down

0 comments on commit 436e833

Please sign in to comment.