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?

7
  • check this and never forget "The application will not react like DLL", need be shared and registered otherwise will not work or work a partition ! Commented Oct 3, 2017 at 10:46
  • Thank you, I read it but didn't really understand how passing com objects across threads relates to this scenario Commented Oct 3, 2017 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) Commented Oct 3, 2017 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. Commented Oct 3, 2017 at 11:11
  • 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. Commented Oct 4, 2017 at 8:41

1 Answer 1

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,
    },

    ...
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.