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

Pip installation #45

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# CSXCAD python interface

## Install
If openEMS was installed into `~/opt/openEMS`, then install this package with:

1. Set the environment variable `OPENEMS_INSTALL_PATH` to point to the installation of openEMS, for example in Linux:
```bash
python setup.py build_ext -I ~/opt/openEMS/include -L ~/opt/openEMS/lib -R ~/opt/openEMS/lib
python setup.py install
export OPENEMS_INSTALL_PATH="/this/is/where/I/installed/openEMS"
```

Otherwise, replace `~/opt/openEMS` with the path to the place where it was installed.
2. Run
```bash
pip install /path/to/the/folder/where/this/README.md/is
```
33 changes: 33 additions & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[project]
name = 'CSXCAD'
version = '0.6.2'
description = "Python interface for the CSXCAD library"
classifiers = [
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)',
'Programming Language :: Python',
'Topic :: Scientific/Engineering',
'Topic :: Software Development :: Libraries :: Python Modules',
'Operating System :: POSIX :: Linux',
'Operating System :: Microsoft :: Windows',
]
authors = [
{name = 'Thorsten Liebig', email = '[email protected]'}
]
maintainers = [
{name = 'Thorsten Liebig', email = '[email protected]'}
]
dependencies = [
'numpy'
]

[project.urls]
Documentation = 'https://openEMS.de'
Source = 'https://github.com/thliebig/CSXCAD/tree/master/python'

[build-system]
requires = ['setuptools','Cython']
build-backend = 'setuptools.build_meta'
60 changes: 32 additions & 28 deletions python/setup.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
from setuptools import Extension, setup
from Cython.Build import cythonize

from pathlib import Path
import os

def looks_like_openEMS_is_installed_there(path_to_some_folder:Path):
path_to_some_folder = Path(path_to_some_folder)
FILES_THAT_SHOULD_EXIST = [
path_to_some_folder/'bin/openEMS',
path_to_some_folder/'include/openEMS/openems.h',
]
if any([not p.is_file() for p in FILES_THAT_SHOULD_EXIST]):
return False
return True

if 'OPENEMS_INSTALL_PATH' not in os.environ:
raise SystemExit('Please set the environment variable OPENEMS_INSTALL_PATH to point to where openEMS was installed. ')

path_to_openEMS_installation = Path(os.environ['OPENEMS_INSTALL_PATH']) # Environment variables are always strings, so this should never raise any error.

if not looks_like_openEMS_is_installed_there(path_to_openEMS_installation):
raise SystemExit(f'I was expecting to find openEMS installed in {path_to_openEMS_installation}, but it does not look like it is installed there. ')

extensions = [
Extension("*", [os.path.join(os.path.dirname(__file__), "CSXCAD","*.pyx")],
language="c++", # generate C++ code
libraries = ['CSXCAD',]),
Extension(
'*',
['CSXCAD/*.pyx'],
include_dirs = [str(path_to_openEMS_installation/'include')],
library_dirs = [str(path_to_openEMS_installation/'lib')],
runtime_library_dirs = [str(path_to_openEMS_installation/'lib')],
language = 'c++',
libraries = ['CSXCAD'],
)
]

setup(
name="CSXCAD",
version = '0.6.2',
description = "Python interface for the CSXCAD library",
classifiers = [
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)',
'Programming Language :: Python',
'Topic :: Scientific/Engineering',
'Topic :: Software Development :: Libraries :: Python Modules',
'Operating System :: POSIX :: Linux',
'Operating System :: Microsoft :: Windows',
],
author = 'Thorsten Liebig',
author_email = '[email protected]',
maintainer = 'Thorsten Liebig',
maintainer_email = '[email protected]',
url = 'https://openEMS.de',
packages=["CSXCAD", ],
package_data={'CSXCAD': ['*.pxd']},
ext_modules = cythonize(extensions, language_level=3)
)
packages = ['CSXCAD'],
ext_modules = cythonize(extensions),
)