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
0ccb40aa
Commit
0ccb40aa
authored
Feb 09, 2014
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract 'archive_context' from _install and _build_egg
parent
4c7aacca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
26 deletions
+17
-26
ez_setup.py
ez_setup.py
+17
-26
No files found.
ez_setup.py
View file @
0ccb40aa
...
...
@@ -22,6 +22,7 @@ import optparse
import
subprocess
import
platform
import
textwrap
import
contextlib
from
distutils
import
log
...
...
@@ -40,21 +41,9 @@ def _python_cmd(*args):
args
=
(
sys
.
executable
,)
+
args
return
subprocess
.
call
(
args
)
==
0
def
_install
(
archive_filename
,
install_args
=
()):
# extracting the archive
tmpdir
=
tempfile
.
mkdtemp
()
log
.
warn
(
'Extracting in %s'
,
tmpdir
)
old_wd
=
os
.
getcwd
()
try
:
os
.
chdir
(
tmpdir
)
with
zipfile
.
ZipFile
(
archive_filename
)
as
archive
:
archive
.
extractall
()
# going in the directory
subdir
=
os
.
path
.
join
(
tmpdir
,
os
.
listdir
(
tmpdir
)[
0
])
os
.
chdir
(
subdir
)
log
.
warn
(
'Now working in %s'
,
subdir
)
def
_install
(
archive_filename
,
install_args
=
()):
with
archive_context
(
archive_filename
):
# installing
log
.
warn
(
'Installing Setuptools'
)
if
not
_python_cmd
(
'setup.py'
,
'install'
,
*
install_args
):
...
...
@@ -62,37 +51,39 @@ def _install(archive_filename, install_args=()):
log
.
warn
(
'See the error message above.'
)
# exitcode will be 2
return
2
finally
:
os
.
chdir
(
old_wd
)
shutil
.
rmtree
(
tmpdir
)
def
_build_egg
(
egg
,
archive_filename
,
to_dir
):
with
archive_context
(
archive_filename
):
# building an egg
log
.
warn
(
'Building a Setuptools egg in %s'
,
to_dir
)
_python_cmd
(
'setup.py'
,
'-q'
,
'bdist_egg'
,
'--dist-dir'
,
to_dir
)
# returning the result
log
.
warn
(
egg
)
if
not
os
.
path
.
exists
(
egg
):
raise
IOError
(
'Could not build the egg.'
)
@
contextlib
.
contextmanager
def
archive_context
(
filename
):
# extracting the archive
tmpdir
=
tempfile
.
mkdtemp
()
log
.
warn
(
'Extracting in %s'
,
tmpdir
)
old_wd
=
os
.
getcwd
()
try
:
os
.
chdir
(
tmpdir
)
with
zipfile
.
ZipFile
(
archive_
filename
)
as
archive
:
with
zipfile
.
ZipFile
(
filename
)
as
archive
:
archive
.
extractall
()
# going in the directory
subdir
=
os
.
path
.
join
(
tmpdir
,
os
.
listdir
(
tmpdir
)[
0
])
os
.
chdir
(
subdir
)
log
.
warn
(
'Now working in %s'
,
subdir
)
# building an egg
log
.
warn
(
'Building a Setuptools egg in %s'
,
to_dir
)
_python_cmd
(
'setup.py'
,
'-q'
,
'bdist_egg'
,
'--dist-dir'
,
to_dir
)
yield
finally
:
os
.
chdir
(
old_wd
)
shutil
.
rmtree
(
tmpdir
)
# returning the result
log
.
warn
(
egg
)
if
not
os
.
path
.
exists
(
egg
):
raise
IOError
(
'Could not build the egg.'
)
def
_do_download
(
version
,
download_base
,
to_dir
,
download_delay
):
...
...
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