Skip to content

Commit

Permalink
Transition from setup.py to pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
bonsaiviking committed Mar 21, 2024
1 parent f4f2e60 commit a946c56
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 17 deletions.
14 changes: 5 additions & 9 deletions Makefile.in
Expand Up @@ -251,7 +251,6 @@ clean-liblinear:
-cd $(LIBLINEARDIR) && $(MAKE) clean

clean-zenmap:
-cd $(ZENMAPDIR) && $(PYTHON) setup.py clean --all
rm -f $(ZENMAPDIR)/zenmapCore/__init__.pyc
rm -f $(ZENMAPDIR)/zenmapCore/Version.pyc
rm -f $(ZENMAPDIR)/zenmapCore/Name.pyc
Expand Down Expand Up @@ -361,15 +360,12 @@ tests/%: tests/%.cc $(OBJS)
# local installation.
DEFAULT_PYTHON_PATH = /usr/bin/env python3

build-zenmap: $(ZENMAPDIR)/setup.py $(ZENMAPDIR)/zenmapCore/Version.py
# When DESTDIR is defined, assume we're building an executable
# distribution rather than a local installation and force a generic
# Python interpreter location.
cd $(ZENMAPDIR) && $(PYTHON) setup.py build $(if $(DESTDIR),--executable "$(DEFAULT_PYTHON_PATH)")
build-zenmap: $(ZENMAPDIR)/pyproject.toml $(ZENMAPDIR)/zenmapCore/Version.py
$(PYTHON) -m build $(ZENMAPDIR)

install-zenmap: $(ZENMAPDIR)/setup.py
install-zenmap: $(ZENMAPDIR)/pyproject.toml
$(INSTALL) -d $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1
cd $(ZENMAPDIR) && $(PYTHON) setup.py --quiet install --prefix "$(prefix)" --force $(if $(DESTDIR),--root "$(DESTDIR)")
$(PYTHON) -m pip install $(ZENMAPDIR) $(if $(DESTDIR),--root "$(DESTDIR)")
$(INSTALL) -c -m 644 docs/zenmap.1 $(DESTDIR)$(mandir)/man1/
# Create a symlink from nmapfe to zenmap if nmapfe doesn't exist or is
# already a link.
Expand Down Expand Up @@ -426,7 +422,7 @@ uninstall-nmap:
rm -rf $(DESTDIR)$(nmapdatadir)

uninstall-zenmap:
cd $(ZENMAPDIR) && $(PYTHON) setup.py uninstall
$(PYTHON) -m pip uninstall $(ZENMAPDIR)
rm -f $(DESTDIR)$(mandir)/man1/zenmap.1
# Uninstall nmapfe only if it's a symlink.
if [ -L $(DESTDIR)$(bindir)/nmapfe ]; then \
Expand Down
2 changes: 1 addition & 1 deletion macosx/Makefile
Expand Up @@ -72,7 +72,7 @@ $(IMAGE_NAME): tool-checks $(IMAGE_STAGING_DIR)/$(PKG_NAME)
# Check the created disk image for the sizes, backgrounds and icons presence and positions
./check_test.sh $(README_FILE) $(LICENSE_FILE) $(3RD_P_LIC_FILE) $(LICENSES_FILE)

tool-checks: have-$(CC) have-jhbuild have-gtk-mac-bundler
tool-checks: have-jhbuild have-gtk-mac-bundler

have-%:
which $*
Expand Down
2 changes: 1 addition & 1 deletion zenmap/README
Expand Up @@ -47,7 +47,7 @@ Default (source) Installation

Zenmap is packaged using Python setuptools. To install Zenmap
independently of Nmap, enter the zenmap subdirectory and run
python setup.py install
python3 -m pip install .

Links:

Expand Down
5 changes: 2 additions & 3 deletions zenmap/install_scripts/macosx/make-bundle.sh
Expand Up @@ -25,7 +25,7 @@ $CC $CPPFLAGS $CFLAGS $LDFLAGS -L$PREFIX/lib `python3-config --cflags --ldflags
~/gtk-mac-bundler/examples/python-launcher.c

echo "Installing Zenmap to local system"
python3 setup.py install vanilla --prefix "$PREFIX"
python3 -m pip install --ignore-installed --target "$PREFIX/lib/python-3.11/site-packages" .

echo "Generating dependencies"
# Have to run this with ~/gtk/inst/python3 or deps have wrong paths
Expand Down Expand Up @@ -79,8 +79,7 @@ python -m compileall "$PYTHONLIB"/site-packages #|| true
echo "Stripping unoptimized Python libraries"

echo "Building using setuptools"
python3 setup.py build --executable "/usr/bin/env python3"
python3 setup.py install vanilla --prefix "$BASE/Resources"
python3 -m pip install --ignore-installed --target "$BASE/Resources/lib/python-3.11/site-packages" .

echo "Renaming main Zenmap executable."
mv $BASE/MacOS/$APP_NAME $BASE/MacOS/zenmap.bin
Expand Down
2 changes: 1 addition & 1 deletion zenmap/install_scripts/macosx/zenmap.bundle
@@ -1,6 +1,6 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE app-bundle [
<!ENTITY PYVER "3.10">
<!ENTITY PYVER "3.11">
<!ENTITY pyreqs SYSTEM "pyreqs.xml">
]>
<app-bundle>
Expand Down
4 changes: 2 additions & 2 deletions zenmap/install_scripts/windows/PKGBUILD
Expand Up @@ -25,8 +25,8 @@ makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")

package() {
cd "${NMAP_DIR}/zenmap"
${MINGW_PREFIX}/bin/python setup.py build
#${MINGW_PREFIX}/bin/python -m pip build
MSYS2_ARG_CONV_EXCL="--prefix=" \
${MINGW_PREFIX}/bin/python setup.py install vanilla --prefix=${MINGW_PREFIX} --root="${pkgdir}" --optimize=1
${MINGW_PREFIX}/bin/python -m pip install --prefix=${MINGW_PREFIX} --root="${pkgdir}" --optimize=1
install -Dm644 install_scripts/unix/zenmap.desktop "${pkgdir}${MINGW_PREFIX}/share/applications/zenmap.desktop"
}

0 comments on commit a946c56

Please sign in to comment.