Commit 3cd92445 authored by Romain Casati's avatar Romain Casati
Browse files

Use of pathlib in instead of os.path.

parent cb959f9b
from setuptools import setup, find_packages
import os
from pathlib import Path
import shutil
import sys
this_dir = os.getcwd()
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("") as f:
......@@ -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 /
shutil.copyfile(path, dst)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment