Skip to content

Commit

Permalink
working on fixing #1330
Browse files Browse the repository at this point in the history
  • Loading branch information
timkpaine authored and texodus committed Apr 2, 2021
1 parent b13a206 commit 31ca47b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,12 @@ junit.xml
python/perspective/python_junit.xml
python/perspective/coverage.xml
python/perspective/bench/stresstest/results
python/perspective/perspective/labextension
rust/perspective-view/target
rust/perspective-view/pkg
rust/perspective-view/target2
rust/perspective-vieux/pkg

rust/perspective-vieux/target
rust/perspective-vieux/target2
.emsdk
.emsdk
5 changes: 5 additions & 0 deletions python/perspective/install.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"packageManager": "python",
"packageName": "perspective-python",
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package perspective-python"
}
2 changes: 1 addition & 1 deletion python/perspective/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools", "wheel", "backports.shutil_which ; python_version <'3'", "numpy>=1.13.1"]
requires = ["setuptools", "wheel", "jupyter_packaging", "backports.shutil_which ; python_version <'3'", "numpy>=1.13.1"]
62 changes: 41 additions & 21 deletions python/perspective/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
#
from __future__ import print_function

import io
from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext
from setuptools.command.sdist import sdist
from distutils.version import LooseVersion
from codecs import open
from jupyter_packaging import create_cmdclass, get_version, combine_commands, ensure_targets

import os
import os.path
import platform
import re
import subprocess
import sys
from codecs import open
from distutils.version import LooseVersion

from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext
from setuptools.command.sdist import sdist

try:
from shutil import which
Expand Down Expand Up @@ -67,7 +67,6 @@ def which(x):
"flake8>=3.7.8",
"mock",
"pybind11>=2.4.0",
"pyarrow>=0.16.0",
"pytest>=4.3.0",
"pytest-cov>=2.6.1",
"pytest-check-links",
Expand All @@ -84,20 +83,8 @@ def which(x):
] + requires_dev_py2 # for development, remember to install black and flake8-black


def get_version(file, name="__version__"):
"""Get the version of the package from the given file by
executing it and extracting the given `name`.
"""
path = os.path.realpath(file)
version_ns = {}
with io.open(path, encoding="utf8") as f:
exec(f.read(), {}, version_ns)
return version_ns[name]


version = get_version(os.path.join(here, "perspective", "core", "_version.py"))


class PSPExtension(Extension):
def __init__(self, name, sourcedir="dist"):
Extension.__init__(self, name, sources=[])
Expand Down Expand Up @@ -233,7 +220,40 @@ def run_check(self):
path
)
)
for dir in ("labextension",):
path = os.path.abspath(os.path.join(here, "perspective", dir))
if not os.path.exists(path):
raise Exception(
"Path is missing! {}\nMust run `yarn build` before building sdist so js files are installed".format(
path
)
)


lab_path = os.path.join(here, "perspective", "labextension")

package_data_spec = {"perspective": ["labextension/*.tgz"]}

data_files_spec = [
("share/jupyter/labextensions", lab_path, "*.tgz"),
("share/jupyter/labextensions", lab_path, "install.json"),
]

jstargets = [
os.path.join(here, "perspective", "labextension"), # TODO this should match ipyregulartable, for example
]

cmdclass = create_cmdclass(
"jsdeps", package_data_spec=package_data_spec, data_files_spec=data_files_spec
)

cmdclass["jsdeps"] = combine_commands(
# install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), # TODO skip_if_exists(jstargets, js_command)
ensure_targets(jstargets),
)

cmdclass["build_ext"] = PSPBuild
cmdclass["sdist"] = PSPCheckSDist

setup(
name="perspective-python",
Expand Down Expand Up @@ -261,5 +281,5 @@ def run_check(self):
install_requires=requires,
extras_require={"dev": requires_dev, "devpy2": requires_dev_py2},
ext_modules=[PSPExtension("perspective")],
cmdclass=dict(build_ext=PSPBuild, sdist=PSPCheckSDist),
cmdclass=cmdclass,
)

0 comments on commit 31ca47b

Please sign in to comment.