Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New pip installation #239

Closed
wants to merge 12 commits into from
14 changes: 14 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: sharpy
channels:
- conda-forge
- defaults
dependencies:
- eigen
- libopenblas
- libblas
- libcblas
- liblapack
- libgfortran
- libgcc
- libgfortran-ng
- python=3.10
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",
#"scikit-build>=0.13",
"cmake>=3.14.3"
]
134 changes: 132 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,98 @@
from setuptools import setup, find_packages
from setuptools import setup, find_packages, Extension, Command
#from skbuild import setup
from setuptools.command.build_ext import build_ext
import subprocess

import re
import os

class CMakeBuildExt(build_ext):
"""Custom command to build Submodules packages during installation."""

# def copy_extensions_to_source(self):
# "Override the method to prevent copying package files"
# pass

def finalize_options(self):
super().finalize_options()
# Process and use os.environ['CUSTOM_CONFIG_SETTINGS'] as needed
self.pip_nobuild = os.environ.get('PIP_NOBUILD')

def run(self):

package_dir = os.path.dirname(os.path.abspath(__file__))
build_dir = package_dir + "/build"
cmake_args = []
if self.pip_nobuild=="yes":
pass
else:
if not os.path.isdir(build_dir):
os.makedirs(build_dir)
subprocess.check_call(
["cmake", ".."] + cmake_args, cwd=build_dir
)
subprocess.check_call(
["make", "install", "-j4"], cwd=build_dir
)

super().run()

def run():

pip_nobuild = os.environ.get('PIP_NOBUILD')
package_dir = os.path.dirname(os.path.abspath(__file__))
build_dir = package_dir + "/build"
cmake_args = []
if pip_nobuild=="yes":
pass
else:
if not os.path.isdir(build_dir):
os.makedirs(build_dir)
subprocess.check_call(
["cmake", ".."] + cmake_args, cwd=build_dir
)
subprocess.check_call(
["make", "install", "-j4"], cwd=build_dir
)

class BuildCommand(Command):
"""Custom command to build Submodules packages without installation."""

description = 'Build Submodules in lib packages'
user_options = [
('cmake-args=', None, 'Additional CMake arguments'),
]

def initialize_options(self):
self.cmake_args = None

def finalize_options(self):
pass

def run(self):
# Run the CMake build step with additional cmake_args
package_dir = os.path.dirname(os.path.abspath(__file__))
build_dir = package_dir + "/build"
if not os.path.isdir(build_dir):
os.makedirs(build_dir)
if self.cmake_args is not None:
subprocess.check_call(
["cmake", f"{self.cmake_args}", ".."], cwd=build_dir
)
else:
subprocess.check_call(
["cmake", ".."], cwd=build_dir
)

subprocess.check_call(
["make", "install", "-j4"], cwd=build_dir
)

ext_modules = [
Extension('lib', []),
# Add more Extension instances for additional extension modules
]

this_directory = os.path.abspath(os.path.dirname(__file__))
__version__ = re.findall(
r"""__version__ = ["']+([0-9\.]*)["']+""",
Expand All @@ -10,7 +101,7 @@

with open(os.path.join(this_directory, "README.md"), encoding="utf-8") as f:
long_description = f.read()

run()
setup(
name="sharpy",
version=__version__,
Expand All @@ -25,13 +116,52 @@
author_email="",
url="https://github.com/ImperialCollegeLondon/sharpy",
license="BSD 3-Clause License",
#ext_modules=ext_modules,
cmdclass={#"build_ext": CMakeBuildExt,
"build_subm": BuildCommand},
packages=find_packages(
where='./',
include=['sharpy*'],
exclude=['tests']
),
# data_files=[
# ("./lib/UVLM/lib", ["libuvlm.so"]),
# ("./lib/xbeam/lib", ["libxbeam.so"])
# ],
python_requires=">=3.8",
install_requires=[
"numpy",
"configobj",
"h5py",
"scipy",
"sympy",
"matplotlib",
"colorama",
"dill",
"jupyterlab",
"mayavi", #tvtk
"pandas",
"control",
# For pandas excel reader.
"openpyxl>=3.0.10",
"lxml>=4.4.1",
"PySocks",
"PyYAML"
],
extras_require={
"docs": [
"sphinx",
"recommonmark>=0.6.0",
"sphinx_rtd_theme>=0.4.3",
"nbsphinx>=0.4.3"
],
"all": [
"sphinx",
"recommonmark>=0.6.0",
"sphinx_rtd_theme>=0.4.3",
"nbsphinx>=0.4.3"
],
},
classifiers=[
"Operating System :: Linux, Mac OS",
"Programming Language :: Python, C++",
Expand Down
Loading