0

I am trying to install a python package using pip install . by entering into the directory.

setup.py

import subprocess
from setuptools import setup, Extension, find_packages

subprocess.call(['./script.sh'], shell=True)

print("Executed subprocess")
setup(
        name='Test Package',
        version='0.0.1',
        description='test',
        author='test user',
        author_email='test@test.com',
        url='https://test.com/test',
        packages=find_packages(),
        )

In the setup.py, a bash shell script 'script.sh' is executing

script.sh

echo "hello world"
echo "hi"

When I try to install the package, pip install . , installation is successful but I am not getting messages "hello world", "hi" and "Executed subprocess" in the terminal. How is it possible to bring the output to the terminal while I install the package.

imhans4305
  • 677
  • 1
  • 16
  • The `shell=True` is a mistake here, you are telling Python to use a shell to _launch_ the command; it is not related to the fact that the command is a shell script (the system already knows to use a shell to run shell scripts; you are ending up with two shell instances). See also [Actual meaning of `shell=True` in subprocess](https://stackoverflow.com/questions/3172470/actual-meaning-of-shell-true-in-subprocess) – tripleee Apr 29 '22 at 08:13
  • I don't think there is any way to guarantee that `pip` runs in a context where you can display output to an invoking user. What are you actually hoping to accomplish here? – tripleee Apr 29 '22 at 08:14

0 Answers0