I'm trying to help the owner of tkdnd generate a wheel and distribute it to Pypi so users could simply install the tkdnd extension with a simple pip install TkinterDnD2
.
I'm after this 'challange' for the last two days but could not solve it by myself so far, but I'm sure someone with a deep understanding python packaging and installing process could help as solve it in short time.
currently in order to get this extension work you need to do the following steps(as mentioned here):
- download the compiled tkdnd files for your os. now go to your base interpreter directory/tcl and copy this folder under. for example:
--<python3.9-directory>
--tcl
--tkdnd2.9.2
...
...
notice - it did not work for me if I created a matching tcl/tkdnd2.9.2 directory in the venv of the project the imported TkinterDnD2
- now download the python wrapper and add it you your venv site-packages directory(or base interpreter it's doesn't matter). so the python project which will import TkinterDnD2 will look like this:
--<python-test-project>
--venv
--Lib
--site-packages
--TkinterDnD2
...
...
now one could successfully run tkdnd extensions.
you can probably tell this is not much like installing the average python library. the problematic thing here is that the extra tkdnd2.9.2 folder is required to be in the tcl folder of your base interpreter.
maybe it is possible to use the package_data
and data_files
in the setup.py to tell python to add this tcl files during the installation from the wheel, but I'm not sure. see Packaging and distributing projects
for full reference.
the incomplete setup.py:
import setuptools
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setuptools.setup(
name="TkinterDnD2",
version="2.9.2",
author="petasis",
description="TkDND is an extension that adds native drag & drop capabilities to the Tk toolkit.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/petasis/tkdnd",
project_urls={
"Bug Tracker": "https://github.com/petasis/tkdnd/issues",
},
classifiers=[
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
packages=setuptools.find_packages(),
python_requires=">=2, >=3",
# some extra logic probably belong here
# ...
)
you can track the issue here which includes some extra discussions.
very helpful stackoverflow questions:
- How to avoid building C library with my python package?
- How to Install and Use TkDnD with Python Tkinter on OSX?
very helpful guides:
- Packaging and distributing projects
- Packaging Python Projects
- Python Bindings: Calling C or C++ From Python
any help would be very appreciated!
TCLLIBPATH
orauto_path
. (Tkdnd seems to have a non-trivial package index file…) – Glenoid