Add a command for generating dataverse data file
+from distutils.cmd import Command
from setuptools import setup, find_packages
import sys
import versioneer
@@ -8,6 +9,35 @@ else:
with open("README.md", encoding="utf8") as f:
readme = f.read()
+
+class GenerateDataverseInstallationsFileCommand(Command):
+ description = "Generate Dataverse installations data map"
+ user_options = []
+
+ def initialize_options(self):
+ self.url = (
+ "https://services.dataverse.harvard.edu/miniverse/map/installations-json"
+ )
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ from urllib.request import urlopen
+ import json
+
+ resp = urlopen(self.url, timeout=5)
+ resp_body = resp.read()
+ data = json.loads(resp_body.decode("utf-8"))
+ if "installations" not in data:
+ raise ValueError("Malformed installation map.")
+ with open("repo2docker/contentproviders/dataverse.json", "wb") as fp:
+ fp.write(resp_body)
+
+
+__cmdclass = versioneer.get_cmdclass()
+__cmdclass["generate_dataverse_file"] = GenerateDataverseInstallationsFileCommand
+
setup(
name="jupyter-repo2docker",
version=versioneer.get_version(),
@@ -48,7 +78,7 @@ setup(
],
packages=find_packages(),
include_package_data=True,
- cmdclass=versioneer.get_cmdclass(),
+ cmdclass=__cmdclass,
entry_points={
"console_scripts": [
"jupyter-repo2docker = repo2docker.__main__:main",
