Commit 3a3debc7 authored by Romain Casati's avatar Romain Casati

Cache busting using version number.

parent 13c175c3
Pipeline #399832 passed with stage
in 2 minutes and 59 seconds
......@@ -3,12 +3,23 @@ from setuptools import setup, find_packages
from pathlib import Path
import shutil
import sys
import re
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'))
# get version number from basthon.js
basthonjs = root_dir / "src" / "basthon-js" / "basthon.js"
# trick to get version at wheel build (build is done in /tmp/...)
if not basthonjs.exists():
basthonjs = this_dir / "basthon-kernel" / "data" / "basthon.js"
# version number from basthon.js using regex
with open(basthonjs) as f:
BASTHON_KERNEL_VERSION = re.search(
"that.version = \"(?P<version>.*)\";", f.read()).group('version')
# make sure we have a version number
assert BASTHON_KERNEL_VERSION
with open("README.md") as f:
LONG_DESCRIPTION = f.read()
......@@ -16,6 +27,12 @@ with open("README.md") as f:
command = sys.argv[1]
if command == "sdist":
# use version number for cache busting
src_dest = ((root_dir / "src" / "basthon-js", '.'),
(root_dir / "src" / "basthon-py" / "build", Path(BASTHON_KERNEL_VERSION) / "basthon-py"),
(root_dir / "src" / "modules", Path(BASTHON_KERNEL_VERSION) / "modules"))
# before creating the distribution, copy files from other locations in
# the repository
print("copying files...")
......@@ -30,13 +47,13 @@ if command == "sdist":
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)
dst.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(path, dst)
setup(
name='basthon-kernel',
version='0.15.6',
version=BASTHON_KERNEL_VERSION,
description=('Basthon-kernel is used in Basthon Notebook'
' and Basthon Console projects to provide '
'Python interpreter in the browser.'),
......@@ -78,7 +95,7 @@ setup(
keywords='Python browser',
package_data={
'basthon-kernel': ['data/*.*', 'data/*/*.*']
'basthon-kernel': ['data/*.*', 'data/*/*.*', 'data/*/*/*.*']
},
......
......@@ -14,6 +14,14 @@
let that = {};
/**
* Version number (entry point for setup.py and publication to PyPi).
*
* /!\ Warning: edit this line with care since it is parsed by
* setup.py to get version number.
*/
that.version = "0.15.7";
/**
* Where to find pyodide.js (private).
*/
......@@ -45,8 +53,9 @@
/**
* Get the URL of Basthon kernel root dir.
* Root path contains version number for cache busting.
*/
that.basthonRoot = that.dirname(that.urlScript);
that.basthonRoot = that.dirname(that.urlScript) + "/" + that.version;
/**
* Get the URL of Basthon modules dir.
......
Markdown is supported
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