Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
07f33c84
Commit
07f33c84
authored
Aug 21, 2011
by
Éric Araujo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factor out the build_ext fixup for shared Python builds.
I need this to fix the failing test_install.
parent
5deb9c1a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
25 deletions
+33
-25
tests/support.py
tests/support.py
+27
-0
tests/test_build_ext.py
tests/test_build_ext.py
+6
-25
No files found.
tests/support.py
View file @
07f33c84
"""Support code for distutils test cases."""
"""Support code for distutils test cases."""
import
os
import
os
import
sys
import
shutil
import
shutil
import
tempfile
import
tempfile
import
unittest
import
unittest
...
@@ -165,3 +166,29 @@ def _get_xxmodule_path():
...
@@ -165,3 +166,29 @@ def _get_xxmodule_path():
for
path
in
candidates
:
for
path
in
candidates
:
if
os
.
path
.
exists
(
path
):
if
os
.
path
.
exists
(
path
):
return
path
return
path
def
fixup_build_ext
(
cmd
):
"""Function needed to make build_ext tests pass on shared builds.
When Python was build with --enable-shared, -L. is not good enough to find
the libpython<blah>.so. This is because regrtest runs it under a tempdir,
not in the top level where the .so lives. By the time we've gotten here,
Python's already been chdir'd to the tempdir. This function work arounds
that. Example use:
cmd = build_ext(dist)
support.fixup_build_ext(cmd)
cmd.ensure_finalized()
"""
# To further add to the fun, we can't just add library_dirs to the
# Extension() instance because that doesn't get plumbed through to the
# final compiler command.
if
(
sysconfig
.
get_config_var
(
'Py_ENABLE_SHARED'
)
and
not
sys
.
platform
.
startswith
(
'win'
)):
runshared
=
sysconfig
.
get_config_var
(
'RUNSHARED'
)
if
runshared
is
None
:
cmd
.
library_dirs
=
[
'.'
]
else
:
name
,
equals
,
value
=
runshared
.
partition
(
'='
)
cmd
.
library_dirs
=
value
.
split
(
os
.
pathsep
)
tests/test_build_ext.py
View file @
07f33c84
...
@@ -7,7 +7,7 @@ from distutils.core import Distribution
...
@@ -7,7 +7,7 @@ from distutils.core import Distribution
from
distutils.command.build_ext
import
build_ext
from
distutils.command.build_ext
import
build_ext
from
distutils
import
sysconfig
from
distutils
import
sysconfig
from
distutils.tests.support
import
(
TempdirManager
,
LoggingSilencer
,
from
distutils.tests.support
import
(
TempdirManager
,
LoggingSilencer
,
copy_xxmodule_c
)
copy_xxmodule_c
,
fixup_build_ext
)
from
distutils.extension
import
Extension
from
distutils.extension
import
Extension
from
distutils.errors
import
(
from
distutils.errors
import
(
CompileError
,
DistutilsPlatformError
,
DistutilsSetupError
,
CompileError
,
DistutilsPlatformError
,
DistutilsSetupError
,
...
@@ -38,25 +38,6 @@ class BuildExtTestCase(TempdirManager,
...
@@ -38,25 +38,6 @@ class BuildExtTestCase(TempdirManager,
from
distutils.command
import
build_ext
from
distutils.command
import
build_ext
build_ext
.
USER_BASE
=
site
.
USER_BASE
build_ext
.
USER_BASE
=
site
.
USER_BASE
def
_fixup_command
(
self
,
cmd
):
# When Python was build with --enable-shared, -L. is not good enough
# to find the libpython<blah>.so. This is because regrtest runs it
# under a tempdir, not in the top level where the .so lives. By the
# time we've gotten here, Python's already been chdir'd to the
# tempdir.
#
# To further add to the fun, we can't just add library_dirs to the
# Extension() instance because that doesn't get plumbed through to the
# final compiler command.
if
(
sysconfig
.
get_config_var
(
'Py_ENABLE_SHARED'
)
and
not
sys
.
platform
.
startswith
(
'win'
)):
runshared
=
sysconfig
.
get_config_var
(
'RUNSHARED'
)
if
runshared
is
None
:
cmd
.
library_dirs
=
[
'.'
]
else
:
name
,
equals
,
value
=
runshared
.
partition
(
'='
)
cmd
.
library_dirs
=
value
.
split
(
os
.
pathsep
)
def
test_build_ext
(
self
):
def
test_build_ext
(
self
):
global
ALREADY_TESTED
global
ALREADY_TESTED
copy_xxmodule_c
(
self
.
tmp_dir
)
copy_xxmodule_c
(
self
.
tmp_dir
)
...
@@ -65,7 +46,7 @@ class BuildExtTestCase(TempdirManager,
...
@@ -65,7 +46,7 @@ class BuildExtTestCase(TempdirManager,
dist
=
Distribution
({
'name'
:
'xx'
,
'ext_modules'
:
[
xx_ext
]})
dist
=
Distribution
({
'name'
:
'xx'
,
'ext_modules'
:
[
xx_ext
]})
dist
.
package_dir
=
self
.
tmp_dir
dist
.
package_dir
=
self
.
tmp_dir
cmd
=
build_ext
(
dist
)
cmd
=
build_ext
(
dist
)
self
.
_fixup_command
(
cmd
)
fixup_build_ext
(
cmd
)
if
os
.
name
==
"nt"
:
if
os
.
name
==
"nt"
:
# On Windows, we must build a debug version iff running
# On Windows, we must build a debug version iff running
# a debug build of Python
# a debug build of Python
...
@@ -162,9 +143,9 @@ class BuildExtTestCase(TempdirManager,
...
@@ -162,9 +143,9 @@ class BuildExtTestCase(TempdirManager,
# see if include_dirs and library_dirs
# see if include_dirs and library_dirs
# were set
# were set
self
.
assert
True
(
lib
in
cmd
.
library_dirs
)
self
.
assert
In
(
lib
,
cmd
.
library_dirs
)
self
.
assert
True
(
lib
in
cmd
.
rpath
)
self
.
assert
In
(
lib
,
cmd
.
rpath
)
self
.
assert
True
(
incl
in
cmd
.
include_dirs
)
self
.
assert
In
(
incl
,
cmd
.
include_dirs
)
def
test_optional_extension
(
self
):
def
test_optional_extension
(
self
):
...
@@ -320,7 +301,7 @@ class BuildExtTestCase(TempdirManager,
...
@@ -320,7 +301,7 @@ class BuildExtTestCase(TempdirManager,
dist
=
Distribution
({
'name'
:
'xx'
,
dist
=
Distribution
({
'name'
:
'xx'
,
'ext_modules'
:
[
ext
]})
'ext_modules'
:
[
ext
]})
cmd
=
build_ext
(
dist
)
cmd
=
build_ext
(
dist
)
self
.
_fixup_command
(
cmd
)
fixup_build_ext
(
cmd
)
cmd
.
ensure_finalized
()
cmd
.
ensure_finalized
()
self
.
assertEqual
(
len
(
cmd
.
get_outputs
()),
1
)
self
.
assertEqual
(
len
(
cmd
.
get_outputs
()),
1
)
...
...
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