Skip to content

Use distutils.sysconfig to detect python include#54292

Merged
copybara-service[bot] merged 1 commit intotensorflow:masterfrom
laramiel:patch-1
Feb 9, 2022
Merged

Use distutils.sysconfig to detect python include#54292
copybara-service[bot] merged 1 commit intotensorflow:masterfrom
laramiel:patch-1

Conversation

@laramiel
Copy link
Copy Markdown
Contributor

@laramiel laramiel commented Feb 8, 2022

On my latest mac sysconfig.get_path('include') fails to find the correct python include path.
This solves that.

On my latest mac sysconfig.get_path('include') fails to find the correct python include path.
This solves that.
@google-ml-butler google-ml-butler bot added the size:S CL Change Size: Small label Feb 8, 2022
@gbaned gbaned requested a review from mihaimaruseac February 8, 2022 10:36
@google-ml-butler google-ml-butler bot added the awaiting review Pull request awaiting review label Feb 8, 2022
@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Feb 8, 2022
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Feb 8, 2022
@copybara-service copybara-service bot merged commit 7b6eb78 into tensorflow:master Feb 9, 2022
@google-ml-butler google-ml-butler bot removed awaiting review Pull request awaiting review ready to pull PR ready for merge process labels Feb 9, 2022
QrczakMK added a commit to google/riegeli that referenced this pull request Jul 6, 2022
@hawkinsp
Copy link
Copy Markdown
Contributor

hawkinsp commented Aug 7, 2023

FYI: I'm going to send a change that reverts this PR.

The reason is that distutils is removed under Python 3.12, and this code now raises a ModuleNotFoundError. Given distutils is due for removal, I can't see a good reason to prefer it over always using sysconfig.

Is it possible the original problem here was installation specific?

copybara-service bot pushed a commit to google/tsl that referenced this pull request Aug 7, 2023
The distutils module has been removed under Python 3.12, and the code here fails with a ModuleNotFoundError. This occurs because:

```
$ ipython
Python 3.12.0rc1 (main, Aug  7 2023, 13:07:47) [GCC 12.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.14.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import importlib.util

In [2]: importlib.util.find_spec('distutils.sysconfig')
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[2], line 1
----> 1 importlib.util.find_spec('distutils.sysconfig')

File <frozen importlib.util>:91, in find_spec(name, package)

ModuleNotFoundError: No module named 'distutils'
```

However, as far as I can tell, we can just unconditionally use sysconfig since Python 3.2, which is well below the minimum Python version requirement of this code.

This change effectively reverts: tensorflow/tensorflow#54292
That change will no longer be tenable once Python 3.12 is released.

PiperOrigin-RevId: 554457984
copybara-service bot pushed a commit to google/tsl that referenced this pull request Aug 9, 2023
The distutils module has been removed under Python 3.12, and the code here fails with a ModuleNotFoundError. This occurs because:

```
$ ipython
Python 3.12.0rc1 (main, Aug  7 2023, 13:07:47) [GCC 12.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.14.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import importlib.util

In [2]: importlib.util.find_spec('distutils.sysconfig')
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[2], line 1
----> 1 importlib.util.find_spec('distutils.sysconfig')

File <frozen importlib.util>:91, in find_spec(name, package)

ModuleNotFoundError: No module named 'distutils'
```

However, as far as I can tell, we can just unconditionally use sysconfig since Python 3.2, which is well below the minimum Python version requirement of this code.

This change effectively reverts: tensorflow/tensorflow#54292
That change will no longer be tenable once Python 3.12 is released.

PiperOrigin-RevId: 554457984
copybara-service bot pushed a commit to google/tsl that referenced this pull request Aug 9, 2023
The distutils module has been removed under Python 3.12, and the code here fails with a ModuleNotFoundError. This occurs because:

```
$ ipython
Python 3.12.0rc1 (main, Aug  7 2023, 13:07:47) [GCC 12.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.14.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import importlib.util

In [2]: importlib.util.find_spec('distutils.sysconfig')
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[2], line 1
----> 1 importlib.util.find_spec('distutils.sysconfig')

File <frozen importlib.util>:91, in find_spec(name, package)

ModuleNotFoundError: No module named 'distutils'
```

However, as far as I can tell, we can just unconditionally use sysconfig since Python 3.2, which is well below the minimum Python version requirement of this code.

This change effectively reverts: tensorflow/tensorflow#54292
That change will no longer be tenable once Python 3.12 is released.

PiperOrigin-RevId: 555273752
copybara-service bot pushed a commit to openxla/xla that referenced this pull request Aug 9, 2023
The distutils module has been removed under Python 3.12, and the code here fails with a ModuleNotFoundError. This occurs because:

```
$ ipython
Python 3.12.0rc1 (main, Aug  7 2023, 13:07:47) [GCC 12.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.14.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import importlib.util

In [2]: importlib.util.find_spec('distutils.sysconfig')
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[2], line 1
----> 1 importlib.util.find_spec('distutils.sysconfig')

File <frozen importlib.util>:91, in find_spec(name, package)

ModuleNotFoundError: No module named 'distutils'
```

However, as far as I can tell, we can just unconditionally use sysconfig since Python 3.2, which is well below the minimum Python version requirement of this code.

This change effectively reverts: tensorflow/tensorflow#54292
That change will no longer be tenable once Python 3.12 is released.

PiperOrigin-RevId: 555273752
copybara-service bot pushed a commit that referenced this pull request Aug 9, 2023
The distutils module has been removed under Python 3.12, and the code here fails with a ModuleNotFoundError. This occurs because:

```
$ ipython
Python 3.12.0rc1 (main, Aug  7 2023, 13:07:47) [GCC 12.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.14.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import importlib.util

In [2]: importlib.util.find_spec('distutils.sysconfig')
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[2], line 1
----> 1 importlib.util.find_spec('distutils.sysconfig')

File <frozen importlib.util>:91, in find_spec(name, package)

ModuleNotFoundError: No module named 'distutils'
```

However, as far as I can tell, we can just unconditionally use sysconfig since Python 3.2, which is well below the minimum Python version requirement of this code.

This change effectively reverts: #54292
That change will no longer be tenable once Python 3.12 is released.

PiperOrigin-RevId: 555273752
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S CL Change Size: Small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants