Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
a4efe65b
Kaydet (Commit)
a4efe65b
authored
May 25, 2000
tarafından
Greg Ward
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Bastian Kleineidam: the "build_scripts" command.
üst
8d5881a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
+71
-0
build_scripts.py
Lib/distutils/command/build_scripts.py
+71
-0
No files found.
Lib/distutils/command/build_scripts.py
0 → 100644
Dosyayı görüntüle @
a4efe65b
"""distutils.command.build_scripts
Implements the Distutils 'build_scripts' command."""
# created 2000/05/23, Bastian Kleineidam
__revision__
=
"$Id$"
import
sys
,
os
,
re
from
distutils.core
import
Command
# check if Python is called on the first line with this expression
first_line_re
=
re
.
compile
(
r"^#!.+python(\s-\w+)*"
)
class
build_scripts
(
Command
):
description
=
"
\"
build
\"
scripts"
user_options
=
[
(
'build-dir='
,
'd'
,
"directory to
\"
build
\"
(copy) to"
),
(
'force'
,
'f'
,
"forcibly build everything (ignore file timestamps"
),
]
def
initialize_options
(
self
):
self
.
build_dir
=
None
self
.
scripts
=
None
self
.
force
=
None
self
.
outfiles
=
None
def
finalize_options
(
self
):
self
.
set_undefined_options
(
'build'
,
(
'build_scripts'
,
'build_dir'
),
(
'force'
,
'force'
))
self
.
scripts
=
self
.
distribution
.
scripts
def
run
(
self
):
if
not
self
.
scripts
:
return
self
.
_copy_files
()
self
.
_adjust_files
()
def
_copy_files
(
self
):
"""Copy all the scripts to the build dir"""
self
.
outfiles
=
[]
self
.
mkpath
(
self
.
build_dir
)
for
f
in
self
.
scripts
:
print
self
.
build_dir
if
self
.
copy_file
(
f
,
self
.
build_dir
):
self
.
outfiles
.
append
(
os
.
path
.
join
(
self
.
build_dir
,
f
))
def
_adjust_files
(
self
):
"""If the first line begins with #! and ends with python
replace it with the current python interpreter"""
for
f
in
self
.
outfiles
:
if
not
self
.
dry_run
:
data
=
open
(
f
,
"r"
)
.
readlines
()
if
not
data
:
self
.
warn
(
"
%
s is an empty file!"
%
f
)
continue
mo
=
first_line_re
.
match
(
data
[
0
])
if
mo
:
self
.
announce
(
"Adjusting first line of file
%
s"
%
f
)
data
[
0
]
=
"#!"
+
sys
.
executable
# add optional command line options
if
mo
.
group
(
1
):
data
[
0
]
=
data
[
0
]
+
mo
.
group
(
1
)
else
:
data
[
0
]
=
data
[
0
]
+
"
\n
"
open
(
f
,
"w"
)
.
writelines
(
data
)
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