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
9e0e2af9
Commit
9e0e2af9
authored
Oct 24, 2009
by
Tarek Ziadé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #7071: byte-compilation in Distutils now looks at sys.dont_write_bytecode
parent
cef81109
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
5 deletions
+64
-5
command/build_py.py
command/build_py.py
+5
-0
command/install_lib.py
command/install_lib.py
+6
-0
errors.py
errors.py
+2
-0
tests/test_build_py.py
tests/test_build_py.py
+16
-0
tests/test_install_lib.py
tests/test_install_lib.py
+17
-0
tests/test_util.py
tests/test_util.py
+13
-5
util.py
util.py
+5
-0
No files found.
command/build_py.py
View file @
9e0e2af9
...
...
@@ -5,6 +5,7 @@ Implements the Distutils 'build_py' command."""
__revision__
=
"$Id$"
import
os
import
sys
from
glob
import
glob
from
distutils.core
import
Command
...
...
@@ -372,6 +373,10 @@ class build_py(Command):
self
.
build_module
(
module
,
module_file
,
package
)
def
byte_compile
(
self
,
files
):
if
sys
.
dont_write_bytecode
:
self
.
warn
(
'byte-compile not supported on this platform, skipping.'
)
return
from
distutils.util
import
byte_compile
prefix
=
self
.
build_lib
if
prefix
[
-
1
]
!=
os
.
sep
:
...
...
command/install_lib.py
View file @
9e0e2af9
...
...
@@ -6,6 +6,8 @@ Implements the Distutils 'install_lib' command
__revision__
=
"$Id$"
import
os
import
sys
from
distutils.core
import
Command
from
distutils.errors
import
DistutilsOptionError
...
...
@@ -118,6 +120,10 @@ class install_lib(Command):
return
outfiles
def
byte_compile
(
self
,
files
):
if
sys
.
dont_write_bytecode
:
self
.
warn
(
'byte-compile not supported on this platform, skipping.'
)
return
from
distutils.util
import
byte_compile
# Get the "--root" directory supplied to the "install" command,
...
...
errors.py
View file @
9e0e2af9
...
...
@@ -74,6 +74,8 @@ class DistutilsInternalError (DistutilsError):
class
DistutilsTemplateError
(
DistutilsError
):
"""Syntax error in a file list template."""
class
DistutilsByteCompileError
(
DistutilsError
):
"""Byte compile error."""
# Exception classes used by the CCompiler implementation classes
class
CCompilerError
(
Exception
):
...
...
tests/test_build_py.py
View file @
9e0e2af9
...
...
@@ -89,6 +89,22 @@ class BuildPyTestCase(support.TempdirManager,
os
.
chdir
(
cwd
)
sys
.
stdout
=
sys
.
__stdout__
def
test_dont_write_bytecode
(
self
):
# makes sure byte_compile is not used
pkg_dir
,
dist
=
self
.
create_dist
()
cmd
=
build_py
(
dist
)
cmd
.
compile
=
1
cmd
.
optimize
=
1
old_dont_write_bytecode
=
sys
.
dont_write_bytecode
sys
.
dont_write_bytecode
=
True
try
:
cmd
.
byte_compile
([])
finally
:
sys
.
dont_write_bytecode
=
old_dont_write_bytecode
self
.
assertTrue
(
'byte-compile not supported '
in
self
.
logs
[
0
][
1
])
def
test_suite
():
return
unittest
.
makeSuite
(
BuildPyTestCase
)
...
...
tests/test_install_lib.py
View file @
9e0e2af9
...
...
@@ -31,6 +31,8 @@ class InstallLibTestCase(support.TempdirManager,
cmd
.
finalize_options
()
self
.
assertEquals
(
cmd
.
optimize
,
2
)
@
unittest
.
skipUnless
(
not
sys
.
dont_write_bytecode
,
'byte-compile not supported'
)
def
test_byte_compile
(
self
):
pkg_dir
,
dist
=
self
.
create_dist
()
cmd
=
install_lib
(
dist
)
...
...
@@ -76,6 +78,21 @@ class InstallLibTestCase(support.TempdirManager,
# get_input should return 2 elements
self
.
assertEquals
(
len
(
cmd
.
get_inputs
()),
2
)
def
test_dont_write_bytecode
(
self
):
# makes sure byte_compile is not used
pkg_dir
,
dist
=
self
.
create_dist
()
cmd
=
install_lib
(
dist
)
cmd
.
compile
=
1
cmd
.
optimize
=
1
old_dont_write_bytecode
=
sys
.
dont_write_bytecode
sys
.
dont_write_bytecode
=
True
try
:
cmd
.
byte_compile
([])
finally
:
sys
.
dont_write_bytecode
=
old_dont_write_bytecode
self
.
assertTrue
(
'byte-compile not supported '
in
self
.
logs
[
0
][
1
])
def
test_suite
():
return
unittest
.
makeSuite
(
InstallLibTestCase
)
...
...
tests/test_util.py
View file @
9e0e2af9
"""Tests for distutils.util."""
# not covered yet:
# - byte_compile
#
import
os
import
sys
import
unittest
...
...
@@ -9,11 +6,12 @@ from copy import copy
from
StringIO
import
StringIO
import
subprocess
from
distutils.errors
import
DistutilsPlatformError
from
distutils.errors
import
DistutilsPlatformError
,
DistutilsByteCompileError
from
distutils.util
import
(
get_platform
,
convert_path
,
change_root
,
check_environ
,
split_quoted
,
strtobool
,
rfc822_escape
,
get_compiler_versions
,
_find_exe_version
,
_MAC_OS_X_LD_VERSION
)
_find_exe_version
,
_MAC_OS_X_LD_VERSION
,
byte_compile
)
from
distutils
import
util
from
distutils.sysconfig
import
get_config_vars
from
distutils
import
sysconfig
...
...
@@ -349,6 +347,16 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
res
=
get_compiler_versions
()
self
.
assertEquals
(
res
[
2
],
None
)
def
test_dont_write_bytecode
(
self
):
# makes sure byte_compile raise a DistutilsError
# if sys.dont_write_bytecode is True
old_dont_write_bytecode
=
sys
.
dont_write_bytecode
sys
.
dont_write_bytecode
=
True
try
:
self
.
assertRaises
(
DistutilsByteCompileError
,
byte_compile
,
[])
finally
:
sys
.
dont_write_bytecode
=
False
def
test_suite
():
return
unittest
.
makeSuite
(
UtilTestCase
)
...
...
util.py
View file @
9e0e2af9
...
...
@@ -13,6 +13,7 @@ from distutils.dep_util import newer
from
distutils.spawn
import
spawn
,
find_executable
from
distutils
import
log
from
distutils.version
import
LooseVersion
from
distutils.errors
import
DistutilsByteCompileError
def
get_platform
():
"""Return a string that identifies the current platform.
...
...
@@ -445,6 +446,10 @@ def byte_compile(py_files, optimize=0, force=0, prefix=None, base_dir=None,
generated
in
indirect
mode
;
unless
you
know
what
you
're doing, leave
it set to None.
"""
# nothing is done if sys.dont_write_bytecode is True
if sys.dont_write_bytecode:
raise DistutilsByteCompileError('
byte
-
compiling
not
supported
.
')
# First, if the caller didn'
t
force
us
into
direct
or
indirect
mode
,
# figure out which mode we should be in. We take a conservative
# approach: choose direct mode *only* if the current interpreter is
...
...
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