Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Basthon
Basthon Kernel
Commits
3cd92445
Commit
3cd92445
authored
Jan 26, 2021
by
Romain Casati
Browse files
Use of pathlib in setup.py instead of os.path.
parent
cb959f9b
Changes
1
Hide whitespace changes
Inline
Side-by-side
setup/setup.py
View file @
3cd92445
from
setuptools
import
setup
,
find_packages
import
os
from
pathlib
import
Path
import
shutil
import
sys
this_dir
=
os
.
get
cwd
()
root_dir
=
os
.
path
.
dirname
(
this_dir
)
src_dest
=
((
os
.
path
.
join
(
root_dir
,
"src"
,
"basthon-js"
)
,
'.'
),
(
os
.
path
.
join
(
root_dir
,
"src"
,
"basthon-py"
,
"build"
)
,
'basthon-py'
),
(
os
.
path
.
join
(
root_dir
,
"src"
,
"modules"
)
,
'modules'
))
this_dir
=
Path
.
cwd
()
root_dir
=
this_dir
.
parent
src_dest
=
((
root_dir
/
"src"
/
"basthon-js"
,
'.'
),
(
root_dir
/
"src"
/
"basthon-py"
/
"build"
,
'basthon-py'
),
(
root_dir
/
"src"
/
"modules"
,
'modules'
))
with
open
(
"README.md"
)
as
f
:
LONG_DESCRIPTION
=
f
.
read
()
...
...
@@ -19,21 +19,19 @@ if command == "sdist":
# before creating the distribution, copy files from other locations in
# the repository
print
(
"copying files..."
)
basthon_dir
=
os
.
path
.
join
(
this_dir
,
"basthon-kernel"
)
data_dir
=
os
.
path
.
join
(
basthon_dir
,
"data"
)
basthon_dir
=
this_dir
/
"basthon-kernel"
data_dir
=
basthon_dir
/
"data"
# copy files from basthon into data_dir
content
=
[]
for
src
,
dest
in
src_dest
:
for
root
,
dirs
,
files
in
os
.
walk
(
src
):
exts
=
(
'.js'
,
'.map'
,
'.data'
)
if
root
==
src
else
(
'.whl'
,)
content
+=
[(
os
.
path
.
join
(
root
,
f
),
dest
)
for
f
in
files
if
os
.
path
.
splitext
(
f
)[
1
]
in
exts
]
for
fname
,
dest
in
content
:
dest
=
os
.
path
.
join
(
data_dir
,
dest
,
os
.
path
.
basename
(
fname
))
os
.
makedirs
(
os
.
path
.
dirname
(
dest
),
exist_ok
=
True
)
shutil
.
copyfile
(
fname
,
dest
)
for
path
in
src
.
rglob
(
"*"
):
exts
=
(
'.js'
,
'.map'
,
'.data'
)
if
path
.
parent
==
src
else
(
'.whl'
,)
if
path
.
is_file
()
and
path
.
suffix
in
exts
:
dst
=
data_dir
/
dest
/
path
.
name
dst
.
parent
.
mkdir
(
exist_ok
=
True
)
shutil
.
copyfile
(
path
,
dst
)
setup
(
name
=
'basthon-kernel'
,
...
...
Write
Preview
Supports
Markdown
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