Skip to content

Commit

Permalink
works with install for setuptools and pip, not develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sosey committed Mar 29, 2020
1 parent 878da59 commit 88de156
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
12 changes: 1 addition & 11 deletions example_notebooks/imexam_ginga_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@
"### If you are running with Python 3, ginga also requires that pillow be installed. You'll see a blank viewer popup in the html window if this is the case. You can \"conda install pillow\" and that should fix the problem.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#start the notebook: jupyter notebook\n",
"%matplotlib notebook"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -351,7 +341,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
"version": "3.7.3"
}
},
"nbformat": 4,
Expand Down
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ setup_requires =
packages =
imexam
install_requires =
numpy>=1.12
numpy>=1.14
astropy>=3.0
matplotlib

Expand All @@ -51,6 +51,8 @@ tests =
photometry =
photutils>=0.4

[build-system]
requires = ["cython"]

[build_sphinx]
source-dir = docs
Expand Down
28 changes: 24 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import importlib
from distutils.command.clean import clean
from distutils.command.install_lib import install_lib
from setuptools.command.install import install
from setuptools import setup, Command, Extension
from setuptools.command.test import test as TestCommand
Expand Down Expand Up @@ -64,8 +65,6 @@ def finalize_options(self):
BuildDoc.finalize_options(self)

def run(self):
# build_cmd = self.reinitialize_command('build_ext')
# self.run_command('build_ext')
retcode = build_main(['-W', '--keep-going', '-b', 'html', './docs', './docs/_build/html'])
if retcode != 0:
sys.exit(retcode)
Expand Down Expand Up @@ -166,6 +165,7 @@ def run(self):
if use_cython:
ext = cythonize(xpa_module)
current_env = sys.prefix

class my_clean(Command):
user_options = []

Expand Down Expand Up @@ -209,6 +209,8 @@ def run(self):
if os.access(myfile, os.F_OK):
print(f"removing {myfile}")
os.remove(myfile)
if os.access(XPA_LIBNAME+suffix_lib, os.F_OK):
os.remove(XPA_LIBNAME+suffix_lib)

clean.run(self)

Expand Down Expand Up @@ -242,6 +244,13 @@ def run(self):
exit(1)
install.run(self)

class MyInstallLib(install_lib):
def initialize_options(self):
super().initialize_options()
def finalize_options(self):
super().finalize_options()
def run(self):
install_lib.run(self)

class BuildExtWithConfigure(build_ext):
"""Configure, build, and install the aXe C code."""
Expand All @@ -253,12 +262,23 @@ def build_extensions(self):
super().build_extensions()

def run(self):
try:
check_call(["make", "-f", "Makefile", "clean"],cwd=XPALIB_DIR)
check_call(["sh", "./configure","--prefix="+current_env], cwd=XPALIB_DIR)
check_call(["make", "-f", "Makefile", "install"], cwd=XPALIB_DIR)
except CalledProcessError as e:
print(e)
exit(1)
build_ext.run(self)



cmdclass.update({'install' : InstallWithRemake,
'clean' : my_clean,
'build_ext' : BuildExtWithConfigure})
'develop': InstallWithRemake,
'build_ext' : BuildExtWithConfigure,
})

else:
ext = [xpa_module]

Expand All @@ -279,4 +299,4 @@ def run(self):
package_data=package_data,
package_dir={'': '.'},
ext_modules=ext,
)
)

0 comments on commit 88de156

Please sign in to comment.