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
26cbce17
Commit
26cbce17
authored
Nov 09, 2017
by
Jason R. Coombs
Committed by
GitHub
Nov 09, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1145 from haobibo/master
python 3 bdist_egg --exclude-source-files __pycache__ issue
parents
ff9bc490
4216b5f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
3 deletions
+40
-3
CHANGES.rst
CHANGES.rst
+3
-0
setuptools/command/bdist_egg.py
setuptools/command/bdist_egg.py
+17
-1
setuptools/tests/test_bdist_egg.py
setuptools/tests/test_bdist_egg.py
+20
-2
No files found.
CHANGES.rst
View file @
26cbce17
...
@@ -4,6 +4,9 @@ v36.6.1
...
@@ -4,6 +4,9 @@ v36.6.1
*
#
1132
:
Removed
redundant
and
costly
serialization
/
parsing
step
*
#
1132
:
Removed
redundant
and
costly
serialization
/
parsing
step
in
``
EntryPoint
.
__init__
``.
in
``
EntryPoint
.
__init__
``.
*
#
844
:
``
bdist_egg
--
exclude
-
source
-
files
``
now
tested
and
works
on
Python
3.
v36
.6.0
v36
.6.0
-------
-------
...
...
setuptools/command/bdist_egg.py
View file @
26cbce17
...
@@ -8,6 +8,7 @@ from distutils import log
...
@@ -8,6 +8,7 @@ from distutils import log
from
types
import
CodeType
from
types
import
CodeType
import
sys
import
sys
import
os
import
os
import
re
import
textwrap
import
textwrap
import
marshal
import
marshal
...
@@ -240,11 +241,26 @@ class bdist_egg(Command):
...
@@ -240,11 +241,26 @@ class bdist_egg(Command):
log
.
info
(
"Removing .py files from temporary directory"
)
log
.
info
(
"Removing .py files from temporary directory"
)
for
base
,
dirs
,
files
in
walk_egg
(
self
.
bdist_dir
):
for
base
,
dirs
,
files
in
walk_egg
(
self
.
bdist_dir
):
for
name
in
files
:
for
name
in
files
:
path
=
os
.
path
.
join
(
base
,
name
)
if
name
.
endswith
(
'.py'
):
if
name
.
endswith
(
'.py'
):
path
=
os
.
path
.
join
(
base
,
name
)
log
.
debug
(
"Deleting %s"
,
path
)
log
.
debug
(
"Deleting %s"
,
path
)
os
.
unlink
(
path
)
os
.
unlink
(
path
)
if
base
.
endswith
(
'__pycache__'
):
path_old
=
path
pattern
=
r'(?P<name>.+)\
.(?P<m
agic>[^.]+)\
.pyc
'
m = re.match(pattern, name)
path_new = os.path.join(base, os.pardir, m.group('
name
') + '
.
pyc
')
log.info("Renaming file from [%s] to [%s]" % (path_old, path_new))
try:
os.remove(path_new)
except OSError:
pass
os.rename(path_old, path_new)
def zip_safe(self):
def zip_safe(self):
safe = getattr(self.distribution, '
zip_safe
', None)
safe = getattr(self.distribution, '
zip_safe
', None)
if safe is not None:
if safe is not None:
...
...
setuptools/tests/test_bdist_egg.py
View file @
26cbce17
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
"""
"""
import
os
import
os
import
re
import
re
import
zipfile
import
pytest
import
pytest
...
@@ -16,7 +17,7 @@ setup(name='foo', py_modules=['hi'])
...
@@ -16,7 +17,7 @@ setup(name='foo', py_modules=['hi'])
"""
"""
@
pytest
.
yield_fixture
@
pytest
.
fixture
(
scope
=
'function'
)
def
setup_context
(
tmpdir
):
def
setup_context
(
tmpdir
):
with
(
tmpdir
/
'setup.py'
).
open
(
'w'
)
as
f
:
with
(
tmpdir
/
'setup.py'
).
open
(
'w'
)
as
f
:
f
.
write
(
SETUP_PY
)
f
.
write
(
SETUP_PY
)
...
@@ -32,7 +33,7 @@ class Test:
...
@@ -32,7 +33,7 @@ class Test:
script_name
=
'setup.py'
,
script_name
=
'setup.py'
,
script_args
=
[
'bdist_egg'
],
script_args
=
[
'bdist_egg'
],
name
=
'foo'
,
name
=
'foo'
,
py_modules
=
[
'hi'
]
py_modules
=
[
'hi'
]
,
))
))
os
.
makedirs
(
os
.
path
.
join
(
'build'
,
'src'
))
os
.
makedirs
(
os
.
path
.
join
(
'build'
,
'src'
))
with
contexts
.
quiet
():
with
contexts
.
quiet
():
...
@@ -42,3 +43,20 @@ class Test:
...
@@ -42,3 +43,20 @@ class Test:
# let's see if we got our egg link at the right place
# let's see if we got our egg link at the right place
[
content
]
=
os
.
listdir
(
'dist'
)
[
content
]
=
os
.
listdir
(
'dist'
)
assert
re
.
match
(
r'foo-0.0.0-py[23].\
d.egg$
', content)
assert
re
.
match
(
r'foo-0.0.0-py[23].\
d.egg$
', content)
def test_exclude_source_files(self, setup_context, user_override):
dist = Distribution(dict(
script_name='
setup
.
py
',
script_args=['
bdist_egg
', '
--
exclude
-
source
-
files
'],
name='
foo
',
py_modules=['
hi
'],
))
with contexts.quiet():
dist.parse_command_line()
dist.run_commands()
[dist_name] = os.listdir('
dist
')
dist_filename = os.path.join('
dist
', dist_name)
zip = zipfile.ZipFile(dist_filename)
names = list(zi.filename for zi in zip.filelist)
assert '
hi
.
pyc
' in names
assert '
hi
.
py
' not in names
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