Nam Nguyen writes:

> Nam Nguyen writes:
>
>> Brad Smith writes:
>>
>>> On 5/16/2022 11:21 PM, Nam Nguyen wrote:
>>
>>>> This diff additionally:
>>>> - removes ${FILESDIR}/setup.py and uses boost-build. This depends on a
>>>> diff for devel/boost to install b2 and bjam. I will send this after this
>>>> e-mail.
>>>>
>>>> The motivation is to lower maintenance of carrying a local copy of
>>>> setup.py with an upside of easier transition to 2.0 in the future.
>
>>
>> ping now that boost-build is back in devel/boost and is in the
>> mirrors.
>
> ping now that 1.2.17 has been released.

ping. boost 1.80.0 is going to be updated soon from Brad. I tested
against both -current boost and upcoming 1.80.0.

I had the same issue as this reported issue with boost 1.80.0, so I had
to backport upstream's fix.

see:
https://github.com/arvidn/libtorrent/issues/6972
https://github.com/arvidn/libtorrent/commit/1ec11e4e9b2d12d26f4661a14743822c91d76003

>
> This fresh diff does the following:
> - updates to 1.2.17
> - major bump due to removed symbols. see:
>   https://namtsui.com/public/check_sym_ltr.txt
> - MODPY_SETUPTOOLS because ${WRKSRC}/bindings/python/setup.py mentions
>   setuptools. A side effect was that this sets TEST_TARGET = test. To
>   get tests to run, I have to set TEST_TARGET = check.
> - removes ${FILESDIR}/setup.py
> - patches Jamfile with correct library version number and add include
>   path for boost
> - patches setup.py to pass arguments to b2 to build python bindings
>   correctly

This fresh diff additionally:
- backports build fix for boost 1.80.0, as mentioned above
- garbage collects PYTHON= CC= CXX= flags, which appear to be unused

>
>>
>> There is a major bump, as Brad had suggested, due to removal of
>> libtorrent::dh_key_exchange::good() in pe_crypto.hpp.
>>
>> Should I use `ONLY_FOR_ARCHS = ${CLANG_ARCHS}'?
>>
>> Inside the patch for bindings/python/setup.py, I have added
>> `toolset=clang cxxstd=17...'. Usage of `toolset=gcc' instead, according to
>> ${WRKSRC}/bindings/python/Jamfile, adds:
>>     result += <lt-visibility>hidden ;
>>     result += <linkflags>-Wl,-Bsymbolic
>>     <toolset>gcc:<cxxflags>-Wno-deprecated-declarations
>> which is not too drastic of a difference from clang.
>>
>> There has not really been testing on non-clang arches. It is no worse
>> off than before, so I propose omitting ONLY_FOR_ARCHS for now.
>
> I tested all consumers: qbittorent, qbittorent-nox and deluge. `make
> test' works as before with 2 skipped tests.
>
> Feedback and tests are welcome. OK?

Index: Makefile
===================================================================
RCS file: /cvs/ports/net/libtorrent-rasterbar/Makefile,v
retrieving revision 1.21
diff -u -p -u -p -r1.21 Makefile
--- Makefile    11 Mar 2022 19:46:17 -0000      1.21
+++ Makefile    10 Aug 2022 00:56:40 -0000
@@ -1,10 +1,9 @@
 COMMENT =              C++ library implementing a BitTorrent client
 
-MODPY_EGG_VERSION =    1.2.15
+MODPY_EGG_VERSION =    1.2.17
 DISTNAME =             libtorrent-rasterbar-${MODPY_EGG_VERSION}
-REVISION =             0
 
-SHARED_LIBS +=         torrent-rasterbar 5.0   # 10.0.0
+SHARED_LIBS +=         torrent-rasterbar 6.0   # 10.0.0
 
 CATEGORIES =           net devel
 
@@ -13,13 +12,17 @@ HOMEPAGE =          https://libtorrent.org/
 # BSD3
 PERMIT_PACKAGE =       Yes
 
-WANTLIB += ${COMPILER_LIBCXX} boost_python${MODPY_VERSION:C/\.//g}-mt
-WANTLIB += boost_system-mt crypto iconv m ssl
+WANTLIB += ${COMPILER_LIBCXX} boost_python${MODPY_VERSION:C/\.//g}
+WANTLIB += boost_system boost_system-mt crypto iconv m ssl
 
 MASTER_SITES =         
https://github.com/arvidn/libtorrent/releases/download/v${MODPY_EGG_VERSION}/
 
 MODULES =              lang/python
 
+MODPY_SETUPTOOLS =     Yes
+# MODPY_SETUPTOOLS sets TEST_TARGET to `test', so reset it to `check'
+TEST_TARGET =          check
+
 BUILD_DEPENDS =                devel/libtool
 
 LIB_DEPENDS =          converters/libiconv \
@@ -39,21 +42,22 @@ CONFIGURE_ARGS =    --enable-python-binding
 # https://github.com/arvidn/libtorrent/issues/6468
 CONFIGURE_ARGS +=      --with-cxx-standard=17
 
-CONFIGURE_ENV +=       PYTHON=${MODPY_DEFAULT_VERSION_3}
-# python bindings setup.py need CXX
-MAKE_ENV =             CC="${CC}" CXX="${CXX}"
-
 .ifdef DEBUG
 CONFIGURE_ARGS +=      --enable-debug
 .endif
 
+post-patch:
+       ${SUBST_CMD} ${WRKSRC}/Jamfile
+
 pre-configure:
        sed -i 's,-Os,,g' ${WRKSRC}/configure
-# use setup.py from 1.2.11 because >=1.2.12 introduced dependency on 
boost-build
-       ${SUBST_CMD} -m 644 -c ${FILESDIR}/setup.py \
-               ${WRKSRC}/bindings/python/setup.py
 
 pre-test:
        ln -sf ${MODPY_BIN} ${WRKDIR}/bin/python
+
+EGG =  ${PREFIX}/lib/python${MODPY_VERSION}/site-packages/libtorrent-*.egg
+post-install:
+       mv ${EGG}/libtorrent.cpython-${MODPY_VERSION:C/\.//g}.so ${EGG}/..
+       rm -rf ${EGG}
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/net/libtorrent-rasterbar/distinfo,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 distinfo
--- distinfo    31 Dec 2021 00:31:16 -0000      1.10
+++ distinfo    10 Aug 2022 00:56:40 -0000
@@ -1,2 +1,2 @@
-SHA256 (libtorrent-rasterbar-1.2.15.tar.gz) = 
yK2GOGhMCpA+urwwSQB54xsaamONoq3sWovvag5iIUs=
-SIZE (libtorrent-rasterbar-1.2.15.tar.gz) = 4163049
+SHA256 (libtorrent-rasterbar-1.2.17.tar.gz) = 
XVNtvtn+OhXVHqHpO5S2LYBvyJuGUEu6BfTFPVJF0Us=
+SIZE (libtorrent-rasterbar-1.2.17.tar.gz) = 4167440
Index: files/setup.py
===================================================================
RCS file: files/setup.py
diff -N files/setup.py
--- files/setup.py      22 May 2021 21:47:28 -0000      1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,196 +0,0 @@
-#!${MODPY_BIN}
-
-
-from distutils.core import setup, Extension
-from distutils.sysconfig import get_config_vars
-import os
-import platform
-import sys
-import shutil
-import multiprocessing
-
-
-class flags_parser:
-    def __init__(self):
-        self.include_dirs = []
-        self.library_dirs = []
-        self.libraries = []
-
-    def parse(self, args):
-        """Parse out the -I -L -l directives
-
-        Returns:
-            list: All other arguments
-        """
-        ret = []
-        for token in args.split():
-            prefix = token[:2]
-            if prefix == '-I':
-                self.include_dirs.append(token[2:])
-            elif prefix == '-L':
-                self.library_dirs.append(token[2:])
-            elif prefix == '-l':
-                self.libraries.append(token[2:])
-            else:
-                ret.append(token)
-        return ret
-
-
-def arch():
-    if platform.system() == 'Darwin':
-        __, __, machine = platform.mac_ver()
-        if machine.startswith('ppc'):
-            return ['-arch', machine]
-    return []
-
-
-def target_specific():
-    if platform.system() == 'Darwin':
-        # On mavericks, clang will fail when unknown arguments are passed in.
-        # python distutils will pass in arguments it doesn't know about.
-        return ['-Wno-error=unused-command-line-argument-hard-error-in-future']
-    return []
-
-
-try:
-    with open('compile_flags') as _file:
-        extra_cmd = _file.read()
-except Exception:
-    extra_cmd = None
-
-try:
-    with open('link_flags') as _file:
-        ldflags = _file.read()
-except Exception:
-    ldflags = None
-
-# this is to pull out compiler arguments from the CXX flags set up by the
-# configure script. Specifically, the -std=c++11 flag is added to CXX and here
-# we pull out everything starting from the first flag (i.e. something starting
-# with a '-'). The actual command to call the compiler may be more than one
-# word, for instance "ccache g++".
-try:
-    with open('compile_cmd') as _file:
-        cmd = _file.read().split(' ')
-        while len(cmd) > 0 and not cmd[0].startswith('-'):
-            cmd = cmd[1:]
-        extra_cmd += ' '.join(cmd)
-except Exception:
-    pass
-
-ext = None
-packages = None
-
-if '--bjam' in sys.argv:
-    del sys.argv[sys.argv.index('--bjam')]
-
-    if '--help' not in sys.argv \
-            and '--help-commands' not in sys.argv:
-
-        toolset = ''
-        file_ext = '.so'
-
-        if platform.system() == 'Windows':
-            file_ext = '.pyd'
-            # See https://wiki.python.org/moin/WindowsCompilers for a table of 
msvc versions
-            # used for each python version
-            # Specify the full version number for 9.0 and 10.0 because 
apparently
-            # older versions of boost don't support only specifying the major 
number and
-            # there was only one version of msvc with those majors.
-            # Only specify the major for msvc-14 so that 14.1, 14.11, etc can 
be used.
-            # Hopefully people building with msvc-14 are using a new enough 
version of boost
-            # for this to work.
-            if sys.version_info[0:2] in ((2, 6), (2, 7), (3, 0), (3, 1), (3, 
2)):
-                toolset = ' toolset=msvc-9.0'
-            elif sys.version_info[0:2] in ((3, 3), (3, 4)):
-                toolset = ' toolset=msvc-10.0'
-            elif sys.version_info[0:2] in ((3, 5), (3, 6)):
-                toolset = ' toolset=msvc-14'
-            else:
-                # unknown python version, lets hope the user has the right 
version of msvc configured
-                toolset = ' toolset=msvc'
-
-        parallel_builds = ' -j%d' % multiprocessing.cpu_count()
-        if sys.maxsize > 2**32:
-            address_model = ' address-model=64'
-        else:
-            address_model = ' address-model=32'
-
-        # add extra quoting around the path to prevent bjam from parsing it as 
a list
-        # if the path has spaces
-        os.environ['LIBTORRENT_PYTHON_INTERPRETER'] = '"' + sys.executable + 
'"'
-
-        # build libtorrent using bjam and build the installer with distutils
-        cmdline = ('b2 libtorrent-link=static boost-link=static release '
-                   'optimization=space stage_module --abbreviate-paths' +
-                   address_model + toolset + parallel_builds)
-        print(cmdline)
-        if os.system(cmdline) != 0:
-            print('build failed')
-            sys.exit(1)
-
-        try:
-            os.mkdir('build')
-        except Exception:
-            pass
-        try:
-            shutil.rmtree('build/lib')
-        except Exception:
-            pass
-        try:
-            os.mkdir('build/lib')
-        except Exception:
-            pass
-        try:
-            os.mkdir('libtorrent')
-        except Exception:
-            pass
-        shutil.copyfile('libtorrent' + file_ext,
-                        'build/lib/libtorrent' + file_ext)
-
-    packages = ['libtorrent']
-
-else:
-    # Remove '-Wstrict-prototypes' compiler option, which isn't valid for C++.
-    cfg_vars = get_config_vars()
-    for key, value in list(cfg_vars.items()):
-        if isinstance(value, str):
-            cfg_vars[key] = value.replace('-Wstrict-prototypes', '')
-            cfg_vars[key] = value.replace('-L${LOCALBASE}/lib/', '')
-
-    src_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "src"))
-    source_list = [os.path.join(src_dir, s) for s in os.listdir(src_dir) if 
s.endswith(".cpp")]
-
-    flags = flags_parser()
-    ext_extra = {}
-
-    if ldflags:
-        # ldflags parsed first to ensure the correct library search path order
-        ext_extra["extra_link_args"] = flags.parse(ldflags) + arch()
-
-    if extra_cmd:
-        ext_extra["extra_compile_args"] = flags.parse(extra_cmd) + arch() + 
target_specific()
-
-    ext = [Extension(
-        'libtorrent',
-        sources=sorted(source_list),
-        language='c++',
-        include_dirs=flags.include_dirs,
-        library_dirs=flags.library_dirs,
-        libraries=['torrent-rasterbar'] + flags.libraries,
-        **ext_extra)
-    ]
-
-setup(
-    name='python-libtorrent',
-    version='${MODPY_EGG_VERSION}',
-    author='Arvid Norberg',
-    author_email='ar...@libtorrent.org',
-    description='Python bindings for libtorrent-rasterbar',
-    long_description='Python bindings for libtorrent-rasterbar',
-    url='http://libtorrent.org',
-    platforms=[platform.system() + '-' + platform.machine()],
-    license='BSD',
-    packages=packages,
-    ext_modules=ext
-)
Index: patches/patch-Jamfile
===================================================================
RCS file: patches/patch-Jamfile
diff -N patches/patch-Jamfile
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-Jamfile       10 Aug 2022 00:56:40 -0000
@@ -0,0 +1,54 @@
+libtorrent.cpython-*.so fails to load libtorrent-rasterbar.so.10.0.0.
+Give it the proper SHARED_LIB.
+
+Add include path to find boost headers.
+
+commit 1ec11e4e9b2d12d26f4661a14743822c91d76003
+from: arvidn <ar...@libtorrent.org>
+date: Fri Jul 22 22:12:42 2022 UTC
+via: Arvid Norberg <arvid.norb...@gmail.com>
+
+back-port Jamfile version fix from RC_2_0
+
+Index: Jamfile
+--- Jamfile.orig
++++ Jamfile
+@@ -18,6 +18,8 @@ ECHO "CXXFLAGS =" $(CXXFLAGS) ;
+ ECHO "LDFLAGS =" $(LDFLAGS) ;
+ ECHO "OS =" [ os.name ] ;
+ 
++jam-version = [ modules.peek : JAM_VERSION ] ;
++
+ if $(BOOST_ROOT)
+ {
+       ECHO "building boost from source directory: " $(BOOST_ROOT) ;
+@@ -46,7 +48,7 @@ else
+ 
+ # we need version numbers in the form X.Y.Z in order to trigger the built-in
+ # support for generating symlinks to the installed library
+-VERSION = 10.0.0 ;
++VERSION = ${LIBtorrent-rasterbar_VERSION} ;
+ 
+ rule linking ( properties * )
+ {
+@@ -756,6 +758,7 @@ ED25519_SOURCES =
+ local usage-requirements =
+       <include>./include
+       <include>./include/libtorrent
++      <include>${LOCALBASE}/include
+       <include>/usr/sfw/include
+       <variant>release:<define>NDEBUG
+       <define>_FILE_OFFSET_BITS=64
+@@ -823,8 +826,10 @@ rule install-paths ( properties * )
+       # package.paths was introduced in boost-1.70 (2018.02)
+       # however, boost build's versioning scheme changed in boost-1.71 to 
version
+       # 4.0
+-      local boost-build-version = [ SPLIT_BY_CHARACTERS [ version.boost-build 
] : "-" ] ;
+-      if [ version.version-less [ SPLIT_BY_CHARACTERS 
$(boost-build-version[1]) : "." ] : 2018 03 ]
++      # so, if versions are 4.0+ we want to use package.paths, but if it's a 
year,
++      # say 2018, that means it's old and we use the fallback below. Any 
version <
++      # 1990 is considered the 4.0 and later numbering scheme.
++      if [ version.version-less 1990 0 : $(jam-version) ]
+       {
+               import option ;
+               import property ;
Index: patches/patch-bindings_python_setup_py
===================================================================
RCS file: patches/patch-bindings_python_setup_py
diff -N patches/patch-bindings_python_setup_py
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-bindings_python_setup_py      10 Aug 2022 00:56:40 -0000
@@ -0,0 +1,23 @@
+Index: bindings/python/setup.py
+--- bindings/python/setup.py.orig
++++ bindings/python/setup.py
+@@ -207,7 +207,7 @@ class LibtorrentBuildExt(BuildExtBase):
+     def initialize_options(self):
+ 
+         self.config_mode = self.CONFIG_MODE_DISTUTILS
+-        self.b2_args = ""
++        self.b2_args = "toolset=clang cxxstd=17 libtorrent-python-pic=on"
+         self.no_autoconf = ""
+ 
+         self.cxxflags = None
+@@ -365,8 +365,8 @@ class LibtorrentBuildExt(BuildExtBase):
+         if os.name == "nt":
+             self._maybe_add_arg("--abbreviate-paths")
+ 
+-        self._maybe_add_arg("boost-link=static")
+-        self._maybe_add_arg("libtorrent-link=static")
++        self._maybe_add_arg("boost-link=shared")
++        self._maybe_add_arg("libtorrent-link=shared")
+ 
+         self._maybe_add_arg("crypto=openssl")
+ 
Index: patches/patch-include_libtorrent_config_hpp
===================================================================
RCS file: 
/cvs/ports/net/libtorrent-rasterbar/patches/patch-include_libtorrent_config_hpp,v
retrieving revision 1.7
diff -u -p -u -p -r1.7 patch-include_libtorrent_config_hpp
--- patches/patch-include_libtorrent_config_hpp 11 Mar 2022 19:46:17 -0000      
1.7
+++ patches/patch-include_libtorrent_config_hpp 10 Aug 2022 00:56:40 -0000
@@ -1,7 +1,7 @@
 Index: include/libtorrent/config.hpp
 --- include/libtorrent/config.hpp.orig
 +++ include/libtorrent/config.hpp
-@@ -429,6 +429,10 @@ POSSIBILITY OF SUCH DAMAGE.
+@@ -443,6 +443,10 @@ POSSIBILITY OF SUCH DAMAGE.
  #define TORRENT_USE_UNC_PATHS 0
  #endif
  
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/net/libtorrent-rasterbar/pkg/PLIST,v
retrieving revision 1.8
diff -u -p -u -p -r1.8 PLIST
--- pkg/PLIST   11 Mar 2022 19:46:17 -0000      1.8
+++ pkg/PLIST   10 Aug 2022 00:56:40 -0000
@@ -54,6 +54,7 @@ include/libtorrent/aux_/session_interfac
 include/libtorrent/aux_/session_settings.hpp
 include/libtorrent/aux_/session_udp_sockets.hpp
 include/libtorrent/aux_/set_socket_buffer.hpp
+include/libtorrent/aux_/set_traffic_class.hpp
 include/libtorrent/aux_/socket_type.hpp
 include/libtorrent/aux_/storage_piece_set.hpp
 include/libtorrent/aux_/storage_utils.hpp
@@ -253,7 +254,6 @@ lib/libtorrent-rasterbar.la
 @lib lib/libtorrent-rasterbar.so.${LIBtorrent-rasterbar_VERSION}
 lib/pkgconfig/libtorrent-rasterbar.pc
 @so 
lib/python${MODPY_VERSION}/site-packages/libtorrent.${MODPY_PYC_MAGIC_TAG}so
-lib/python${MODPY_VERSION}/site-packages/python_libtorrent-${MODPY_EGG_VERSION}-py${MODPY_VERSION}.egg-info
 share/cmake/
 share/cmake/Modules/
 share/cmake/Modules/FindLibtorrentRasterbar.cmake

Reply via email to