diff --git a/.github/workflows/deploy-wheels.yaml b/.github/workflows/pypi.yml similarity index 76% rename from .github/workflows/deploy-wheels.yaml rename to .github/workflows/pypi.yml index e49fede..17b6f34 100644 --- a/.github/workflows/deploy-wheels.yaml +++ b/.github/workflows/pypi.yml @@ -2,11 +2,6 @@ name: Build on: push: - branches: - - deploy-pypi-test - - deploy-pypi - # Release branches - #- "[0-9]+.[0-9]+.X" # Manual run workflow_dispatch: @@ -78,8 +73,12 @@ jobs: name: Upload to PyPI test needs: [build_wheels_win_32, build_wheels_win_64] runs-on: ubuntu-latest - # upload to PyPI test only for pushes to 'deploy-pypi-test' - if: github.event_name == 'push' && github.ref == 'refs/heads/deploy-pypi-test' + environment: + name: pypi + url: https://test.pypi.org/project/delphivcl + permissions: + id-token: write + if: github.ref == 'refs/heads/main' steps: - uses: actions/download-artifact@v2 with: @@ -87,18 +86,20 @@ jobs: path: dist - name: Publish package to TestPyPI - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 with: - user: ${{ secrets.test_pypi_username }} - password: ${{ secrets.test_pypi_password }} - repository_url: https://test.pypi.org/legacy/ + repository_url: https://test.pypi.org/legacy/ upload_pypi: name: Upload to PyPI needs: [build_wheels_win_32, build_wheels_win_64] runs-on: ubuntu-latest - # upload to PyPI only for pushes to 'deploy-pypi' - if: github.event_name == 'push' && github.ref == 'refs/heads/deploy-pypi' + environment: + name: pypi + url: https://pypi.org/project/delphivcl/ + permissions: + id-token: write + if: startsWith(github.ref, 'refs/tags/v') steps: - uses: actions/download-artifact@v2 with: @@ -106,7 +107,4 @@ jobs: path: dist - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@master - with: - user: ${{ secrets.pypi_username }} - password: ${{ secrets.pypi_password }} + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/.github/workflows/sphinx-build.yaml b/.github/workflows/sphinx-build.yml similarity index 100% rename from .github/workflows/sphinx-build.yaml rename to .github/workflows/sphinx-build.yml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yml similarity index 89% rename from .github/workflows/tests.yaml rename to .github/workflows/tests.yml index b44ae20..f42b658 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yml @@ -3,10 +3,7 @@ name: Tests on: push: branches: - - main - - test - # Release branches - #- "[0-9]+.[0-9]+.X" + - main # Manual run workflow_dispatch: diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..87cfd2a --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include delphivcl *.pyd +recursive-include delphivcl docs.xml \ No newline at end of file diff --git a/build.py b/build.py new file mode 100644 index 0000000..3d3f1e2 --- /dev/null +++ b/build.py @@ -0,0 +1,133 @@ +import sys +import os +import sys +import shutil +import time +import platform +import distutils.dir_util +from wheel.bdist_wheel import bdist_wheel + + +''' +BDistWheel forces python and abi wheel tags for binary distributions +''' + + +class BDistWheel(bdist_wheel): + + def finalize_options(self): + bdist_wheel.finalize_options(self) + self.root_is_pure = ("--universal" in sys.argv) + + +''' +Sort out the platform library for binary distribution and add to the package directory. +Place all libraries onto the package directory for source distribution. +Place the XML doc file onto the package directory. +''' + + +class PackageDataBuilder(): + + def __init__(self): + self.pkg_dir = os.path.join(os.curdir, "delphivcl") + self.plat_name = None + for arg in sys.argv: + if arg.startswith("--plat-name=") and (len(arg.split("=")) == 2): + self.plat_name = arg.split("=")[1] + + ''' + Must run "python setup.py clean --all" between builds. + ''' + + def clean_up(self): + lib_dirs = [os.path.join(self.pkg_dir, "Win32"), + os.path.join(self.pkg_dir, "Win64")] + + for lib_dir in lib_dirs: + if os.path.isdir(lib_dir): + shutil.rmtree(lib_dir) + + # Wait until the OS remove all dirs + for lib_dir in lib_dirs: + for attempts in range(3): + if not os.path.isdir(lib_dir): + break + else: + time.sleep(1) + + ''' + Cross-compiling wheel. + This generates a wheel following the cross platform set on --plat-name. + See: https://docs.python.org/3/distutils/builtdist.html#cross-compiling-on-windows + ''' + + def __check_cross_compiling(self): + is_cross_compiling = False + lib_dir = None + + if self.plat_name: + is_cross_compiling = True + if self.plat_name == "win32": + lib_dir = "Win32" + elif self.plat_name == "win_amd64": + lib_dir = "Win64" + else: + is_cross_compiling = False + + return (is_cross_compiling, lib_dir) + + ''' + Copy the VCL extension module(s) to the package data folder. + Source distributions and Universal binary distributions will deliver + all library versions. The right one will be loaded by __init__.py. + Platform distributions will deliver only the library that matches the runner. + ''' + + def __pick_and_copy_libraries(self): + if ("sdist" in sys.argv) or (("bdist_wheel" in sys.argv) and ("--universal" in sys.argv)): + # sdist/bdist[--universal] deploy all extension modules + distutils.dir_util.copy_tree("lib", self.pkg_dir) + else: + # Deploys the current platform extension module only + is_cross_compiling, lib_dir = self.__check_cross_compiling() + if not is_cross_compiling: + plat_sys = platform.system() + if plat_sys == "Windows": + if (sys.maxsize > 2**32): + # Win x64 + lib_dir = "Win64" + else: + # Win x86 + lib_dir = "Win32" + + if lib_dir: + distutils.dir_util.copy_tree(os.path.join( + "lib", lib_dir), os.path.join(self.pkg_dir, lib_dir)) + else: + raise ValueError("Unsupported platform.") + + ''' + Copy the XML doc file to the package data folder. + The docs.xml file is the result of the compilation of all xml doc files. + ''' + + def __pick_and_copy_docs(self): + # Copy the doc files to the package folder into the doc subfolder + docs_file = os.path.join("docs", "xml", "docs.xml") + if os.path.exists(docs_file): + pkg_doc_dir = os.path.join(self.pkg_dir, "doc") + if not os.path.exists(pkg_doc_dir): + os.mkdir(pkg_doc_dir) + distutils.file_util.copy_file( + docs_file, os.path.join(pkg_doc_dir, "docs.xml")) + + def build_package_data(self): + self.__pick_and_copy_libraries() + self.__pick_and_copy_docs() + + +def setup(): + builder = PackageDataBuilder() + builder.clean_up() + builder.build_package_data() diff --git a/delphivcl/__init__.py b/delphivcl/__init__.py index 7be473c..6bd558a 100644 --- a/delphivcl/__init__.py +++ b/delphivcl/__init__.py @@ -1,47 +1,58 @@ -import sys, os, sys, platform -from os import environ -import importlib, importlib.machinery, importlib.util +import sys +import os +import sys +import platform +import importlib +import importlib.machinery +import importlib.util -class PyVerNotSupported(Exception): - pass -def findmodule(): - pyver = f"{sys.version_info.major}.{sys.version_info.minor}" - ossys = platform.system() - libdir = None +def find_extension_module(): + py_ver = f"{sys.version_info.major}.{sys.version_info.minor}" + plat_sys = platform.system() + lib_dir = None - if not (pyver in ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]): - raise PyVerNotSupported(f"DelphiVCL doesn't support Python{pyver}.") + if not (py_ver in ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]): + raise ValueError(f"DelphiVCL doesn't support Python{py_ver}.") - if ossys == "Windows": - if (sys.maxsize > 2**32): - #Win x64 - libdir = "Win64" + if plat_sys == "Windows": + if (sys.maxsize > 2**32): + # Win x64 + lib_dir = "Win64" + else: + # Win x86 + lib_dir = "Win32" + + if lib_dir: + lib_dir = os.path.join(os.path.dirname( + os.path.abspath(__file__)), lib_dir) + if not os.path.exists(lib_dir): + raise ValueError( + "DelphiVCL module not found. \ + Try to reinstall the delphivcl package or check for support compatibility.") + + for file_name in os.listdir(lib_dir): + if 'DelphiVCL' in file_name: + return os.path.join(lib_dir, os.path.basename(file_name)) + raise ValueError( + "DelphiVCL module not found. Try to reinstall the delphivcl package.") else: - #Win x86 - libdir = "Win32" - - if libdir: - sdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), libdir) - if not os.path.exists(sdir): - raise ValueError("DelphiVCL module not found. Try to reinstall the delphivcl package or check for support compatibility.") - for fname in os.listdir(sdir): - if 'DelphiVCL' in fname: - return os.path.join(sdir, os.path.basename(fname)) - raise ValueError("DelphiVCL module not found. Try to reinstall the delphivcl package.") - else: - raise ValueError("Unsupported platform.") + raise ValueError("Unsupported platform.") + def new_import(): - modulefullpath = findmodule() - loader = importlib.machinery.ExtensionFileLoader("DelphiVCL", modulefullpath) - spec = importlib.util.spec_from_file_location("DelphiVCL", modulefullpath, - loader=loader, submodule_search_locations=None) - ld = loader.create_module(spec) + lib_path = find_extension_module() + loader = importlib.machinery.ExtensionFileLoader("DelphiVCL", lib_path) + spec = importlib.util.spec_from_file_location("DelphiVCL", + lib_path, + loader=loader, + submodule_search_locations=None) + loader.create_module(spec) package = importlib.util.module_from_spec(spec) sys.modules["delphivcl"] = package spec.loader.exec_module(package) return package -#Import the shared lib -package = new_import() \ No newline at end of file + +# Import the extension module +package = new_import() diff --git a/delphivcl/__version__.py b/delphivcl/__version__.py deleted file mode 100644 index 679362c..0000000 --- a/delphivcl/__version__.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "1.0.3" \ No newline at end of file diff --git a/experts/README.md b/experts/README.md deleted file mode 100644 index 912f79a..0000000 --- a/experts/README.md +++ /dev/null @@ -1,3 +0,0 @@ -We have ported the experts to a new repository. Please, have a visit to the link below: - -https://github.com/Embarcadero/Delphi4PythonExporter \ No newline at end of file diff --git a/lib/Win32/DelphiVCL.pyd b/lib/Win32/DelphiVCL.pyd index 02c7112..a11ce2b 100644 Binary files a/lib/Win32/DelphiVCL.pyd and b/lib/Win32/DelphiVCL.pyd differ diff --git a/lib/Win64/DelphiVCL.pyd b/lib/Win64/DelphiVCL.pyd index c0502ad..b239285 100644 Binary files a/lib/Win64/DelphiVCL.pyd and b/lib/Win64/DelphiVCL.pyd differ diff --git a/pyproject.toml b/pyproject.toml index 00e3138..d1cf2ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,27 +1,14 @@ [build-system] -requires = ["setuptools>=40.9.0", "wheel"] - -[tool.cibuildwheel] -build = ["cp36-win*", "cp37-win*", "cp38-win*", "cp39-win*", "cp310-win*"] -skip = "pp*" -#archs = ["auto"] -#repair-wheel-command = "" - -[tool.cibuildwheel.windows] -archs = ["x86", "AMD64"] - -[tool.isort] -profile = "black" -multi_line_output = 3 - -[tool.poetry] -name = "delphivcl" -version = "0.1.18" -description = "" -authors = ["Jim McKeth", "Lucas Belo", "Lucio Montero"] - -[tool.poetry.dependencies] -python = ">=3.6<=3.10" - -[tool.poetry.dev-dependencies] -pytest = "^6.2.5" +requires = [ + "setuptools >= 54", + "setuptools_scm[toml] >= 4, <6", + "setuptools_scm_git_archive", + "wheel >= 0.29.0", +] +build-backend = 'setuptools.build_meta' + +[tool.setuptools_scm] +version_scheme = "post-release" +local_scheme = "no-local-version" +write_to = "delphivcl/__version__.py" +git_describe_command = "git describe --dirty --tags --long --match v* --first-parent" \ No newline at end of file diff --git a/samples/ListView/images/add-16.png b/samples/ListView/images/add-16.png new file mode 100644 index 0000000..8e911a4 Binary files /dev/null and b/samples/ListView/images/add-16.png differ diff --git a/samples/ListView/images/add-32.png b/samples/ListView/images/add-32.png new file mode 100644 index 0000000..932a883 Binary files /dev/null and b/samples/ListView/images/add-32.png differ diff --git a/samples/ListView/images/item-16.png b/samples/ListView/images/item-16.png new file mode 100644 index 0000000..9910fb9 Binary files /dev/null and b/samples/ListView/images/item-16.png differ diff --git a/samples/ListView/images/item-32.png b/samples/ListView/images/item-32.png new file mode 100644 index 0000000..b46decd Binary files /dev/null and b/samples/ListView/images/item-32.png differ diff --git a/samples/ListView/images/remove-16.png b/samples/ListView/images/remove-16.png new file mode 100644 index 0000000..fdbcd35 Binary files /dev/null and b/samples/ListView/images/remove-16.png differ diff --git a/samples/ListView/images/remove-32.png b/samples/ListView/images/remove-32.png new file mode 100644 index 0000000..782e0a5 Binary files /dev/null and b/samples/ListView/images/remove-32.png differ diff --git a/samples/ListView/listview_project.py b/samples/ListView/listview_project.py new file mode 100644 index 0000000..edae771 --- /dev/null +++ b/samples/ListView/listview_project.py @@ -0,0 +1,24 @@ +# --------------------------------------------------------------------------------- +# Name: listview_project.py +# Purpose: DelphiVCL for Python sample +# +# Author: lmbelo, Priyatham +# +# Created: 08/28/2023 +# Copyright: 2020-2023 Embarcadero Technologies, Inc. +# License: https://github.com/Embarcadero/DelphiVCL4Python/blob/main/LICENSE.md +# --------------------------------------------------------------------------------- + +from delphivcl import * +from listview_unit import ListViewForm + +def main(): + Application.Initialize() + Application.Title = 'List View Sample' + MainForm = ListViewForm(Application) + MainForm.Show() + FreeConsole() + Application.Run() + +if __name__ == '__main__': + main() diff --git a/samples/ListView/listview_unit.py b/samples/ListView/listview_unit.py new file mode 100644 index 0000000..e302010 --- /dev/null +++ b/samples/ListView/listview_unit.py @@ -0,0 +1,608 @@ +# --------------------------------------------------------------------------------- +# Name: listview_unit.py +# Purpose: DelphiVCL for Python sample +# +# Author: lmbelo, Priyatham +# +# Created: 08/28/2023 +# Copyright: 2020-2023 Embarcadero Technologies, Inc. +# License: https://github.com/Embarcadero/DelphiVCL4Python/blob/main/LICENSE.md +# --------------------------------------------------------------------------------- + +import os +import io +from PIL import Image as PILImg +from delphivcl import * + +class ListViewForm(Form): + + + def __init__(self, owner): + self.il_images=ImageList(self) + self.il_small_images=ImageList(self) + self.list_view=ListView(self) + self.memo_evts=Memo(self) + self.pnl_actions=Panel(self) + self.pnl_add=Panel(self) + self.btn_remove_all=Button(self) + self.btn_remove_selected=Button(self) + self.pnl_remove=Panel(self) + self.btn_add_many=Button(self) + self.btn_add_single=Button(self) + self.rg_view_style=RadioGroup(self) + self.gb_options=GroupBox(self) + self.pnl_sort_type=Panel(self) + self.lb_sort_type=Label(self) + self.cb_sort_type=ComboBox(self) + self.cb_checkboxes=CheckBox(self) + self.cb_column_click=CheckBox(self) + self.cb_show_work_areas=CheckBox(self) + self.cb_multi_select=CheckBox(self) + self.cb_row_select=CheckBox(self) + + # Basic settings + self.config() + # Fill default data + self.fill_data() + # Fill up image list + self.fill_images() + + + def config(self): + self.SetProps( + Parent=self, + Caption='Form1', + Left = 0, + Top = 0, + Height=700, + Width=1100, + Color=clBtnFace, + TextHeight=15, + Position="poDesktopCenter", + TabOrder=0, + ) + + self.Font.SetProps( + Charset=1,#DEFAULT_CHARSET + Color=clWindowText, + Height=-12, + Name='Segoe UI', + Style=[], + ) + + self.il_images.SetProps( + ColorDepth="cd32Bit", + DrawingStyle="dsTransparent", + Height=32, + Width=32, + ) + + self.il_small_images.SetProps( + ColorDepth="cd32Bit", + DrawingStyle="dsTransparent", + Height=16, + Width=16, + ) + + self.list_view.SetProps( + Parent=self, + Width=743, + Height=416, + Align="alClient", + TabOrder=0, + LargeImages=self.il_images, + SmallImages=self.il_small_images, + # Events + OnAdvancedCustomDraw=self.list_view_advanced_custom_draw, + OnAdvancedCustomDrawItem=self.list_view_advanced_custom_draw_item, + OnAdvancedCustomDrawSubItem=self.list_view_advanced_custom_draw_sub_item, + OnChange=self.list_view_change, + OnChanging=self.list_view_changing, + OnClick=self.list_view_click, + OnColumnClick=self.list_view_column_click, + OnColumnRightClick=self.list_view_column_right_click, + OnCompare=self.list_view_compare, + OnContextPopup=self.list_view_context_popup, + OnCustomDraw=self.list_view_custom_draw, + OnCustomDrawItem=self.list_view_custom_draw_item, + OnCustomDrawSubItem=self.list_view_custom_draw_sub_item, + OnCreateItemClass=self.list_view_create_item_class, + OnData=self.list_view_data, + OnDataFind=self.list_view_data_find, + OnDataHint=self.list_view_data_hint, + OnDataStateChange=self.list_view_data_state_change, + OnDrawItem=self.list_view_draw_item, + OnEdited=self.list_view_edited, + OnEditing=self.list_view_editing, + OnEnter=self.list_view_enter, + OnGetSubItemImage=self.list_view_get_sub_item_image, + OnInfoTip=self.list_view_info_tip, + OnInsert=self.list_view_insert, + OnKeyDown=self.list_view_key_down, + OnSelectItem=self.list_view_select_item, + OnItemChecked=self.list_view_item_checked, + ) + + self.memo_evts.SetProps( + Parent=self, + Width=1083, + Height=152, + Align="alBottom", + TabOrder=1, + ) + + self.pnl_actions.SetProps( + Parent=self, + Width=340, + Height=416, + Align="alRight", + BevelOuter="bvNone", + TabOrder=2, + ) + + self.pnl_add.SetProps( + Parent=self.pnl_actions, + AlignWithMargins=True, + Left = 3, + Top = 3, + Width = 334, + Height = 41, + Align="alTop", + BevelOuter="bvNone", + TabOrder=0, + ) + + self.btn_add_single.SetProps( + Parent=self.pnl_add, + AlignWithMargins=True, + Left = 3, + Top = 3, + Width=160, + Height=35, + Align="alLeft", + Caption='Add Item', + ImageIndex=0, + Images=self.il_images, + TabOrder=1, + OnClick=self.do_add_single_click, + ) + + self.btn_add_single.ImageMargins.SetProps( + Left=20, + ) + + self.btn_add_many.SetProps( + Parent=self.pnl_add, + AlignWithMargins=True, + Left = 169, + Top = 3, + Width=160, + Height=35, + Align="alLeft", + Caption='Add Many Items', + ImageIndex=0, + Images=self.il_images, + TabOrder=0, + OnClick=self.do_add_many_click, + ) + + self.btn_add_many.ImageMargins.SetProps( + Left=20, + ) + + self.pnl_remove.SetProps( + Parent=self.pnl_actions, + AlignWithMargins=True, + Left = 3, + Top = 50, + Width=334, + Height=41, + Align="alTop", + BevelOuter="bvNone", + TabOrder=0, + ) + + self.btn_remove_selected.SetProps( + Parent=self.pnl_remove, + AlignWithMargins=True, + Left = 3, + Top = 3, + Width=160, + Height=35, + Align="alLeft", + Caption='Remove Selected', + ImageIndex=1, + Images=self.il_images, + TabOrder=1, + OnClick=self.do_remove_selected, + ) + + self.btn_remove_selected.ImageMargins.SetProps( + Left=20, + ) + + self.btn_remove_all.SetProps( + Parent=self.pnl_remove, + AlignWithMargins=True, + Left = 169, + Top = 3, + Width=160, + Height=35, + Align="alLeft", + Caption='Remove All', + ImageIndex=1, + Images=self.il_images, + TabOrder=0, + OnClick=self.do_remove_all, + ) + + self.btn_remove_all.ImageMargins.SetProps( + Left=20, + ) + + self.rg_view_style.SetProps( + Parent=self.pnl_actions, + AlignWithMargins=True, + Left = 3, + Top = 97, + Width=334, + Height=105, + Align="alTop", + Caption='View Stytle', + Columns=2, + TabOrder=2, + OnClick=self.do_rg_view_style_click + ) + + self.gb_options.SetProps( + Parent=self.pnl_actions, + AlignWithMargins=True, + Left = 3, + Top = 208, + Width=334, + Height=240, + Align="alTop", + Caption='Options', + TabOrder=3, + ) + + self.pnl_sort_type.SetProps( + Parent=self.gb_options, + Left=2, + Top=17, + Width=330, + Height=50, + Align="alTop", + BevelOuter="bvNone", + TabOrder=5, + ) + + self.lb_sort_type.SetProps( + Parent=self.pnl_sort_type, + AlignWithMargins=True, + Left=3, + Top=3, + Width=324, + Height=15, + Align="alTop", + Caption='Sort Type', + ) + + self.cb_sort_type.SetProps( + Parent=self.pnl_sort_type, + AlignWithMargins=True, + Left=3, + Top=24, + Width=324, + Height=23, + Align="alTop", + TabOrder=0, + OnChange=self.do_sort_type_change + ) + + self.cb_checkboxes.SetProps( + Parent=self.gb_options, + AlignWithMargins=True, + Left=5, + Top=70, + Width=324, + Height=17, + Align="alTop", + Caption='Checkboxes', + TabOrder=0, + OnClick=self.do_cb_checkboxes, + ) + + self.cb_column_click.SetProps( + Parent=self.gb_options, + AlignWithMargins=True, + Left=5, + Top=93, + Width=324, + Height=17, + Align="alTop", + Caption='Column Click', + TabOrder=1, + OnClick=self.do_cb_column_click, + ) + + self.cb_show_work_areas.SetProps( + Parent=self.gb_options, + AlignWithMargins=True, + Left=5, + Top=162, + Width=324, + Height=17, + Align="alTop", + Caption='Show Work Areas', + TabOrder=2, + OnClick=self.do_cb_show_work_areas, + ) + + self.cb_multi_select.SetProps( + Parent=self.gb_options, + AlignWithMargins=True, + Left=5, + Top=116, + Width=324, + Height=17, + Align="alTop", + Caption='Multiselect', + TabOrder=3, + OnClick=self.do_cb_multi_select, + ) + + self.cb_row_select.SetProps( + Parent=self.gb_options, + AlignWithMargins=True, + Left=5, + Top=139, + Width=324, + Height=17, + Align="alTop", + Caption='Row Select', + TabOrder=4, + OnClick=self.do_cb_row_select, + ) + + + def fill_data(self): + # ListView Columns + # Column 1 + col = self.list_view.Columns.Add() + col.Caption = "First Column" + col.Width = 100 + # Column 2 + col = self.list_view.Columns.Add() + col.Caption = "Second Column" + col.Width = 150 + # Column 3 + col = self.list_view.Columns.Add() + col.Caption = "Third Column" + col.Width = 150 + + # ListView View Styles + self.rg_view_style.Items.Add("vsIcon") + self.rg_view_style.Items.Add("vsList") + self.rg_view_style.Items.Add("vsReport") + self.rg_view_style.Items.Add("vsSmallIcon") + self.rg_view_style.ItemIndex = 0 + + # ListView Sort Type + self.cb_sort_type.Items.Add("stBoth") + self.cb_sort_type.Items.Add("stData") + self.cb_sort_type.Items.Add("stNone") + self.cb_sort_type.Items.Add("stText") + self.cb_sort_type.ItemIndex = 2 + + + def png_to_bmp(self, file_path): + img = PILImg.open(file_path, mode='r') + img_byte_arr = io.BytesIO() + img.save(img_byte_arr, format='BMP') + byte_arr = img_byte_arr.getvalue() + + return BytesStream(byte_arr) + + + def add_image(self, file_path, image_list): + img_stream = self.png_to_bmp(file_path) + try: + bm = Bitmap(image_list.Height, image_list.Width) + try: + bm.LoadFromStream(img_stream) + # Add the image to the image container + image_list.AddMasked(bm, clNone) + finally: + bm.Free() + finally: + img_stream.Free() + + + def fill_images(self): + base_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "images") + # 32x32 images + self.add_image(os.path.join(base_path, "add-32.png"), self.il_images) + self.add_image(os.path.join(base_path, "remove-32.png"), self.il_images) + self.add_image(os.path.join(base_path, "item-32.png"), self.il_images) + # 16x16 images + self.add_image(os.path.join(base_path, "add-16.png"), self.il_small_images) + self.add_image(os.path.join(base_path, "remove-16.png"), self.il_small_images) + self.add_image(os.path.join(base_path, "item-16.png"), self.il_small_images) + + + def add_item(self): + item = self.list_view.Items.Add() + item.Caption = 'Item ' + str(self.list_view.Items.Count) + item.SubItems.Add(item.Caption + ' Subitem 1') + item.SubItems.Add(item.Caption + ' Subitem 2') + item.ImageIndex=2 + + + def do_add_single_click(self, sender): + self.add_item() + + + def do_add_many_click(self, sender): + for i in range(10): + self.add_item() + + + def do_remove_selected(self, sender): + self.list_view.DeleteSelected() + + + def do_remove_all(self, sender): + self.list_view.Items.Clear() + + + def do_rg_view_style_click(self, sender): + match self.rg_view_style.ItemIndex: + case 0: + self.list_view.ViewStyle = "vsIcon" + case 1: + self.list_view.ViewStyle = "vsList" + case 2: + self.list_view.ViewStyle = "vsReport" + case 3: + self.list_view.ViewStyle = "vsSmallIcon" + + + def do_sort_type_change(self, sender): + self.list_view.SortType = self.cb_sort_type.Text + + + def do_cb_checkboxes(self, sender): + self.list_view.CheckBoxes = self.cb_checkboxes.Checked + + + def do_cb_column_click(self, sender): + self.list_view.ColumnClick = self.cb_column_click.Checked + + + def do_cb_show_work_areas(self, sender): + self.list_view.ShowWorkAreas = self.cb_show_work_areas.Checked + + + def do_cb_multi_select(self, sender): + self.list_view.Multiselect = self.cb_multi_select.Checked + + + def do_cb_row_select(self, sender): + self.list_view.RowSelect = self.cb_row_select.Checked + + + def log_evt(self, log): + self.memo_evts.Lines.Add(log) + + + def list_view_advanced_custom_draw(self, Sender, ARect, Stage, DefaultDraw): + self.log_evt("list_view_advanced_custom_draw(self, Sender, ARect, Stage, var DefaultDraw)") + + + def list_view_advanced_custom_draw_item(self, Sender, Item, State, Stage, DefaultDraw): + self.log_evt("list_view_advanced_custom_draw_item(self, Sender, Item, State, Stage, var DefaultDraw)") + + + def list_view_advanced_custom_draw_sub_item(self, Sender, Item, SubItem, State, Stage, DefaultDraw): + self.log_evt("list_view_advanced_custom_draw_sub_item(self, Sender, Item, SubItem, State, Stage, var DefaultDraw)") + + + def list_view_change(self, Sender, Item, Change): + self.log_evt("list_view_change(self, Sender, Item, Change)") + + + def list_view_changing(self, Sender, Item, Change, AllowChange): + self.log_evt("list_view_changing(self, Sender, Item, Change, var AllowChange)") + + + def list_view_click(self, Sender): + self.log_evt("list_view_click(self, Sender)") + + + def list_view_column_click(self, Sender, Column): + self.log_evt("list_view_column_click(self, Sender, Column)") + + + def list_view_column_right_click(self, Sender, Column, Point): + self.log_evt("list_view_column_right_click(self, Sender, Column, Point)") + + + def list_view_compare(self, Sender, Item1, Item2, Data, Compare): + self.log_evt("list_view_compare(self, Sender, Item1, Item2, Data, Compare)") + + + def list_view_context_popup(self, Sender, MousePos, Handled): + self.log_evt("list_view_context_popup(self, Sender, MousePos, var Handled)") + + + def list_view_custom_draw(self, Sender, ARect, DefaultDraw): + self.log_evt("list_view_custom_draw(self, Sender, ARect, var DefaultDraw)") + + + def list_view_custom_draw_item(self, Sender, Item, State, DefaultDraw): + self.log_evt("list_view_custom_draw_item(self, Sender, Item, State, var DefaultDraw)") + + + def list_view_custom_draw_sub_item(self, Sender, Item, SubItem, State, DefaultDraw): + self.log_evt("list_view_custom_draw_sub_item(self, Sender, Item, SubItem, State, var DefaultDraw)") + + + def list_view_create_item_class(self, Sender, ItemClass): + self.log_evt("list_view_create_item_class(self, Sender, var ItemClass)") + + + def list_view_data(self, Sender, Item): + self.log_evt("list_view_data(self, Sender, Item)") + + + def list_view_data_find(self, Sender, Find, FindString, FindPosition, FindData, StartIndex, Direction, Wrap, Index): + self.log_evt("list_view_data_find(self, Sender, Find, FindString, FindPosition, FindData, StartIndex, Direction, Wrap, Index)") + + + def list_view_data_hint(self, Sender, StartIndex, EndIndex): + self.log_evt("list_view_data_hint(self, Sender, StartIndex, EndIndex)") + + + def list_view_data_state_change(self, Sender, StartIndex, EndIndex, OldState, NewState): + self.log_evt("list_view_data_state_change(self, Sender, StartIndex, EndIndex, OldState, NewState)") + + + def list_view_draw_item(self, Sender, Item, Rect, State): + self.log_evt("list_view_draw_item(self, Sender, Item, Rect, State)") + + + def list_view_edited(self, Sender, Item, S): + self.log_evt("list_view_edited(self, Sender, Item, var S)") + + + def list_view_editing(self, Sender, Item, AllowEdit): + self.log_evt("list_view_editing(self, Sender, Item, var AllowEdit)") + + + def list_view_enter(self, Sender): + self.log_evt("list_view_enter(self, Sender)") + + + def list_view_get_sub_item_image(self, Sender, Item, SubItem, ImageIndex): + self.log_evt("list_view_get_sub_item_image(self, Sender, Item, SubItem, var ImageIndex)") + + + def list_view_info_tip(self, Sender, Item, InfoTip): + self.log_evt("list_view_info_tip(self, Sender, Item, var InfoTip)") + + + def list_view_insert(self, Sender, Item): + self.log_evt("list_view_insert(self, Sender, Item)") + + + def list_view_key_down(self, Sender, Key, Shift): + self.log_evt("list_view_key_down(self, Sender, Key, Shift)") + + + def list_view_select_item(self, Sender, Item, Selected): + self.log_evt("list_view_select_item(self, Sender, Item, Selected)") + + + def list_view_item_checked(self, Sender, Item): + self.log_evt("list_view_item_checked(self, Sender, Item)") \ No newline at end of file diff --git a/samples/TreeView/treeview_sample.py b/samples/TreeView/treeview_sample.py new file mode 100644 index 0000000..e5e0d63 --- /dev/null +++ b/samples/TreeView/treeview_sample.py @@ -0,0 +1,367 @@ +# --------------------------------------------------------------------------------- +# Name: treeview_sample.py +# Purpose: DelphiVCL for Python sample +# +# Author: lmbelo, Priyatham +# +# Created: 28/08/2023 +# Copyright: 2020-2023 Embarcadero Technologies, Inc. +# License: https://github.com/Embarcadero/DelphiVCL4Python/blob/main/LICENSE.md +# --------------------------------------------------------------------------------- + +from delphivcl import * + +class TreeViewSample(Form): + + + def __init__(self, owner): + self.tree_view = TreeView(self) + self.panel = Panel(self) + self.memo = Memo(self) + + self.tg_checkboxes = CheckBox(self.panel) + self.check_styles_groupbox = GroupBox(self.panel) + self.check_styles_cs_partial = CheckBox(self.check_styles_groupbox) + self.check_styles_cs_dimmed = CheckBox(self.check_styles_groupbox) + self.check_styles_cs_excluded = CheckBox(self.check_styles_groupbox) + self.tg_multi_select = CheckBox(self.panel) + self.tg_show_buttons = CheckBox(self.panel) + self.multi_select_groupbox = GroupBox(self.panel) + self.multi_select_ms_control_select = CheckBox(self.multi_select_groupbox) + self.multi_select_ms_shift_select = CheckBox(self.multi_select_groupbox) + self.multi_select_ms_visible_only = CheckBox(self.multi_select_groupbox) + self.multi_select_ms_sibling_only = CheckBox(self.multi_select_groupbox) + self.tg_show_lines = CheckBox(self.panel) + self.tg_tv_visibility = CheckBox(self.panel) + + self.config() + + root_node = self.tree_view.Items.Add(None, "TreeView") + root_node_child1 = self.tree_view.Items.AddChild(root_node, "Lucas") + root_node_child2 = self.tree_view.Items.AddChild(root_node, "Priyatham") + root_node.Expand(True) + + + def log_event(self, log): + self.memo.lines.Add("Event: "+log) + + + def config(self): + self.SetProps( + Width = 850, + Height = 700 + ) + + self.tree_view.SetProps( + Parent = self, + Width = 605, + Height = 520, + Align = "alClient", + # CheckBoxes = True, + #events + OnAddition = self.do_addition, + OnAdvancedCustomDraw = self.do_advanced_custom_draw, + OnAdvancedCustomDrawItem = self.do_advanced_custom_draw_item, + OnCancelEdit = self.do_cancel_edit, + OnChange = self.do_change, + OnChanging = self.do_changing, + OnCheckStateChanged = self.do_check_state_changed, + OnCheckStateChanging = self.do_check_state_changing, + OnClick = self.do_click, + OnCollapsed = self.do_collapsed, + OnCollapsing = self.do_collapsing, + OnCompare = self.do_compare, + OnContextPopup = self.do_context_popup, + OnCreateNodeClass = self.do_create_node_class, + OnCustomDraw = self.do_custom_draw, + OnCustomDrawItem = self.do_custom_draw_item, + OnEdited = self.do_edited, + OnEditing = self.do_editing, + OnExpanding = self.do_expanding, + OnExpanded = self.do_expanded, + OnHint = self.do_hint + ) + + self.panel.SetProps( + Parent = self, + Width = 240, + Height = 520, + Align = "alRight" + ) + + self.memo.SetProps( + Parent = self, + Width = 850, + Height = 140, + Align = "alBottom" + ) + + self.tg_checkboxes.SetProps( + Parent = self.panel, + Caption = "Toggle checkboxes", + Left = 14, + Top = 48, + Width = 230, + OnClick = self.do_tg_checkboxes_click + ) + + self.check_styles_groupbox.SetProps( + Parent = self.panel, + Caption = "CheckStyles", + Left = 6, + Top = 98, + Height = 90, + Width = 180 + ) + + self.check_styles_cs_partial.SetProps( + Parent = self.check_styles_groupbox, + Caption = "csPartial", + Align = "alTop", + AlignWithMargins = True, + OnClick = self.do_check_styles_change + ) + + self.check_styles_cs_dimmed.SetProps( + Parent = self.check_styles_groupbox, + Caption = "csDimmed", + Align = "alTop", + AlignWithMargins = True, + OnClick = self.do_check_styles_change + ) + + self.check_styles_cs_excluded.SetProps( + Parent = self.check_styles_groupbox, + Caption = "csExclusion", + Align = "alTop", + AlignWithMargins = True, + OnClick = self.do_check_styles_change + ) + + self.tg_multi_select.SetProps( + Parent = self.panel, + Caption = "Toggle MultiSelect", + Top = 208, + Left = 14, + Width = 160, + OnClick = self.do_tg_multi_select_click + ) + + self.tg_show_buttons.SetProps( + Parent = self.panel, + Caption = "Toggle Show Buttons", + Left = 14, + Top = 240, + Width = 170, + OnClick = self.do_tg_show_buttons_click + ) + + self.multi_select_groupbox.SetProps( + Parent = self.panel, + Caption = "MultiSelectStyle", + Left = 6, + Top = 288, + Width = 180, + Height = 124 + ) + + self.multi_select_ms_control_select.SetProps( + Parent = self.multi_select_groupbox, + Caption = "msControlSelect", + Align = "alTop", + AlignWithMargins = True, + OnClick = self.do_multi_select_style_change + ) + + self.multi_select_ms_shift_select.SetProps( + Parent = self.multi_select_groupbox, + Caption = "msShiftSelect", + Align = "alTop", + AlignWithMargins = True, + OnClick = self.do_multi_select_style_change + ) + + self.multi_select_ms_visible_only.SetProps( + Parent = self.multi_select_groupbox, + Caption = "msVisibleOnly", + Align = "alTop", + AlignWithMargins = True, + OnClick = self.do_multi_select_style_change + ) + + self.multi_select_ms_sibling_only.SetProps( + Parent = self.multi_select_groupbox, + Caption = "msSiblingOnly", + Align = "alTop", + AlignWithMargins = True, + OnClick = self.do_multi_select_style_change + ) + + self.tg_show_lines.SetProps( + Parent = self.panel, + Caption = "Toggle Show Lines", + Left = 6, + Top = 425, + Width = 195, + OnClick = self.do_tg_show_lines_click + ) + + self.tg_tv_visibility.SetProps( + Parent = self.panel, + Caption = "Toggle TreeView Visibility", + Left = 6, + Top = 456, + Width = 195, + OnClick = self.do_tg_tv_visibility_click + ) + + + def do_tg_checkboxes_click(self, Sender): + if not self.tree_view.CheckBoxes: + self.tree_view.CheckBoxes = True + else: + self.tree_view.CheckBoxes = False + + + def do_check_styles_change(self, Sender): + check_styles = self.tree_view.CheckStyles + if Sender.Caption in self.tree_view.CheckStyles: + check_styles.remove(Sender.Caption) + else: + check_styles.append(Sender.Caption) + self.tree_view.CheckStyles = check_styles + + + def do_tg_multi_select_click(self, Sender): + if not self.tree_view.MultiSelect: + self.tree_view.MultiSelect = True + else: + self.tree_view.MultiSelect = False + + + def do_tg_show_buttons_click(self, Sender): + if not self.tree_view.ShowButtons: + self.tree_view.ShowButtons = True + else: + self.tree_view.ShowButtons = False + + + def do_multi_select_style_change(self, Sender): + multiselect_style = self.tree_view.MultiSelectStyle + if Sender.Caption in self.tree_view.MultiSelectStyle: + multiselect_style.remove(Sender.Caption) + else: + multiselect_style.append(Sender.Caption) + self.tree_view.MultiSelectStyle = multiselect_style + + + def do_tg_show_lines_click(self, Sender): + if not self.tree_view.ShowLines: + self.tree_view.ShowLines = True + else: + self.tree_view.ShowLines = False + + + def do_tg_tv_visibility_click(self, Sender): + if not self.tree_view.Visible: + self.tree_view.Visible = True + else: + self.tree_view.Visible = False + + + def do_addition(self, Sender, Node): + self.log_event("OnAdittion(Sender, Node))") + + + def do_advanced_custom_draw(self, Sender, ARect, Stage, DefaultDraw): + self.log_event("OnAdvancedCustomDraw(Sender, ARect, Stage, var DefaultDraw)") + + + def do_advanced_custom_draw_item(self, Sender, Node, State, Stage, PaintImages, DefaultDraw): + self.log_event("OnAdvancedCustomDrawItem(Sender, Node, State, Stage, var PaintImages, var DefaultDraw)") + + + def do_cancel_edit(self, Sender, Node): + self.log_event("OnCancelEdit(Sender, Node))") + + + def do_change(self, Sender, Node): + self.log_event("OnChange(Sender, Node))") + + + def do_changing(self, Sender, Node, AllowChange): + self.log_event("OnChanging(Sender, Node, var AllowChange))") + + + def do_check_state_changed(self, Sender, Node, CheckState): + self.log_event("OnCheckStateChanged(Sender, Node, CheckState))") + + + def do_check_state_changing(self, Sender, Node, NewCheckState, OldCheckState, AllowChange): + self.log_event("OnCheckStateChanging(Sender, Node, NewCheckState, OldCheckState, var AllowChange))") + + + def do_click(self, Sender): + self.log_event("OnClick(Sender)") + + + def do_collapsed(self, Sender, Node): + self.log_event("OnCollapsed(Sender, Node)") + + + def do_collapsing(self, Sender, Node, AllowCollapse): + self.log_event("OnCollapsing(Sender, Node, var AllowCollapse)") + + + def do_compare(self, Sender, Node1, Node2, Data, Compare): + self.log_event("OnCompare(Sender, Node1, Node2, Data, Compare)") + + + def do_context_popup(self, Sender, MousePos, Handled): + self.log_event("OnContextPopup(Sender, MousePos, var Handled)") + + + def do_create_node_class(self, Sender, NodeClass): + self.log_event("OnCreateNodeClass(Sender, var NodeClass)") + + + def do_custom_draw(self, Sender, ARect, DefaultDraw): + self.log_event("OnCustomDraw(Sender, ARect, var DefaultDraw)") + + + def do_custom_draw_item(self, Sender, Node, State, DefaultDraw): + self.log_event("OnCustomDrawItem(Sender, Node, State, var DefaultDraw)") + + + def do_edited(self, Sender, Node, S): + self.log_event("OnEdited(Sender, Node, var S)") + + + def do_editing(self, Sender, Node, AllowEdit): + self.log_event("OnEditing(Sender, Node, var AllowEdit)") + + + def do_expanding(self, Sender, Node, AllowExpansion): + self.log_event("OnExpanding(Sender, Node, var AllowExpansion)") + + + def do_expanded(self, Sender, Node): + self.log_event("OnExpanded(Sender, Node)") + + + def do_hint(self, Sender, Node, Hint): + self.log_event("OnHint(Sender, Node, var Hint)") + + +def main(): + Application.Initialize() + Application.Title = "TreeView Sample" + MainForm = TreeViewSample(Application) + MainForm.Show() + FreeConsole() + Application.Run() + MainForm.Destroy() + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..baf740e --- /dev/null +++ b/setup.cfg @@ -0,0 +1,54 @@ +[egg_info] +tag_build = +tag_date = 0 +tag_svn_revision = 0 + +[bdist_wheel] +universal = 0 + +[build_sphinx] +source-dir = docs/source +build-dir = _build +all-files = True + +[metadata] +name = delphivcl +version = 1.0.5 +description = Delphi VCL for Python +long_description = file: README.md +long_description_content_type = text/markdown; charset=UTF-8 +url = https://github.com/Embarcadero/DelphiVCL4Python +author = Lucas Belo, Jim McKeeth +author_email = lucas.belo@live.com +license = BSD +license_files = ['LICENSE.md'] +classifiers = + Intended Audience :: Developers + Topic :: Software Development + License :: Other/Proprietary License + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3 :: Only + Operating System :: Microsoft :: Windows +project_urls = + Documentation = https://embarcadero.github.io/DelphiVCL4Python + Source = https://github.com/Embarcadero/DelphiVCL4Python + Tracker = https://github.com/Embarcadero/DelphiVCL4Python/issues + +[options] +zip_safe = False +packages = find: +platforms = any +include_package_data = True +install_requires = +python_requires = >=3 +setup_requires = + setuptools_scm +cmdclass = + bdist_wheel = build.BDistWheel \ No newline at end of file diff --git a/setup.py b/setup.py index 1bd5d78..578f955 100644 --- a/setup.py +++ b/setup.py @@ -1,105 +1,10 @@ -import setuptools, os, sys, platform, distutils.dir_util -from pathlib import Path +import setuptools +import build -pkgname = "delphivcl" -#Force platform wheel -try: - from wheel.bdist_wheel import bdist_wheel as _bdist_wheel - class bdist_wheel(_bdist_wheel): - def finalize_options(self): - _bdist_wheel.finalize_options(self) - self.root_is_pure = ("--universal" in sys.argv) -except ImportError: - bdist_wheel = None +def main(): + build.setup() + setuptools.setup() -def get_release_version(): - lcals = locals() - gbals = globals() - with open(os.path.join(os.getcwd(), pkgname, "__version__.py"), "rt") as opf: - opffilecontents = opf.read() - retvalue = exec(opffilecontents, gbals, lcals) - versorigstr = lcals["__version__"] - return versorigstr - -pkg_dir = os.path.join(os.curdir, pkgname) -if ("sdist" in sys.argv) or (("bdist_wheel" in sys.argv) and ("--universal" in sys.argv)): - #sdist deploys all shared libraries - distutils.dir_util.copy_tree("lib", pkg_dir) -else: - #Deploy the current platform shared library only - ossys = platform.system() - platmac = platform.machine() - libdir = None - if ossys == "Windows": - if (sys.maxsize > 2**32): - #Win x64 - libdir = "Win64" - else: - #Win x86 - libdir = "Win32" - - if libdir: - distutils.dir_util.copy_tree(os.path.join("lib", libdir), os.path.join(pkg_dir, libdir)) - else: - raise ValueError("Unsupported platform.") - -#Copy the doc files to the package folder into the doc subfolder -if os.path.exists(os.path.join("docs", "xml", "docs.xml")): - pkg_doc_dir = os.path.join(pkg_dir, "doc") - if not os.path.exists(pkg_doc_dir): - os.mkdir(pkg_doc_dir) - distutils.file_util.copy_file(os.path.join("docs", "xml", "docs.xml"), os.path.join(pkg_doc_dir, "docs.xml")) - -#Create the package data. -pkgdata = [] -for dir_, _, files in os.walk(pkg_dir): - for file_name in files: - rel_dir = os.path.relpath(dir_, pkg_dir) - rel_file = os.path.join(rel_dir, file_name) - #Add the shared library. - if ''.join(Path(rel_file).suffixes) in ['.pyd', '.tds']: - pkgdata.append(rel_file) - #Add the doc xml file - elif (rel_file.endswith('.xml')): - pkgdata.append(rel_file) - -#Read the current version from __version.py__ -versnewstr = get_release_version() - -with open("README.md", "r") as fh: - long_description = fh.read() - -setuptools.setup( - name=pkgname, - version=versnewstr, - description="Delphi VCL for Python", - author="Lucas Belo, Jim McKeeth", - author_email="lucas.belo@live.com", - long_description=long_description, - long_description_content_type="text/markdown", - license="Other/Proprietary License", - license_files=["LICENSE.md"], - url="https://github.com/Embarcadero/DelphiVCL4Python", - python_requires=">=3.6", - packages=[pkgname], - package_data={pkgname: pkgdata}, - classifiers=[ - 'Intended Audience :: Developers', - 'Topic :: Software Development', - 'License :: Other/Proprietary License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3 :: Only', - 'Operating System :: Microsoft :: Windows', - ], - cmdclass={ - 'bdist_wheel': bdist_wheel - } -) +if __name__ == "__main__": + main() diff --git a/tests/___init__.py b/tests/___init__.py deleted file mode 100644 index 521ad4f..0000000 --- a/tests/___init__.py +++ /dev/null @@ -1,6 +0,0 @@ -import importlib.machinery, importlib.util -def new_import(ext_file): - loader = importlib.machinery.ExtensionFileLoader("DelphiVCL", ext_file) - spec = importlib.util.spec_from_file_location("DelphiVCL", ext_file, - loader=loader, submodule_search_locations=None) - #print("spec", spec, spec.loader, modulefullpath, __file__) diff --git a/tests/__main__.py b/tests/__main__.py deleted file mode 100644 index 4077dbf..0000000 --- a/tests/__main__.py +++ /dev/null @@ -1 +0,0 @@ -from delphivcl import * \ No newline at end of file diff --git a/tests/test_import.py b/tests/test_import.py deleted file mode 100644 index 57ba20d..0000000 --- a/tests/test_import.py +++ /dev/null @@ -1,24 +0,0 @@ -import importlib.machinery, importlib.util -import sys - -#from ..delphivcl import * -#from . import new_import -def new_import(ext_file=None): - if ext_file is None: - ext_file = r"C:\Users\lucio\anaconda3\envs\DelphiVCL_assessment\lib\site-packages\delphivcl\DelphiVCL.pyd" - loader = importlib.machinery.ExtensionFileLoader("DelphiVCL", ext_file) - spec = importlib.util.spec_from_file_location("DelphiVCL", ext_file, - loader=loader, submodule_search_locations=None) - #ld = loader.create_module(spec) - package = importlib.util.module_from_spec(spec) - assert "delphivcl" in sys.modules, sys.modules.keys() - return - return package - return ld - -def test_import(): - ld = new_import(r"C:\Users\lucio\PycharmProjects\DelphiVCL_assessment\DelphiVCL4Python\lib\DelphiVCL_Win64_38\DelphiVCL.pyd") - assert 0, ld - -if __name__ == "__main__": - test_import() \ No newline at end of file