Skip to content

Commit e23d9e8

Browse files
committed
Stop using setuptools for build
1 parent 02a5f6f commit e23d9e8

23 files changed

+693
-2034
lines changed

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.intltool-merge-cache
22
.make.state
33
**/__pycache__
4+
**/*.so
45
/packages
56
/proto
67
/src/brand/fmri_compare
@@ -17,8 +18,7 @@
1718
/src/tests/.timing_history.txt
1819
/src/tests/*.pyc
1920
/src/tests/*/*.pyc
20-
/src/cffi_src/_*
21-
/src/cffi_src/64
21+
/src/cffi_src/src
2222
/src/tests/failures
2323
/src/tests/failures.3*
2424
src/pkg.egg-info/

src/Makefile

+16-17
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,33 @@ include Makefile.com
2929

3030
JOBS = 8
3131

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

3639
REQUIREMENTS = requirements.txt
3740

41+
TARGET = all
3842
all := TARGET = all
3943
install := TARGET = install
44+
install-cmd := TARGET = install
4045
clean := TARGET = clean
4146
clobber := TARGET = clobber
4247
check := TARGET = check
4348
packages := TARGET = install
49+
test := TARGET = install
4450

45-
SUBDIRS=brand util/mkcert man po svc web
51+
SUBDIRS= cffi_src modules brand util man po svc web
52+
brand: cffi_src modules util $(EXTMODULES)
4653

4754
all: $(SUBDIRS)
4855

49-
build: $(PYVERSIONS)
56+
install: install-cmd $(SUBDIRS) $(EXTMODULES)
5057

51-
install: $(PYVERSIONS) .WAIT $(PYMODULES) .WAIT $(SUBDIRS)
52-
53-
clean: $(SUBDIRS) $(PYVERSIONS)
54-
@cd pkg; pwd; make clean
55-
56-
clobber: $(SUBDIRS) $(PYVERSONS)
57-
@cd pkg; pwd; make clobber
58+
clean clobber: $(SUBDIRS) pkg
5859

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

81-
$(SUBDIRS) cffi_src: FRC
82+
$(SUBDIRS) pkg: FRC
8283
@cd $@; pwd; $(MAKE) $(TARGET) CC=$(CC)
8384

84-
$(PYVERSIONS): FRC
85-
python$@ setup.py $(TARGET)
85+
install-cmd: FRC
86+
$(MAKE) -f Makefile.cmd $(TARGET)
8687

87-
$(PYMODULES): FRC
88+
$(EXTMODULES):
8889
../tools/installmodules $(CODE_WS) $(ROOT) $(@F) \
8990
$(TARGET) $(ROOTPKGLIB) core $(REQUIREMENTS)
9091

91-
$(PYTESTS): $(PYMODULES)
92+
$(PYTESTS): $(EXTMODULES)
9293
-pfexec python$(@F) tests/run.py -t -j $(JOBS)
9394
-pfexec cp tests/failures.3 tests/failures.$(@F)
9495
-pfexec cp tests/timing_info.txt tests/timing_info.$(@F)
@@ -100,5 +101,3 @@ $(TESTRESULTS): $(PYTESTS)
100101

101102
FRC:
102103

103-
.NO_PARALLEL: $(PYVERSIONS) $(PYTESTS)
104-

src/Makefile.cmd

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#
2+
# This file and its contents are supplied under the terms of the
3+
# Common Development and Distribution License ("CDDL"), version 1.0.
4+
# You may only use this file in accordance with the terms of version
5+
# 1.0 of the CDDL.
6+
#
7+
# A full copy of the text of the CDDL should have accompanied this
8+
# source. A copy of the CDDL is also available via the Internet at
9+
# http://www.illumos.org/license/CDDL.
10+
#
11+
12+
#
13+
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
14+
#
15+
16+
include Makefile.com
17+
18+
BINS = \
19+
pkg \
20+
pkgdepend \
21+
pkgrepo \
22+
pkgdiff \
23+
pkgfmt \
24+
pkglint \
25+
pkgmerge \
26+
pkgmogrify \
27+
pkgsurf \
28+
pkgsend \
29+
pkgrecv \
30+
pkgsign
31+
32+
LIBS = \
33+
pkg.depotd
34+
35+
TARGETS= $(BINS:%=$(ROOTUSRBIN)/%) $(LIBS:%=$(ROOTUSRLIB)/%)
36+
37+
$(ROOTUSRBIN)/pkg := SRC = client.py
38+
$(ROOTUSRBIN)/pkgdepend := SRC = pkgdep.py
39+
$(ROOTUSRBIN)/pkgrepo := SRC = pkgrepo.py
40+
$(ROOTUSRBIN)/pkgdiff := SRC = util/publish/pkgdiff.py
41+
$(ROOTUSRBIN)/pkgfmt := SRC = util/publish/pkgfmt.py
42+
$(ROOTUSRBIN)/pkglint := SRC = util/publish/pkglint.py
43+
$(ROOTUSRBIN)/pkgmerge := SRC = util/publish/pkgmerge.py
44+
$(ROOTUSRBIN)/pkgmogrify := SRC = util/publish/pkgmogrify.py
45+
$(ROOTUSRBIN)/pkgsurf := SRC = util/publish/pkgsurf.py
46+
$(ROOTUSRBIN)/pkgsend := SRC = publish.py
47+
$(ROOTUSRBIN)/pkgrecv := SRC = pull.py
48+
$(ROOTUSRBIN)/pkgsign := SRC = sign.py
49+
$(ROOTUSRLIB)/pkg.depotd := SRC = depot.py
50+
51+
all clean clobber:
52+
53+
install: $(TARGETS)
54+
python$(PYVER) $(PYCOMPILE_OPTS) $(TARGETS)
55+
56+
$(TARGETS): FRC
57+
$(MKDIR) $(@D)
58+
$(RM) $@
59+
$(SED) '1s/python3 /python$(PYVER) /' < $(SRC) > $@
60+
$(CHMOD) 555 $@
61+
62+
# shebang...
63+
64+
FRC:
65+

src/Makefile.com

+6
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ ROOTETC = $(ROOT)/etc
2121
ROOTETCZONES = $(ROOTETC)/zones
2222
ROOTETCBRAND = $(ROOTETC)/brand
2323
ROOTUSRLIB = $(ROOT)/usr/lib
24+
ROOTUSRBIN = $(ROOT)/usr/bin
2425
ROOTUSRSHARE = $(ROOT)/usr/share
2526
ROOTUSRSHARELOCALE = $(ROOTUSRSHARE)/locale
2627
ROOTBRAND = $(ROOTUSRLIB)/brand
2728
ROOTPKGLIB = $(ROOTUSRLIB)/pkg
29+
TRIPLET = x86_64-pc-solaris2
2830

2931
CC = /usr/bin/gcc-13
3032
CFLAGS = -m64 -Wall -Werror -Wextra -gdwarf-2 -gstrict-dwarf \
@@ -43,9 +45,13 @@ STRIP = /usr/bin/strip
4345
RM = /usr/bin/rm -f
4446
MV = /usr/bin/mv
4547
MKDIR = /usr/bin/mkdir -p
48+
RMDIR = /usr/bin/rmdir
49+
SED = /usr/bin/sed
50+
CHMOD = /usr/bin/chmod
4651

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

5056
PRE_HASH= pre\#
5157
HASH= $(PRE_HASH:pre\%=%)

src/cffi_src/Makefile

+15-14
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,28 @@
1010
#
1111

1212
#
13-
# Copyright 2023 OmniOS Community Edition (OmniOSce) Association.
13+
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
1414
#
1515

16-
EXTENSIONS= arch sha512_t sysattr syscallat
17-
SOURCES= $(EXTENSIONS:%=_%.c)
18-
OUTDIR= cffi_src
16+
include ../Makefile.com
1917

20-
all: $(SOURCES)
18+
SUBDIRS= $(PYVERSIONS:%=src/%)
2119

22-
$(OUTDIR): FRC
23-
mkdir $@
20+
all := TARGET = all
21+
install := TARGET = install
22+
clean := TARGET = clean
23+
clobber := TARGET = clobber
2424

25-
_%.c: $(OUTDIR) build_%.py
26-
./$<
27-
mv $(OUTDIR)/$@ .
25+
all install clean: $(SUBDIRS)
2826

29-
clean:
30-
rm -f $(SOURCES)
27+
clobber: $(SUBDIRS)
28+
$(RMDIR) $(SUBDIRS) src
3129

32-
clobber: clean
33-
rm -rf $(OUTDIR)
30+
check:
31+
32+
$(SUBDIRS): FRC
33+
$(MKDIR) $@
34+
@cd $@; pwd; $(MAKE) -f ../../Makefile.ext $(TARGET) USEPY=$(@F)
3435

3536
FRC:
3637

src/cffi_src/Makefile.crossext

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#
2+
# This file and its contents are supplied under the terms of the
3+
# Common Development and Distribution License ("CDDL"), version 1.0.
4+
# You may only use this file in accordance with the terms of version
5+
# 1.0 of the CDDL.
6+
#
7+
# A full copy of the text of the CDDL should have accompanied this
8+
# source. A copy of the CDDL is also available via the Internet at
9+
# http://www.illumos.org/license/CDDL.
10+
#
11+
12+
#
13+
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
14+
#
15+
16+
#
17+
# This file is used instead of Makefile.ext when cross-compiling as the FFI
18+
# module is not available in the python cross environment.
19+
#
20+
21+
include ../../../Makefile.com
22+
23+
SUSEPY.cmd = echo $(USEPY) | tr -d .
24+
SUSEPY = $(SUSEPY.cmd:sh)
25+
26+
ROOTPYPKG= $(ROOT)/usr/lib/python$(USEPY)/vendor-packages/pkg
27+
28+
EXTENSIONS= arch sha512_t sysattr syscallat
29+
SOBJ= $(EXTENSIONS:%=_%.cpython-$(SUSEPY)-$(TRIPLET).so)
30+
31+
_sha512_t.cpython-%.so := LDFLAGS = -lmd
32+
_sysattr.cpython-%.so := LDFLAGS = -lnvpair
33+
34+
all: $(SOBJ)
35+
36+
install: all $(ROOTPYPKG) $(SOBJ:%=$(ROOTPYPKG)/%)
37+
38+
clean:
39+
clobber:
40+
$(RM) $(SOBJ)
41+
42+
$(ROOTPYPKG): FRC
43+
$(MKDIR) $@
44+
45+
$(ROOTPYPKG)/%.so: %.so
46+
$(MKDIR) $(@D)
47+
$(RM) $@; $(INSTALL) -f $(@D) -m 0555 $<
48+
49+
%.cpython-$(SUSEPY)-$(TRIPLET).so: %.c
50+
$(CC) -shared -fPIC $< $(PYCFLAGS) $(PYLDFLAGS) $(LDFLAGS) -o $@
51+
52+
FRC:
53+

src/cffi_src/Makefile.ext

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#
2+
# This file and its contents are supplied under the terms of the
3+
# Common Development and Distribution License ("CDDL"), version 1.0.
4+
# You may only use this file in accordance with the terms of version
5+
# 1.0 of the CDDL.
6+
#
7+
# A full copy of the text of the CDDL should have accompanied this
8+
# source. A copy of the CDDL is also available via the Internet at
9+
# http://www.illumos.org/license/CDDL.
10+
#
11+
12+
#
13+
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
14+
#
15+
16+
include ../../../Makefile.com
17+
18+
SUSEPY.cmd = echo $(USEPY) | tr -d .
19+
SUSEPY = $(SUSEPY.cmd:sh)
20+
21+
ROOTPYPKG= $(ROOT)/usr/lib/python$(USEPY)/vendor-packages/pkg
22+
23+
EXTENSIONS= arch sha512_t sysattr syscallat
24+
SOURCES= $(EXTENSIONS:%=_%.c)
25+
SOBJ= $(EXTENSIONS:%=_%.cpython-$(SUSEPY)-$(TRIPLET).so)
26+
ROOTSOBJ = $(SOBJ:%=$(ROOTPYPKG)/%)
27+
28+
all: $(SOURCES)
29+
30+
install: $(ROOTPYPKG) $(ROOTSOBJ)
31+
32+
clean:
33+
$(RM) $(SOURCES) $(SOURCES:%.c=%.o)
34+
35+
clobber: clean
36+
$(RM) *.so
37+
38+
$(ROOTSOBJ): $(SOURCES)
39+
40+
$(ROOTPYPKG): FRC
41+
$(MKDIR) $@
42+
43+
$(ROOTPYPKG)/%: %
44+
$(RM) $@; $(INSTALL) -f $(@D) -m 0555 $<
45+
46+
_%.c: ../../build_%.py
47+
python$(USEPY) $<
48+
49+
FRC:
50+

src/cffi_src/build_arch.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <sys/systeminfo.h>
3636
#include <stdlib.h>
3737
""",
38+
extra_compile_args=["-O3"],
3839
)
3940

4041
ffi.cdef(
@@ -54,7 +55,7 @@
5455
)
5556

5657
if __name__ == "__main__":
57-
ffi.emit_c_code("cffi_src/_arch.c")
58+
ffi.compile(verbose=False)
5859

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

src/cffi_src/build_sha512_t.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
#include <sys/sha2.h>
3737
#include <string.h>
3838
""",
39+
extra_compile_args=["-O3"],
40+
libraries=["md"],
3941
)
4042

4143
ffi.cdef(
@@ -70,7 +72,7 @@
7072
)
7173

7274
if __name__ == "__main__":
73-
ffi.emit_c_code("cffi_src/_sha512_t.c")
75+
ffi.compile(verbose=False)
7476

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

src/cffi_src/build_sysattr.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#include <stdbool.h>
3939
#include <sys/nvpair.h>
4040
""",
41+
extra_compile_args=["-O3"],
42+
libraries=["nvpair"],
4143
)
4244

4345
ffi.cdef(
@@ -150,7 +152,7 @@
150152
)
151153

152154
if __name__ == "__main__":
153-
ffi.emit_c_code("cffi_src/_sysattr.c")
155+
ffi.compile(verbose=False)
154156

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

0 commit comments

Comments
 (0)