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
8ac6d0fd
Commit
8ac6d0fd
authored
Feb 27, 2009
by
Tarek Ziadé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #5052: make Distutils compatible with 2.3 again.
parent
9daeb929
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
183 additions
and
38 deletions
+183
-38
README
README
+2
-0
command/build_ext.py
command/build_ext.py
+14
-4
command/install.py
command/install.py
+52
-31
command/upload.py
command/upload.py
+6
-1
tests/test_build_ext.py
tests/test_build_ext.py
+45
-2
tests/test_install.py
tests/test_install.py
+64
-0
No files found.
README
View file @
8ac6d0fd
...
@@ -8,4 +8,6 @@ The Distutils-SIG web page is also a good starting point:
...
@@ -8,4 +8,6 @@ The Distutils-SIG web page is also a good starting point:
http://www.python.org/sigs/distutils-sig/
http://www.python.org/sigs/distutils-sig/
WARNING : Distutils must remain compatible with 2.3
$Id$
$Id$
command/build_ext.py
View file @
8ac6d0fd
...
@@ -8,7 +8,6 @@ __revision__ = "$Id$"
...
@@ -8,7 +8,6 @@ __revision__ = "$Id$"
import
sys
,
os
,
string
,
re
import
sys
,
os
,
string
,
re
from
types
import
*
from
types
import
*
from
site
import
USER_BASE
from
distutils.core
import
Command
from
distutils.core
import
Command
from
distutils.errors
import
*
from
distutils.errors
import
*
from
distutils.sysconfig
import
customize_compiler
,
get_python_version
from
distutils.sysconfig
import
customize_compiler
,
get_python_version
...
@@ -17,6 +16,14 @@ from distutils.extension import Extension
...
@@ -17,6 +16,14 @@ from distutils.extension import Extension
from
distutils.util
import
get_platform
from
distutils.util
import
get_platform
from
distutils
import
log
from
distutils
import
log
# this keeps compatibility from 2.3 to 2.5
if
sys
.
version
<
"2.6"
:
USER_BASE
=
None
HAS_USER_SITE
=
False
else
:
from
site
import
USER_BASE
HAS_USER_SITE
=
True
if
os
.
name
==
'nt'
:
if
os
.
name
==
'nt'
:
from
distutils.msvccompiler
import
get_build_version
from
distutils.msvccompiler
import
get_build_version
MSVC_VERSION
=
int
(
get_build_version
())
MSVC_VERSION
=
int
(
get_build_version
())
...
@@ -92,11 +99,14 @@ class build_ext (Command):
...
@@ -92,11 +99,14 @@ class build_ext (Command):
"list of SWIG command line options"
),
"list of SWIG command line options"
),
(
'swig='
,
None
,
(
'swig='
,
None
,
"path to the SWIG executable"
),
"path to the SWIG executable"
),
(
'user'
,
None
,
"add user include, library and rpath"
),
]
]
boolean_options
=
[
'inplace'
,
'debug'
,
'force'
,
'swig-cpp'
,
'user'
]
boolean_options
=
[
'inplace'
,
'debug'
,
'force'
,
'swig-cpp'
]
if
HAS_USER_SITE
:
user_options
.
append
((
'user'
,
None
,
"add user include, library and rpath"
))
boolean_options
.
append
(
'user'
)
help_options
=
[
help_options
=
[
(
'help-compiler'
,
None
,
(
'help-compiler'
,
None
,
...
...
command/install.py
View file @
8ac6d0fd
...
@@ -16,9 +16,16 @@ from distutils.file_util import write_file
...
@@ -16,9 +16,16 @@ from distutils.file_util import write_file
from
distutils.util
import
convert_path
,
subst_vars
,
change_root
from
distutils.util
import
convert_path
,
subst_vars
,
change_root
from
distutils.util
import
get_platform
from
distutils.util
import
get_platform
from
distutils.errors
import
DistutilsOptionError
from
distutils.errors
import
DistutilsOptionError
from
site
import
USER_BASE
from
site
import
USER_SITE
# this keeps compatibility from 2.3 to 2.5
if
sys
.
version
<
"2.6"
:
USER_BASE
=
None
USER_SITE
=
None
HAS_USER_SITE
=
False
else
:
from
site
import
USER_BASE
from
site
import
USER_SITE
HAS_USER_SITE
=
True
if
sys
.
version
<
"2.2"
:
if
sys
.
version
<
"2.2"
:
WINDOWS_SCHEME
=
{
WINDOWS_SCHEME
=
{
...
@@ -52,21 +59,7 @@ INSTALL_SCHEMES = {
...
@@ -52,21 +59,7 @@ INSTALL_SCHEMES = {
'scripts'
:
'$base/bin'
,
'scripts'
:
'$base/bin'
,
'data'
:
'$base'
,
'data'
:
'$base'
,
},
},
'unix_user'
:
{
'purelib'
:
'$usersite'
,
'platlib'
:
'$usersite'
,
'headers'
:
'$userbase/include/python$py_version_short/$dist_name'
,
'scripts'
:
'$userbase/bin'
,
'data'
:
'$userbase'
,
},
'nt'
:
WINDOWS_SCHEME
,
'nt'
:
WINDOWS_SCHEME
,
'nt_user'
:
{
'purelib'
:
'$usersite'
,
'platlib'
:
'$usersite'
,
'headers'
:
'$userbase/Python$py_version_nodot/Include/$dist_name'
,
'scripts'
:
'$userbase/Scripts'
,
'data'
:
'$userbase'
,
},
'mac'
:
{
'mac'
:
{
'purelib'
:
'$base/Lib/site-packages'
,
'purelib'
:
'$base/Lib/site-packages'
,
'platlib'
:
'$base/Lib/site-packages'
,
'platlib'
:
'$base/Lib/site-packages'
,
...
@@ -74,13 +67,7 @@ INSTALL_SCHEMES = {
...
@@ -74,13 +67,7 @@ INSTALL_SCHEMES = {
'scripts'
:
'$base/Scripts'
,
'scripts'
:
'$base/Scripts'
,
'data'
:
'$base'
,
'data'
:
'$base'
,
},
},
'mac_user'
:
{
'purelib'
:
'$usersite'
,
'platlib'
:
'$usersite'
,
'headers'
:
'$userbase/$py_version_short/include/$dist_name'
,
'scripts'
:
'$userbase/bin'
,
'data'
:
'$userbase'
,
},
'os2'
:
{
'os2'
:
{
'purelib'
:
'$base/Lib/site-packages'
,
'purelib'
:
'$base/Lib/site-packages'
,
'platlib'
:
'$base/Lib/site-packages'
,
'platlib'
:
'$base/Lib/site-packages'
,
...
@@ -88,14 +75,41 @@ INSTALL_SCHEMES = {
...
@@ -88,14 +75,41 @@ INSTALL_SCHEMES = {
'scripts'
:
'$base/Scripts'
,
'scripts'
:
'$base/Scripts'
,
'data'
:
'$base'
,
'data'
:
'$base'
,
},
},
'os2_home'
:
{
}
# user site schemes
if
HAS_USER_SITE
:
INSTALL_SCHEMES
[
'nt_user'
]
=
{
'purelib'
:
'$usersite'
,
'platlib'
:
'$usersite'
,
'headers'
:
'$userbase/Python$py_version_nodot/Include/$dist_name'
,
'scripts'
:
'$userbase/Scripts'
,
'data'
:
'$userbase'
,
}
INSTALL_SCHEMES
[
'unix_user'
]
=
{
'purelib'
:
'$usersite'
,
'purelib'
:
'$usersite'
,
'platlib'
:
'$usersite'
,
'platlib'
:
'$usersite'
,
'headers'
:
'$userbase/include/python$py_version_short/$dist_name'
,
'headers'
:
'$userbase/include/python$py_version_short/$dist_name'
,
'scripts'
:
'$userbase/bin'
,
'scripts'
:
'$userbase/bin'
,
'data'
:
'$userbase'
,
'data'
:
'$userbase'
,
},
}
}
INSTALL_SCHEMES
[
'mac_user'
]
=
{
'purelib'
:
'$usersite'
,
'platlib'
:
'$usersite'
,
'headers'
:
'$userbase/$py_version_short/include/$dist_name'
,
'scripts'
:
'$userbase/bin'
,
'data'
:
'$userbase'
,
}
INSTALL_SCHEMES
[
'os2_home'
]
=
{
'purelib'
:
'$usersite'
,
'platlib'
:
'$usersite'
,
'headers'
:
'$userbase/include/python$py_version_short/$dist_name'
,
'scripts'
:
'$userbase/bin'
,
'data'
:
'$userbase'
,
}
# The keys to an installation scheme; if any new types of files are to be
# The keys to an installation scheme; if any new types of files are to be
# installed, be sure to add an entry to every installation scheme above,
# installed, be sure to add an entry to every installation scheme above,
...
@@ -115,8 +129,6 @@ class install (Command):
...
@@ -115,8 +129,6 @@ class install (Command):
"(Unix only) prefix for platform-specific files"
),
"(Unix only) prefix for platform-specific files"
),
(
'home='
,
None
,
(
'home='
,
None
,
"(Unix only) home directory to install under"
),
"(Unix only) home directory to install under"
),
(
'user'
,
None
,
"install in user site-package '%s'"
%
USER_SITE
),
# Or, just set the base director(y|ies)
# Or, just set the base director(y|ies)
(
'install-base='
,
None
,
(
'install-base='
,
None
,
...
@@ -168,7 +180,13 @@ class install (Command):
...
@@ -168,7 +180,13 @@ class install (Command):
"filename in which to record list of installed files"
),
"filename in which to record list of installed files"
),
]
]
boolean_options
=
[
'compile'
,
'force'
,
'skip-build'
,
'user'
]
boolean_options
=
[
'compile'
,
'force'
,
'skip-build'
]
if
HAS_USER_SITE
:
user_options
.
append
((
'user'
,
None
,
"install in user site-package '%s'"
%
USER_SITE
))
boolean_options
.
append
(
'user'
)
negative_opt
=
{
'no-compile'
:
'compile'
}
negative_opt
=
{
'no-compile'
:
'compile'
}
...
@@ -320,9 +338,12 @@ class install (Command):
...
@@ -320,9 +338,12 @@ class install (Command):
'prefix'
:
prefix
,
'prefix'
:
prefix
,
'sys_exec_prefix'
:
exec_prefix
,
'sys_exec_prefix'
:
exec_prefix
,
'exec_prefix'
:
exec_prefix
,
'exec_prefix'
:
exec_prefix
,
'userbase'
:
self
.
install_userbase
,
'usersite'
:
self
.
install_usersite
,
}
}
if
HAS_USER_SITE
:
self
.
config_vars
[
'userbase'
]
=
self
.
install_userbase
self
.
config_vars
[
'usersite'
]
=
self
.
install_usersite
self
.
expand_basedirs
()
self
.
expand_basedirs
()
self
.
dump_dirs
(
"post-expand_basedirs()"
)
self
.
dump_dirs
(
"post-expand_basedirs()"
)
...
...
command/upload.py
View file @
8ac6d0fd
...
@@ -6,7 +6,7 @@ from distutils.errors import *
...
@@ -6,7 +6,7 @@ from distutils.errors import *
from
distutils.core
import
PyPIRCCommand
from
distutils.core
import
PyPIRCCommand
from
distutils.spawn
import
spawn
from
distutils.spawn
import
spawn
from
distutils
import
log
from
distutils
import
log
from
hashlib
import
md5
import
sys
import
os
import
os
import
socket
import
socket
import
platform
import
platform
...
@@ -16,6 +16,11 @@ import urlparse
...
@@ -16,6 +16,11 @@ import urlparse
import
cStringIO
as
StringIO
import
cStringIO
as
StringIO
from
ConfigParser
import
ConfigParser
from
ConfigParser
import
ConfigParser
# this keeps compatibility for 2.3 and 2.4
if
sys
.
version
<
"2.5"
:
from
md5
import
md5
else
:
from
hashlib
import
md5
class
upload
(
PyPIRCCommand
):
class
upload
(
PyPIRCCommand
):
...
...
tests/test_build_ext.py
View file @
8ac6d0fd
...
@@ -24,11 +24,17 @@ class BuildExtTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -24,11 +24,17 @@ class BuildExtTestCase(support.TempdirManager, unittest.TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
# Create a simple test environment
# Create a simple test environment
# Note that we're making changes to sys.path
# Note that we're making changes to sys.path
sup
port
.
TempdirManager
.
setUp
(
self
)
sup
er
(
BuildExtTestCase
,
self
).
setUp
(
)
self
.
tmp_dir
=
self
.
mkdtemp
()
self
.
tmp_dir
=
self
.
mkdtemp
()
self
.
sys_path
=
sys
.
path
[:]
self
.
sys_path
=
sys
.
path
[:]
sys
.
path
.
append
(
self
.
tmp_dir
)
sys
.
path
.
append
(
self
.
tmp_dir
)
shutil
.
copy
(
_get_source_filename
(),
self
.
tmp_dir
)
shutil
.
copy
(
_get_source_filename
(),
self
.
tmp_dir
)
if
sys
.
version
>
"2.6"
:
import
site
self
.
old_user_base
=
site
.
USER_BASE
site
.
USER_BASE
=
self
.
mkdtemp
()
from
distutils.command
import
build_ext
build_ext
.
USER_BASE
=
site
.
USER_BASE
def
test_build_ext
(
self
):
def
test_build_ext
(
self
):
global
ALREADY_TESTED
global
ALREADY_TESTED
...
@@ -76,7 +82,13 @@ class BuildExtTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -76,7 +82,13 @@ class BuildExtTestCase(support.TempdirManager, unittest.TestCase):
# Get everything back to normal
# Get everything back to normal
test_support
.
unload
(
'xx'
)
test_support
.
unload
(
'xx'
)
sys
.
path
=
self
.
sys_path
sys
.
path
=
self
.
sys_path
support
.
TempdirManager
.
tearDown
(
self
)
if
sys
.
version
>
"2.6"
:
import
site
site
.
USER_BASE
=
self
.
old_user_base
from
distutils.command
import
build_ext
build_ext
.
USER_BASE
=
self
.
old_user_base
super
(
BuildExtTestCase
,
self
).
tearDown
()
def
test_solaris_enable_shared
(
self
):
def
test_solaris_enable_shared
(
self
):
dist
=
Distribution
({
'name'
:
'xx'
})
dist
=
Distribution
({
'name'
:
'xx'
})
...
@@ -99,6 +111,37 @@ class BuildExtTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -99,6 +111,37 @@ class BuildExtTestCase(support.TempdirManager, unittest.TestCase):
# make sur we get some lobrary dirs under solaris
# make sur we get some lobrary dirs under solaris
self
.
assert_
(
len
(
cmd
.
library_dirs
)
>
0
)
self
.
assert_
(
len
(
cmd
.
library_dirs
)
>
0
)
def
test_user_site
(
self
):
# site.USER_SITE was introduced in 2.6
if
sys
.
version
<
'2.6'
:
return
import
site
dist
=
Distribution
({
'name'
:
'xx'
})
cmd
=
build_ext
(
dist
)
# making sure the suer option is there
options
=
[
name
for
name
,
short
,
lable
in
cmd
.
user_options
]
self
.
assert_
(
'user'
in
options
)
# setting a value
cmd
.
user
=
1
# setting user based lib and include
lib
=
os
.
path
.
join
(
site
.
USER_BASE
,
'lib'
)
incl
=
os
.
path
.
join
(
site
.
USER_BASE
,
'include'
)
os
.
mkdir
(
lib
)
os
.
mkdir
(
incl
)
# let's run finalize
cmd
.
ensure_finalized
()
# see if include_dirs and library_dirs
# were set
self
.
assert_
(
lib
in
cmd
.
library_dirs
)
self
.
assert_
(
incl
in
cmd
.
include_dirs
)
def
test_suite
():
def
test_suite
():
src
=
_get_source_filename
()
src
=
_get_source_filename
()
if
not
os
.
path
.
exists
(
src
):
if
not
os
.
path
.
exists
(
src
):
...
...
tests/test_install.py
View file @
8ac6d0fd
"""Tests for distutils.command.install."""
"""Tests for distutils.command.install."""
import
os
import
os
import
os.path
import
sys
import
unittest
import
unittest
import
site
from
distutils.command.install
import
install
from
distutils.command.install
import
install
from
distutils.command
import
install
as
install_module
from
distutils.command.install
import
INSTALL_SCHEMES
from
distutils.core
import
Distribution
from
distutils.core
import
Distribution
from
distutils.tests
import
support
from
distutils.tests
import
support
...
@@ -47,6 +52,65 @@ class InstallTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -47,6 +52,65 @@ class InstallTestCase(support.TempdirManager, unittest.TestCase):
check_path
(
cmd
.
install_scripts
,
os
.
path
.
join
(
destination
,
"bin"
))
check_path
(
cmd
.
install_scripts
,
os
.
path
.
join
(
destination
,
"bin"
))
check_path
(
cmd
.
install_data
,
destination
)
check_path
(
cmd
.
install_data
,
destination
)
def
test_user_site
(
self
):
# site.USER_SITE was introduced in 2.6
if
sys
.
version
<
'2.6'
:
return
# preparing the environement for the test
self
.
old_user_base
=
site
.
USER_BASE
self
.
old_user_site
=
site
.
USER_SITE
self
.
tmpdir
=
self
.
mkdtemp
()
self
.
user_base
=
os
.
path
.
join
(
self
.
tmpdir
,
'B'
)
self
.
user_site
=
os
.
path
.
join
(
self
.
tmpdir
,
'S'
)
site
.
USER_BASE
=
self
.
user_base
site
.
USER_SITE
=
self
.
user_site
install_module
.
USER_BASE
=
self
.
user_base
install_module
.
USER_SITE
=
self
.
user_site
def
_expanduser
(
path
):
return
self
.
tmpdir
self
.
old_expand
=
os
.
path
.
expanduser
os
.
path
.
expanduser
=
_expanduser
try
:
# this is the actual test
self
.
_test_user_site
()
finally
:
site
.
USER_BASE
=
self
.
old_user_base
site
.
USER_SITE
=
self
.
old_user_site
install_module
.
USER_BASE
=
self
.
old_user_base
install_module
.
USER_SITE
=
self
.
old_user_site
os
.
path
.
expanduser
=
self
.
old_expand
def
_test_user_site
(
self
):
for
key
in
(
'nt_user'
,
'unix_user'
,
'os2_home'
):
self
.
assert_
(
key
in
INSTALL_SCHEMES
)
dist
=
Distribution
({
'name'
:
'xx'
})
cmd
=
install
(
dist
)
# making sure the user option is there
options
=
[
name
for
name
,
short
,
lable
in
cmd
.
user_options
]
self
.
assert_
(
'user'
in
options
)
# setting a value
cmd
.
user
=
1
# user base and site shouldn't be created yet
self
.
assert_
(
not
os
.
path
.
exists
(
self
.
user_base
))
self
.
assert_
(
not
os
.
path
.
exists
(
self
.
user_site
))
# let's run finalize
cmd
.
ensure_finalized
()
# now they should
self
.
assert_
(
os
.
path
.
exists
(
self
.
user_base
))
self
.
assert_
(
os
.
path
.
exists
(
self
.
user_site
))
self
.
assert_
(
'userbase'
in
cmd
.
config_vars
)
self
.
assert_
(
'usersite'
in
cmd
.
config_vars
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
InstallTestCase
)
return
unittest
.
makeSuite
(
InstallTestCase
)
...
...
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