Skip to content

Commit

Permalink
Stop using setuptools for build
Browse files Browse the repository at this point in the history
  • Loading branch information
citrus-it committed Nov 14, 2024
1 parent 02a5f6f commit fcfb8dc
Show file tree
Hide file tree
Showing 23 changed files with 693 additions and 2,034 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.intltool-merge-cache
.make.state
**/__pycache__
**/*.so
/packages
/proto
/src/brand/fmri_compare
Expand All @@ -17,8 +18,7 @@
/src/tests/.timing_history.txt
/src/tests/*.pyc
/src/tests/*/*.pyc
/src/cffi_src/_*
/src/cffi_src/64
/src/cffi_src/src
/src/tests/failures
/src/tests/failures.3*
src/pkg.egg-info/
33 changes: 16 additions & 17 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,33 @@ include Makefile.com

JOBS = 8

# These are artificial targets used to run actions against all current python
# versions (in PYVERSIONS). In rules the target python version can be picked
# up via $(@F).
PYTESTS = $(PYVERSIONS:%=runtest/%)
PYMODULES = $(PYVERSIONS:%=modules/%)
EXTMODULES = $(PYVERSIONS:%=extmodules/%)
TESTRESULTS = $(PYVERSIONS:%=testresults/%)

REQUIREMENTS = requirements.txt

TARGET = all
all := TARGET = all
install := TARGET = install
install-cmd := TARGET = install
clean := TARGET = clean
clobber := TARGET = clobber
check := TARGET = check
packages := TARGET = install
test := TARGET = install

SUBDIRS=brand util/mkcert man po svc web
SUBDIRS= cffi_src modules brand util man po svc web
brand: cffi_src modules util $(EXTMODULES)

all: $(SUBDIRS)

build: $(PYVERSIONS)
install: install-cmd $(SUBDIRS) $(EXTMODULES)

install: $(PYVERSIONS) .WAIT $(PYMODULES) .WAIT $(SUBDIRS)

clean: $(SUBDIRS) $(PYVERSIONS)
@cd pkg; pwd; make clean

clobber: $(SUBDIRS) $(PYVERSONS)
@cd pkg; pwd; make clobber
clean clobber: $(SUBDIRS) pkg

packages: install
@cd pkg; pwd; $(MAKE) $(TARGET) check \
Expand All @@ -78,17 +79,17 @@ baseline: _bandit
python$(PYVER) -m bandit -r -q -c tests/banditrc . \
-o tests/bandit-baseline.json -f json || true

$(SUBDIRS) cffi_src: FRC
$(SUBDIRS) pkg: FRC
@cd $@; pwd; $(MAKE) $(TARGET) CC=$(CC)

$(PYVERSIONS): FRC
python$@ setup.py $(TARGET)
install-cmd: FRC
$(MAKE) -f Makefile.cmd $(TARGET)

$(PYMODULES): FRC
$(EXTMODULES):
../tools/installmodules $(CODE_WS) $(ROOT) $(@F) \
$(TARGET) $(ROOTPKGLIB) core $(REQUIREMENTS)

$(PYTESTS): $(PYMODULES)
$(PYTESTS): $(EXTMODULES)
-pfexec python$(@F) tests/run.py -t -j $(JOBS)
-pfexec cp tests/failures.3 tests/failures.$(@F)
-pfexec cp tests/timing_info.txt tests/timing_info.$(@F)
Expand All @@ -100,5 +101,3 @@ $(TESTRESULTS): $(PYTESTS)

FRC:

.NO_PARALLEL: $(PYVERSIONS) $(PYTESTS)

65 changes: 65 additions & 0 deletions src/Makefile.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
#

include Makefile.com

BINS = \
pkg \
pkgdepend \
pkgrepo \
pkgdiff \
pkgfmt \
pkglint \
pkgmerge \
pkgmogrify \
pkgsurf \
pkgsend \
pkgrecv \
pkgsign

LIBS = \
pkg.depotd

TARGETS= $(BINS:%=$(ROOTUSRBIN)/%) $(LIBS:%=$(ROOTUSRLIB)/%)

$(ROOTUSRBIN)/pkg := SRC = client.py
$(ROOTUSRBIN)/pkgdepend := SRC = pkgdep.py
$(ROOTUSRBIN)/pkgrepo := SRC = pkgrepo.py
$(ROOTUSRBIN)/pkgdiff := SRC = util/publish/pkgdiff.py
$(ROOTUSRBIN)/pkgfmt := SRC = util/publish/pkgfmt.py
$(ROOTUSRBIN)/pkglint := SRC = util/publish/pkglint.py
$(ROOTUSRBIN)/pkgmerge := SRC = util/publish/pkgmerge.py
$(ROOTUSRBIN)/pkgmogrify := SRC = util/publish/pkgmogrify.py
$(ROOTUSRBIN)/pkgsurf := SRC = util/publish/pkgsurf.py
$(ROOTUSRBIN)/pkgsend := SRC = publish.py
$(ROOTUSRBIN)/pkgrecv := SRC = pull.py
$(ROOTUSRBIN)/pkgsign := SRC = sign.py
$(ROOTUSRLIB)/pkg.depotd := SRC = depot.py

all clean clobber:

install: $(TARGETS)
python$(PYVER) $(PYCOMPILE_OPTS) $(TARGETS)

$(TARGETS): FRC
$(MKDIR) $(@D)
$(RM) $@
$(SED) '1s/python3 /python$(PYVER) /' < $(SRC) > $@
$(CHMOD) 555 $@

# shebang...

FRC:

6 changes: 6 additions & 0 deletions src/Makefile.com
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ ROOTETC = $(ROOT)/etc
ROOTETCZONES = $(ROOTETC)/zones
ROOTETCBRAND = $(ROOTETC)/brand
ROOTUSRLIB = $(ROOT)/usr/lib
ROOTUSRBIN = $(ROOT)/usr/bin
ROOTUSRSHARE = $(ROOT)/usr/share
ROOTUSRSHARELOCALE = $(ROOTUSRSHARE)/locale
ROOTBRAND = $(ROOTUSRLIB)/brand
ROOTPKGLIB = $(ROOTUSRLIB)/pkg
TRIPLET = x86_64-pc-solaris2

CC = /usr/bin/gcc-13
CFLAGS = -m64 -Wall -Werror -Wextra -gdwarf-2 -gstrict-dwarf \
Expand All @@ -43,9 +45,13 @@ STRIP = /usr/bin/strip
RM = /usr/bin/rm -f
MV = /usr/bin/mv
MKDIR = /usr/bin/mkdir -p
RMDIR = /usr/bin/rmdir
SED = /usr/bin/sed
CHMOD = /usr/bin/chmod

CTFCONVERT_BIN = $(CTFCONVERT) -l pkg5
POST_PROCESS = $(CTFCONVERT_BIN) $@; $(STRIP) -x $@
PYCOMPILE_OPTS = -m compileall -j0 -f --invalidation-mode timestamp

PRE_HASH= pre\#
HASH= $(PRE_HASH:pre\%=%)
Expand Down
29 changes: 15 additions & 14 deletions src/cffi_src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,28 @@
#

#
# Copyright 2023 OmniOS Community Edition (OmniOSce) Association.
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
#

EXTENSIONS= arch sha512_t sysattr syscallat
SOURCES= $(EXTENSIONS:%=_%.c)
OUTDIR= cffi_src
include ../Makefile.com

all: $(SOURCES)
SUBDIRS= $(PYVERSIONS:%=src/%)

$(OUTDIR): FRC
mkdir $@
all := TARGET = all
install := TARGET = install
clean := TARGET = clean
clobber := TARGET = clobber

_%.c: $(OUTDIR) build_%.py
./$<
mv $(OUTDIR)/$@ .
all install clean: $(SUBDIRS)

clean:
rm -f $(SOURCES)
clobber: $(SUBDIRS)
$(RMDIR) $(SUBDIRS) src

clobber: clean
rm -rf $(OUTDIR)
check:

$(SUBDIRS): FRC
$(MKDIR) $@
@cd $@; pwd; $(MAKE) -f ../../Makefile.ext $(TARGET) USEPY=$(@F)

FRC:

53 changes: 53 additions & 0 deletions src/cffi_src/Makefile.crossext
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
#

#
# This file is used instead of Makefile.ext when cross-compiling as the FFI
# module is not available in the python cross environment.
#

include ../../../Makefile.com

SUSEPY.cmd = echo $(USEPY) | tr -d .
SUSEPY = $(SUSEPY.cmd:sh)

ROOTPYPKG= $(ROOT)/usr/lib/python$(USEPY)/vendor-packages/pkg

EXTENSIONS= arch sha512_t sysattr syscallat
SOBJ= $(EXTENSIONS:%=_%.cpython-$(SUSEPY)-$(TRIPLET).so)

_sha512_t.cpython-%.so := LDFLAGS = -lmd
_sysattr.cpython-%.so := LDFLAGS = -lnvpair

all: $(SOBJ)

install: all $(ROOTPYPKG) $(SOBJ:%=$(ROOTPYPKG)/%)

clean:
clobber:
$(RM) $(SOBJ)

$(ROOTPYPKG): FRC
$(MKDIR) $@

$(ROOTPYPKG)/%.so: %.so
$(MKDIR) $(@D)
$(RM) $@; $(INSTALL) -f $(@D) -m 0555 $<

%.cpython-$(SUSEPY)-$(TRIPLET).so: %.c
$(CC) -shared -fPIC $< $(PYCFLAGS) $(PYLDFLAGS) $(LDFLAGS) -o $@

FRC:

50 changes: 50 additions & 0 deletions src/cffi_src/Makefile.ext
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
#

include ../../../Makefile.com

SUSEPY.cmd = echo $(USEPY) | tr -d .
SUSEPY = $(SUSEPY.cmd:sh)

ROOTPYPKG= $(ROOT)/usr/lib/python$(USEPY)/vendor-packages/pkg

EXTENSIONS= arch sha512_t sysattr syscallat
SOURCES= $(EXTENSIONS:%=_%.c)
SOBJ= $(EXTENSIONS:%=_%.cpython-$(SUSEPY)-$(TRIPLET).so)
ROOTSOBJ = $(SOBJ:%=$(ROOTPYPKG)/%)

all: $(SOURCES)

install: $(ROOTPYPKG) $(ROOTSOBJ)

clean:
$(RM) $(SOURCES) $(SOURCES:%.c=%.o)

clobber: clean
$(RM) *.so

$(ROOTSOBJ): $(SOURCES)

$(ROOTPYPKG): FRC
$(MKDIR) $@

$(ROOTPYPKG)/%: %
$(RM) $@; $(INSTALL) -f $(@D) -m 0555 $<

_%.c: ../../build_%.py
python$(USEPY) $<

FRC:

3 changes: 2 additions & 1 deletion src/cffi_src/build_arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <sys/systeminfo.h>
#include <stdlib.h>
""",
extra_compile_args=["-O3"],
)

ffi.cdef(
Expand All @@ -54,7 +55,7 @@
)

if __name__ == "__main__":
ffi.emit_c_code("cffi_src/_arch.c")
ffi.compile(verbose=False)

# Vim hints
# vim:ts=4:sw=4:et:fdm=marker
4 changes: 3 additions & 1 deletion src/cffi_src/build_sha512_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include <sys/sha2.h>
#include <string.h>
""",
extra_compile_args=["-O3"],
libraries=["md"],
)

ffi.cdef(
Expand Down Expand Up @@ -70,7 +72,7 @@
)

if __name__ == "__main__":
ffi.emit_c_code("cffi_src/_sha512_t.c")
ffi.compile(verbose=False)

# Vim hints
# vim:ts=4:sw=4:et:fdm=marker
4 changes: 3 additions & 1 deletion src/cffi_src/build_sysattr.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#include <stdbool.h>
#include <sys/nvpair.h>
""",
extra_compile_args=["-O3"],
libraries=["nvpair"],
)

ffi.cdef(
Expand Down Expand Up @@ -150,7 +152,7 @@
)

if __name__ == "__main__":
ffi.emit_c_code("cffi_src/_sysattr.c")
ffi.compile(verbose=False)

# Vim hints
# vim:ts=4:sw=4:et:fdm=marker
Loading

0 comments on commit fcfb8dc

Please sign in to comment.