-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #209 from SciGaP/py311-pip-install-support
Add support for building JS code when installed with pip
- Loading branch information
Showing
4 changed files
with
84 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |