4

I'm building a python package which requires pywin32.

Adding pywin32 as a dependency doesn't work seamlessly, since it has a postinstall script which the user must run themselves.

Adding pypiwin32 as a dependency doesn't work because my package won't play nice with other packages which do require pywin32

I tried requiring both, but it turns out pywin32 and pypiwin32 can't coexist on the same python installation

Is there a way of specifying either pywin32 or pypiwin32 as a dependency? Or some other solution?

Alon
  • 743
  • 10
  • 23
  • [check this](https://stackoverflow.com/questions/26764978/using-win32com-with-multithreading) and never forget "The application will not react like DLL", need be `shared` and `registered` otherwise will not work or work a partition ! – dsgdfg Oct 03 '17 at 10:46
  • Thank you, I read it but didn't really understand how passing com objects across threads relates to this scenario – Alon Oct 03 '17 at 10:51
  • `Adding pywin32 as a dependency` resource access will not work ! You can't add your dependencies as `system required/registered` module. Got 2 way : 1-use a `dll` as module,2- Use minimal-common libraries(not full library) – dsgdfg Oct 03 '17 at 11:01
  • You can used method on the link If you are the manager of all computers. I fixed this problem with "Compiled execute for every machine", different machines different errors ! Waste a lot time. Maybe not good idea but "install python+pythonwin to every machine" your application(.exe) will be work without any error. – dsgdfg Oct 03 '17 at 11:11
  • _pywin32_ and _pypiwin32_ is one and the same package, only the shipping form differs. – CristiFati Oct 04 '17 at 08:30
  • @CristiFati I am aware, but they are registered as different packages, meaning a package with pywin32 in its dependencies won't accept pypiwin32 – Alon Oct 04 '17 at 08:32
  • 1
    _pywin32_ comes as an executable, while _pypiwin32_ (is the newer form that) comes as a _.whl_ (which can be a dependency for other packages). How can a package have a _pywin32_ as a dependency (since it doesn't exist)? Something doesn't seem to be right here. – CristiFati Oct 04 '17 at 08:41

1 Answers1

1

The adding pip install pywin32 as a post-install script works, but removes the install_requires command from setup. To fix this, add do_egg_install(self) rather than run in the classes

from setuptools import setup
from setuptools.command.develop import develop as _develop
from setuptools.command.install import install as _install
from subprocess import check_call

# PostDevelopCommand
class develop(_develop):
    """Post-installation for development mode."""
    def run(self):
        check_call("pip install pywin32")
        develop.do_egg_install(self)

# PostInstallCommand
class install(_install):
    """Post-installation for installation mode."""
    def run(self):
        check_call("pip install pywin32")
        develop.do_egg_install(self)

and insert cmdclass argument to setup() function in setup.py:

 setup(
     ...

    cmdclass={
        'develop': develop,
        'install': install,
    },

    ...
)