Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
3804a131
Unverified
Commit
3804a131
authored
Apr 30, 2023
by
David Hotham
Committed by
GitHub
Apr 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle distutils deprecation (#7766)
parent
5dab851d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
53 deletions
+10
-53
src/poetry/utils/env.py
+5
-48
tests/fixtures/extended_with_no_setup/build.py
+4
-4
tests/fixtures/extended_with_no_setup/pyproject.toml
+1
-1
No files found.
src/poetry/utils/env.py
View file @
3804a131
...
@@ -13,7 +13,6 @@ import shutil
...
@@ -13,7 +13,6 @@ import shutil
import
subprocess
import
subprocess
import
sys
import
sys
import
sysconfig
import
sysconfig
import
warnings
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
from
copy
import
deepcopy
from
copy
import
deepcopy
...
@@ -190,33 +189,15 @@ print(json.dumps(sysconfig.get_paths()))
...
@@ -190,33 +189,15 @@ print(json.dumps(sysconfig.get_paths()))
"""
"""
GET_PATHS_FOR_GENERIC_ENVS
=
"""
\
GET_PATHS_FOR_GENERIC_ENVS
=
"""
\
# We can't use sysconfig.get_paths() because
# on some distributions it does not return the proper paths
# (those used by pip for instance). We go through distutils
# to get the proper ones.
import json
import json
import site
import site
import sysconfig
import sysconfig
from distutils.command.install import SCHEME_KEYS
from distutils.core import Distribution
d = Distribution()
d.parse_config_files()
obj = d.get_command_obj("install", create=True)
obj.finalize_options()
paths = sysconfig.get_paths().copy()
paths = sysconfig.get_paths().copy()
for key in SCHEME_KEYS:
if key == "headers":
# headers is not a path returned by sysconfig.get_paths()
continue
paths[key] = getattr(obj, f"install_{key}")
if site.check_enableusersite():
paths["usersite"] = site.getusersitepackages()
if site.check_enableusersite() and hasattr(obj, "install_usersite"):
paths["userbase"] = site.getuserbase()
paths["usersite"] = getattr(obj, "install_usersite")
paths["userbase"] = getattr(obj, "install_userbase")
print(json.dumps(paths))
print(json.dumps(paths))
"""
"""
...
@@ -1637,37 +1618,13 @@ class SystemEnv(Env):
...
@@ -1637,37 +1618,13 @@ class SystemEnv(Env):
return
platform
.
python_implementation
()
return
platform
.
python_implementation
()
def
get_paths
(
self
)
->
dict
[
str
,
str
]:
def
get_paths
(
self
)
->
dict
[
str
,
str
]:
# We can't use sysconfig.get_paths() because
# on some distributions it does not return the proper paths
# (those used by pip for instance). We go through distutils
# to get the proper ones.
import
site
import
site
from
distutils.command.install
import
SCHEME_KEYS
from
distutils.core
import
Distribution
d
=
Distribution
()
d
.
parse_config_files
()
with
warnings
.
catch_warnings
():
warnings
.
filterwarnings
(
"ignore"
,
"setup.py install is deprecated"
)
obj
=
d
.
get_command_obj
(
"install"
,
create
=
True
)
assert
obj
is
not
None
obj
.
finalize_options
()
paths
=
sysconfig
.
get_paths
()
.
copy
()
paths
=
sysconfig
.
get_paths
()
.
copy
()
for
key
in
SCHEME_KEYS
:
if
key
==
"headers"
:
# headers is not a path returned by sysconfig.get_paths()
continue
paths
[
key
]
=
getattr
(
obj
,
f
"install_{key}"
)
if
site
.
check_enableusersite
():
if
site
.
check_enableusersite
():
usersite
=
getattr
(
obj
,
"install_usersite"
,
None
)
paths
[
"usersite"
]
=
site
.
getusersitepackages
()
userbase
=
getattr
(
obj
,
"install_userbase"
,
None
)
paths
[
"userbase"
]
=
site
.
getuserbase
()
if
usersite
is
not
None
and
userbase
is
not
None
:
paths
[
"usersite"
]
=
usersite
paths
[
"userbase"
]
=
userbase
return
paths
return
paths
...
...
tests/fixtures/extended_with_no_setup/build.py
View file @
3804a131
...
@@ -3,9 +3,9 @@ from __future__ import annotations
...
@@ -3,9 +3,9 @@ from __future__ import annotations
import
os
import
os
import
shutil
import
shutil
from
distutils.command.build_ext
import
build_ext
from
setuptools
import
Distribution
from
distutils.core
import
Distribut
ion
from
setuptools
import
Extens
ion
from
distutils.core
import
Extension
from
setuptools.command.build_ext
import
build_ext
extensions
=
[
Extension
(
"extended.extended"
,
[
"extended/extended.c"
])]
extensions
=
[
Extension
(
"extended.extended"
,
[
"extended/extended.c"
])]
...
@@ -13,7 +13,7 @@ extensions = [Extension("extended.extended", ["extended/extended.c"])]
...
@@ -13,7 +13,7 @@ extensions = [Extension("extended.extended", ["extended/extended.c"])]
def
build
():
def
build
():
distribution
=
Distribution
({
"name"
:
"extended"
,
"ext_modules"
:
extensions
})
distribution
=
Distribution
({
"name"
:
"extended"
,
"ext_modules"
:
extensions
})
distribution
.
package_dir
=
"extended"
distribution
.
package_dir
=
{
"extended"
:
"extended"
}
cmd
=
build_ext
(
distribution
)
cmd
=
build_ext
(
distribution
)
cmd
.
ensure_finalized
()
cmd
.
ensure_finalized
()
...
...
tests/fixtures/extended_with_no_setup/pyproject.toml
View file @
3804a131
...
@@ -22,5 +22,5 @@ script = "build.py"
...
@@ -22,5 +22,5 @@ script = "build.py"
generate-setup-file
=
false
generate-setup-file
=
false
[build-system]
[build-system]
requires
=
["poetry-core>=1.5.0"]
requires
=
[
"poetry-core>=1.5.0"
,
"setuptools>=67.6.1"
]
build-backend
=
"poetry.core.masonry.api"
build-backend
=
"poetry.core.masonry.api"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment