Skip to content

Commit

Permalink
avoid direct distutils
Browse files Browse the repository at this point in the history
  • Loading branch information
mdavidsaver committed Dec 16, 2022
1 parent cefd192 commit 28d3b0b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
27 changes: 12 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@

from setuptools import Command, Distribution
from setuptools.command import install
from distutils.command import build

from setuptools_dso import Extension, setup, DSO, build_dso

from distutils import log


mydir = os.path.abspath(os.path.dirname(__file__))

Expand Down Expand Up @@ -76,17 +73,17 @@ def finalize_options(self):
)

def run(self):
log.info("In GetVersionError")
print("In GetVersionError")
self.mkpath(self.build_temp)
defs = {}
readmake(defs, 'configure', 'CONFIG_BASE_VERSION')
defs['EPICS_SITE_VERSION'] = 'pipi'

outfile = os.path.join(self.build_temp, 'epicsVersion.h')
if self.dry_run:
log.info("Would write %s", outfile)
print("Would write %s", outfile)
else:
log.info("Writing %s", outfile)
print("Writing %s", outfile)
with open(outfile, 'w') as F:
F.write("""
#ifndef INC_epicsVersion_H
Expand Down Expand Up @@ -119,9 +116,9 @@ def run(self):

outfile = os.path.join(self.build_temp, 'generated.c')
if self.dry_run:
log.info("Would write %s", outfile)
print("Would write %s", outfile)
else:
log.info("Writing %s", outfile)
print("Writing %s", outfile)
with open(outfile, 'w') as F:
F.write("""
#include <stddef.h>
Expand Down Expand Up @@ -157,7 +154,7 @@ def run(self):
defS.append(D)

if len(defM)==0 or len(defS)==0:
log.warn("Warning: generated error string table is empty!")
print("Warning: generated error string table is empty!")
# MSVC doesn't like zero length C arrays
# so give it something
defS.append({'macro':'S_generic', 'value':'1', 'desc':'placeholder'})
Expand All @@ -183,9 +180,9 @@ def run(self):

outfile = os.path.join(self.build_temp, 'epicsVCS.h')
if self.dry_run:
log.info("Would write %s", outfile)
print("Would write %s", outfile)
else:
log.info("Writing %s", outfile)
print("Writing %s", outfile)
with open(outfile, 'w') as F:
F.write("""
#ifndef EPICS_VCS_VERSION
Expand Down Expand Up @@ -214,12 +211,12 @@ def finalize_options(self):
)

def run(self):
log.info("In Expand")
print("In Expand")
for template, outname, files in self.distribution.x_expand or []:
template = os.path.normcase(template)

outname = os.path.join(self.build_temp, os.path.normcase(outname))
log.info("expand %s -> %s", template, outname)
print("expand %s -> %s", template, outname)

with open(template, 'r') as F:
tmpl = F.read()
Expand Down Expand Up @@ -257,7 +254,7 @@ def finalize_options(self):
def run(self):
for stem, outname in self.distribution.x_api_h or []:
outname = os.path.join(self.build_lib, 'epicscorelibs', 'include', os.path.basename(outname))
log.info('make %s -> %s', stem, outname)
print('make %s -> %s', stem, outname)
out = '''
#ifndef %(guard)s
#define %(guard)s
Expand Down Expand Up @@ -315,7 +312,7 @@ def finalize_options(self):
('build_temp', 'build_temp'),
)
def run(self):
log.info("In InstallHeaders")
print("In InstallHeaders")
for pkg, files in (self.distribution.x_headers or {}).items():
print("Install headers for", pkg)
pkgdir = os.path.join(*[self.build_lib]+pkg.split('.'))
Expand Down
5 changes: 2 additions & 3 deletions src/python/epicscorelibs/config.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""Host configuration information using EPICS names and build flags.
Patterned after distutils.sysconfig
Patterned after sysconfig
"""

from copy import deepcopy
import platform
import sysconfig
import distutils.sysconfig

__all__ = (
'get_config_var',
Expand All @@ -26,7 +25,7 @@ def _makeconf():
}[platform.system()]

# select epics CMPLR_CLASS
CC = sysconfig.get_config_var('CC') or distutils.sysconfig.get_config_var('CC')
CC = sysconfig.get_config_var('CC')
if CC is None and osname=='WIN32':
cmplrname = conf['CMPLR_CLASS'] = 'msvc'
elif CC is None:
Expand Down

0 comments on commit 28d3b0b

Please sign in to comment.