5555import zipfile
5656
5757
58- VTK_MANYLINUX = None
59- if platform .system () == "Linux" and os .getenv ("VTK_MANYLINUX" ):
60- VTK_MANYLINUX = pathlib .Path (os .getenv ("VTK_MANYLINUX" )).resolve ()
61- if not (VTK_MANYLINUX / "vtkmodules" / "__init__.py" ).exists ():
62- raise Exception (f"invalid VTK_MANYLINUX: { VTK_MANYLINUX } " )
63-
64-
65- def populate_lib_dir (conda_prefix , vtk_manylinux , out_dir ):
66- """Merge non-vtk conda libs and vtk manylinux libs into a single directory"""
67-
68- conda_prefix = pathlib .Path (conda_prefix )
69- vtk_manylinux = pathlib .Path (vtk_manylinux )
70- out_dir = pathlib .Path (out_dir )
71-
72- fns = list ((conda_prefix / "conda-meta" ).glob ("vtk-9*-qt_*.json" ))
73- if len (fns ) != 1 :
74- raise Exception (f"could not find unique vtk meta: { fns } " )
75- vtk_meta = json .loads (fns [0 ].read_text ())
76- vtk_files = {conda_prefix / f for f in vtk_meta ["files" ]}
77-
78- # Do not copy regular VTK files because we will use manylinux
79- # files instead. Do copy VTK symlinks because they're expected by
80- # other conda packages which we may bundle into the wheel.
81- vtk_skipped_files = []
82- for f in (conda_prefix / "lib" ).iterdir ():
83- if f .is_dir ():
84- continue
85- if f in vtk_files and not f .is_symlink ():
86- vtk_skipped_files .append (f )
87- else :
88- shutil .copy2 (f , out_dir , follow_symlinks = False )
89-
90- # Copy VTK files. Symlinks in the target will be followed so we
91- # are fixing broken symlinks.
92- for f in (vtk_manylinux / "vtkmodules" ).glob ("lib*.so*" ):
93- shutil .copy2 (f , out_dir , follow_symlinks = False )
94-
95- # The VTK manylinux wheel may not provide all the libraries of the
96- # VTK conda pkg, so there may be missing files or broken symlinks.
97- # If this is problematic then auditwheel will fail. For now,
98- # print some helpful information.
99- for f in vtk_skipped_files :
100- if not (out_dir / f .name ).exists ():
101- print ("manylinux whl did not provide:" , f )
102-
103- # Copy the rest of the libraries bundled in the VTK wheel.
104- for f in (vtk_manylinux / "vtk.libs" ).glob ("lib*.so*" ):
105- shutil .copy2 (f , out_dir , follow_symlinks = False )
58+ # VTK_MANYLINUX = None
59+ # if platform.system() == "Linux" and os.getenv("VTK_MANYLINUX"):
60+ # VTK_MANYLINUX = pathlib.Path(os.getenv("VTK_MANYLINUX")).resolve()
61+ # if not (VTK_MANYLINUX / "vtkmodules" / "__init__.py").exists():
62+ # raise Exception(f"invalid VTK_MANYLINUX: {VTK_MANYLINUX}")
63+
64+
65+ # def populate_lib_dir(conda_prefix, vtk_manylinux, out_dir):
66+ # """Merge non-vtk conda libs and vtk manylinux libs into a single directory"""
67+
68+ # conda_prefix = pathlib.Path(conda_prefix)
69+ # vtk_manylinux = pathlib.Path(vtk_manylinux)
70+ # out_dir = pathlib.Path(out_dir)
71+
72+ # fns = list((conda_prefix / "conda-meta").glob("vtk-9*-qt_*.json"))
73+ # if len(fns) != 1:
74+ # raise Exception(f"could not find unique vtk meta: {fns}")
75+ # vtk_meta = json.loads(fns[0].read_text())
76+ # vtk_files = {conda_prefix / f for f in vtk_meta["files"]}
77+
78+ # # Do not copy regular VTK files because we will use manylinux
79+ # # files instead. Do copy VTK symlinks because they're expected by
80+ # # other conda packages which we may bundle into the wheel.
81+ # vtk_skipped_files = []
82+ # for f in (conda_prefix / "lib").iterdir():
83+ # if f.is_dir():
84+ # continue
85+ # if f in vtk_files and not f.is_symlink():
86+ # vtk_skipped_files.append(f)
87+ # else:
88+ # shutil.copy2(f, out_dir, follow_symlinks=False)
89+
90+ # # Copy VTK files. Symlinks in the target will be followed so we
91+ # # are fixing broken symlinks.
92+ # for f in (vtk_manylinux / "vtkmodules").glob("lib*.so*"):
93+ # shutil.copy2(f, out_dir, follow_symlinks=False)
94+
95+ # # The VTK manylinux wheel may not provide all the libraries of the
96+ # # VTK conda pkg, so there may be missing files or broken symlinks.
97+ # # If this is problematic then auditwheel will fail. For now,
98+ # # print some helpful information.
99+ # for f in vtk_skipped_files:
100+ # if not (out_dir / f.name).exists():
101+ # print("manylinux whl did not provide:", f)
102+
103+ # # Copy the rest of the libraries bundled in the VTK wheel.
104+ # for f in (vtk_manylinux / "vtk.libs").glob("lib*.so*"):
105+ # shutil.copy2(f, out_dir, follow_symlinks=False)
106106
107107
108108class copy_installed (setuptools .command .build_ext .build_ext ):
@@ -116,22 +116,22 @@ def build_extension(self, ext):
116116 # OCP is a single-file extension; just copy it
117117 shutil .copy (OCP .__file__ , self .build_lib )
118118 # vtkmodules is a package; copy it while excluding __pycache__
119- if VTK_MANYLINUX :
120- # Copy python source files and python extensions, but not
121- # shared libraries. We will point auditwheel to them
122- # separately to be bundled in.
123- shutil .copytree (
124- os .path .join (VTK_MANYLINUX , "vtkmodules" ),
125- os .path .join (self .build_lib , "vtkmodules" ),
126- ignore = shutil .ignore_patterns ("__pycache__" , "libvtk*.so*" ),
127- )
128- else :
129- assert vtkmodules .__file__ .endswith (os .path .join (os .sep , "vtkmodules" , "__init__.py" ))
130- shutil .copytree (
131- os .path .dirname (vtkmodules .__file__ ),
132- os .path .join (self .build_lib , "vtkmodules" ),
133- ignore = shutil .ignore_patterns ("__pycache__" ),
134- )
119+ # if VTK_MANYLINUX:
120+ # # Copy python source files and python extensions, but not
121+ # # shared libraries. We will point auditwheel to them
122+ # # separately to be bundled in.
123+ # shutil.copytree(
124+ # os.path.join(VTK_MANYLINUX, "vtkmodules"),
125+ # os.path.join(self.build_lib, "vtkmodules"),
126+ # ignore=shutil.ignore_patterns("__pycache__", "libvtk*.so*"),
127+ # )
128+ # else:
129+ # assert vtkmodules.__file__.endswith(os.path.join(os.sep, "vtkmodules", "__init__.py"))
130+ # shutil.copytree(
131+ # os.path.dirname(vtkmodules.__file__),
132+ # os.path.join(self.build_lib, "vtkmodules"),
133+ # ignore=shutil.ignore_patterns("__pycache__"),
134+ # )
135135
136136
137137class bdist_wheel_repaired (wheel .bdist_wheel .bdist_wheel ):
@@ -163,12 +163,12 @@ def run(self):
163163 out_dir = os .path .join (self .dist_dir , "repaired" )
164164 system = platform .system ()
165165 if system == "Linux" :
166- if VTK_MANYLINUX :
167- # Create a lib dir with VTK manylinux files merged in,
168- # and point auditwheel to it.
169- merged_lib_dir = tempfile .mkdtemp ()
170- populate_lib_dir (conda_prefix , VTK_MANYLINUX , merged_lib_dir )
171- lib_path = merged_lib_dir
166+ # if VTK_MANYLINUX:
167+ # # Create a lib dir with VTK manylinux files merged in,
168+ # # and point auditwheel to it.
169+ # merged_lib_dir = tempfile.mkdtemp()
170+ # populate_lib_dir(conda_prefix, VTK_MANYLINUX, merged_lib_dir)
171+ # lib_path = merged_lib_dir
172172 repair_wheel_linux (lib_path , bad_whl , out_dir )
173173 elif system == "Darwin" :
174174 repair_wheel_macos (lib_path , bad_whl , out_dir )
@@ -272,7 +272,7 @@ def add_licenses_bundled(conda_prefix, whl, added_files):
272272 with open (os .path .join (dist_info ,"LICENSES_bundled" ), "w" ) as f :
273273 f .write ("This wheel distribution bundles a number of libraries that\n " )
274274 f .write ("are compatibly licensed. We list them here.\n " )
275- write_licenses (conda_prefix , whl , ["ocp" , "vtk" ], added_files , f )
275+ write_licenses (conda_prefix , whl , ["ocp" ], added_files , f ) # , "vtk"
276276
277277 subprocess .check_call (["wheel" , "pack" , "-d" , os .path .dirname (whl ), os .path .dirname (dist_info )])
278278
@@ -378,7 +378,7 @@ def try_unmangle(n):
378378setup (
379379 name = "cadquery-ocp" ,
380380 version = wheel_version ,
381- description = "OCP+VTK wheel with shared library dependencies bundled." ,
381+ description = "OCP wheel with shared library dependencies bundled." ,
382382 long_description = open ("README.md" ).read (),
383383 long_description_content_type = 'text/markdown' ,
384384 author = "adam-urbanczyk, fp473 (wheel generation), roipoussiere (wheel generation)" ,
@@ -396,6 +396,7 @@ def try_unmangle(n):
396396 "Topic :: Software Development :: Libraries :: Python Modules" ,
397397 "Topic :: Scientific/Engineering"
398398 ],
399+ install_requires = ["vtk" ],
399400 # Dummy extension to trigger build_ext
400401 ext_modules = [Extension ("__dummy__" , sources = [])],
401402 cmdclass = {"bdist_wheel" : bdist_wheel_repaired , "build_ext" : copy_installed },
0 commit comments