Skip to content

Commit

Permalink
Allow to build without distutils
Browse files Browse the repository at this point in the history
Closes #203
  • Loading branch information
jschueller committed Jun 25, 2024
1 parent 8c018ef commit 68be80e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

--- PyFMI-2.13.1 ---
* Numpy 2.x support
* Allow to build without distutils for Python>=3.12 support

--- PyFMI-2.13.0 ---
* Upgraded to Cython3.
Expand Down
18 changes: 10 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import distutils
import os
import shutil
import numpy as np
import ctypes.util
import sys

#If prefix is set, we want to allow installation in a directory that is not on PYTHONPATH
#and this is only possible with distutils, not setuptools
if str(sys.argv[1:]).find("--prefix") == -1:
from setuptools import setup
else:
from distutils.core import setup
try:
from numpy.distutils.core import setup
have_nd = True
except ImportError:
from setuptools import setup
have_nd = False

try:
from Cython.Distutils import build_ext
Expand Down Expand Up @@ -114,6 +113,8 @@
# Fix path sep
for x in sys.argv[1:]:
if not x.find('--prefix'):
if not have_nd:
raise Exception("Cannot specify --prefix without numpy.distutils")
copy_args[copy_args.index(x)] = x.replace('/',os.sep)
if not x.find('--fmil-home'):
incdirs = os.path.join(x[12:],'include')
Expand All @@ -136,6 +137,8 @@
copy_args.remove(x)
if not x.find('--no-msvcr'):
if x[11:].upper() == "TRUE":
if not have_nd:
raise Exception("Cannot specify --no-msvcr without numpy.distutils")
no_msvcr = True
copy_args.remove(x)
if not x.find('--extra-c-flags'):
Expand Down Expand Up @@ -308,7 +311,6 @@ def check_extensions():
extra_package_data = ['*fmilib_shared*'] if sys.platform.startswith("win") else []
extra_package_data += ['libgcc_s_dw2-1.dll'] if copy_gcc_lib else []

from numpy.distutils.core import setup
setup(name=NAME,
version=VERSION,
license=LICENSE,
Expand Down

0 comments on commit 68be80e

Please sign in to comment.