Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup.py build fails without PATH #6934

Closed
mtelka opened this issue Feb 9, 2023 · 4 comments · Fixed by #6935
Closed

setup.py build fails without PATH #6934

mtelka opened this issue Feb 9, 2023 · 4 comments · Fixed by #6935
Labels

Comments

@mtelka
Copy link
Contributor

mtelka commented Feb 9, 2023

What did you do?

$ env - python3.9 setup.py build

What did you expect to happen?

The build succeeds.

What actually happened?

$ env - python3.9 setup.py build
... (skipped many lines) ...
writing manifest file 'src/Pillow.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
  File "$(BUILD_DIR)/setup.py", line 993, in <module>
    setup(
  File "/usr/lib/python3.9/vendor-packages/setuptools/__init__.py", line 108, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.9/vendor-packages/setuptools/_distutils/core.py", line 185, in setup
    return run_commands(dist)
  File "/usr/lib/python3.9/vendor-packages/setuptools/_distutils/core.py", line 201, in run_commands
    dist.run_commands()
  File "/usr/lib/python3.9/vendor-packages/setuptools/_distutils/dist.py", line 969, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.9/vendor-packages/setuptools/dist.py", line 1213, in run_command
    super().run_command(command)
  File "/usr/lib/python3.9/vendor-packages/setuptools/_distutils/dist.py", line 988, in run_command
    cmd_obj.run()
  File "/usr/lib/python3.9/vendor-packages/setuptools/_distutils/command/build.py", line 132, in run
    self.run_command(cmd_name)
  File "/usr/lib/python3.9/vendor-packages/setuptools/_distutils/cmd.py", line 318, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.9/vendor-packages/setuptools/dist.py", line 1213, in run_command
    super().run_command(command)
  File "/usr/lib/python3.9/vendor-packages/setuptools/_distutils/dist.py", line 988, in run_command
    cmd_obj.run()
  File "/usr/lib/python3.9/vendor-packages/setuptools/command/build_ext.py", line 84, in run
    _build_ext.run(self)
  File "/usr/lib/python3.9/vendor-packages/Cython/Distutils/old_build_ext.py", line 186, in run
    _build_ext.build_ext.run(self)
  File "/usr/lib/python3.9/vendor-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
    self.build_extensions()
  File "$(BUILD_DIR)/setup.py", line 438, in build_extensions
    if _cmd_exists(os.environ.get("PKG_CONFIG", "pkg-config")):
  File "$(BUILD_DIR)/setup.py", line 248, in _cmd_exists
    for path in os.environ["PATH"].split(os.pathsep)
  File "/usr/lib/python3.9/os.py", line 679, in __getitem__
    raise KeyError(key) from None
KeyError: 'PATH'
$

What are your OS, Python and Pillow versions?

  • OS: OpenIndiana
  • Python: 3.9.16
  • Pillow: 9.4.0
@wiredfool
Copy link
Member

I'm not sure that we can reasonably expect a build to work if there's no PATH? We have to be able to find compilers, linkers, and pkg-config.

Are there any binary packages that build with this configuration?

@radarhere
Copy link
Member

radarhere commented Feb 9, 2023

What happens if you try running setup.py with the following patch?

radarhere@02b976b

diff --git a/setup.py b/setup.py
index 8f7f223f8..9fc06f73f 100755
--- a/setup.py
+++ b/setup.py
@@ -243,6 +243,8 @@ def _find_include_dir(self, dirname, include):
 
 
 def _cmd_exists(cmd):
+    if not "PATH" in os.environ:
+        return
     return any(
         os.access(os.path.join(path, cmd), os.X_OK)
         for path in os.environ["PATH"].split(os.pathsep)

@radarhere radarhere added the Build label Feb 9, 2023
@mtelka
Copy link
Contributor Author

mtelka commented Feb 9, 2023

@radarhere, radarhere@02b976b fixed the problem. Now env - python3.9 setup.py build works as expected. Thank you.

@hugovk
Copy link
Member

hugovk commented Feb 9, 2023

What did you do?

$ env - python3.9 setup.py build

Note that invoking setup.py directly is deprecated, use python3.9 -m pip install . instead.

https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants