Skip to content

Commit

Permalink
Merge pull request #209 from SciGaP/py311-pip-install-support
Browse files Browse the repository at this point in the history
Add support for building JS code when installed with pip
  • Loading branch information
machristie authored Sep 28, 2023
2 parents 63fbb37 + 9fa63e8 commit fe9fcd8
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 50 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
recursive-include simccs_maptool/static *
recursive-include simccs_maptool/templates *
recursive-include simccs_maptool/simccs *
recursive-include frontend *
recursive-exclude frontend/node_modules *
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
26 changes: 26 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,28 @@
[metadata]
name = simccs-maptool
version = 0.0.1
description = SimCCS MapTool plugin to Airavata Django Portal

[options]
packages = find:
# Include data files as specified in MANIFEST.in
include_package_data = True
install_requires =
django >= 3.2
cython
pyjnius
pyshp
airavata-django-portal-sdk
djangorestframework
# Pandas 1.2 requires Python 3.7+ and we need less than 1.2 until we drop 3.6 support
pandas < 1.2
geopandas

[options.entry_points]
airavata.djangoapp =
simccs_maptool = simccs_maptool.apps:MapToolConfig
airavata.output_view_providers =
cplex-solution-link = simccs_maptool.output_views:SolutionLinkProvider

[flake8]
max-line-length = 88
100 changes: 50 additions & 50 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
import distutils
import logging
import os
import subprocess

import setuptools
from setuptools.command.develop import develop
from setuptools.command.install import install


def build_js():
subprocess.check_call(["yarn", "install"], cwd=os.path.join(os.getcwd(), "frontend"))
subprocess.check_call(["yarn", "run", "build"], cwd=os.path.join(os.getcwd(), "frontend"))


# Build JS code when this package is installed in virtual env
# https://stackoverflow.com/a/36902139
class BuildJSDevelopCommand(develop):
def run(self):
self.announce("Building JS code", level=distutils.log.INFO)
build_js()
super().run()


class BuildJSInstallCommand(install):
def run(self):
self.announce("Building JS code", level=distutils.log.INFO)
build_js()
super().run()


setuptools.setup(
name="simccs-maptool",
version="0.0.1",
description="SimCCS MapTool plugin to Airavata Django Portal",
packages=setuptools.find_packages(),
include_package_data=True,
install_requires=[
'django>=1.11.16',
'cython',
'pyjnius',
'pyshp',
"airavata-django-portal-sdk",
'djangorestframework',
# Pandas 1.2 requires Python 3.7+ and our deployments are currently on Python 3.6
'pandas<1.2',
'geopandas'
],
entry_points="""
[airavata.djangoapp]
simccs_maptool = simccs_maptool.apps:MapToolConfig
[airavata.output_view_providers]
cplex-solution-link = simccs_maptool.output_views:SolutionLinkProvider
""",
cmdclass={
'develop': BuildJSDevelopCommand,
'install': BuildJSInstallCommand,
}
)
subprocess.check_call(["yarn", "install"],
cwd=os.path.join(os.getcwd(), "frontend"))
subprocess.check_call(["yarn", "run", "build"],
cwd=os.path.join(os.getcwd(), "frontend"))


try:
from setuptools.command.build import build as _build
from setuptools.command.editable_wheel import \
editable_wheel as _editable_wheel

class build(_build):
def run(self) -> None:
self.announce("Building JS code", level=logging.INFO)
build_js()
super().run()

class editable_wheel(_editable_wheel):
def run(self) -> None:
self.announce("Building JS code", level=logging.INFO)
build_js()
super().run()

cmdclass = dict(build=build, editable_wheel=editable_wheel)

except ImportError:

# For older versions of setuptools (Python 3.6)
from setuptools.command.develop import develop as _develop
from setuptools.command.install import install as _install

# Build JS code when this package is installed in virtual env
# https://stackoverflow.com/a/36902139

class develop(_develop):
def run(self):
self.announce("Building JS code", level=distutils.log.INFO)
build_js()
super().run()

class install(_install):
def run(self):
self.announce("Building JS code", level=distutils.log.INFO)
build_js()
super().run()

cmdclass = dict(develop=develop, install=install)

setuptools.setup(cmdclass=cmdclass)

0 comments on commit fe9fcd8

Please sign in to comment.