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.
>>
>> - minor bump to 5.1 instead of major bump
>>
>> check_sym shows added symbols.
>> see:
>> https://github.com/arvidn/libtorrent/commit/175c20a897ce29a6ba42b564d015d90d7dceefb1
>> https://github.com/arvidn/libtorrent/commit/9a73ab76233fecd4948a32169d07086d871fc939
>>
>> Diffing reveals that a function in a public header was
>> removed. Specifically, libtorrent::dh_key_exchange::good() in
>> include/libtorrent/pe_crypto.hpp was removed.
>> see:
>> https://github.com/arvidn/libtorrent/commit/175c20a897ce29a6ba42b564d015d90d7dceefb1
>>
>> Is my understanding correct? good() has its definition in a header so it
>> is inline and never shows up in the shared object
>> (libtorrent-rasterbar.so.5.0).
>>
>> Even right above it in the same link,
>> include/libtorrent/bt_peer_connection.hpp removes init_bt_handshake from
>> enum class state_t. This enum class has changed.
>>
>> In these two cases, because they affect headers, consumers could include
>> the header, but it never shows up in the shared object. Thus, no need to
>> major bump?
>
> Ya, I was not 100% sure of this part so I thought it's better to be on
> the safe side.

ping now that boost-build is back in devel/boost and is in the mirrors.

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.

>
>> Testing
>> =======
>> I was able to download a linux iso torrent with qbittorrent and deluge.
>>
>> Testers will need to apply the b2/bjam diff to devel/boost I will be
>> sending shortly.
>>
>> Feedback and tests are welcome. OK?

To test, upgrade to boost-1.79.0p0v0 so boost-build is available.

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    21 Jun 2022 02:15:04 -0000
@@ -1,10 +1,9 @@
 COMMENT =              C++ library implementing a BitTorrent client
 
-MODPY_EGG_VERSION =    1.2.15
+MODPY_EGG_VERSION =    1.2.16
 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,15 @@ 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
+
 BUILD_DEPENDS =                devel/libtool
 
 LIB_DEPENDS =          converters/libiconv \
@@ -47,13 +48,18 @@ MAKE_ENV =          CC="${CC}" CXX="${CXX}"
 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    21 Jun 2022 02:15:04 -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.16.tar.gz) = 
W9wiFmJUGr3DJN7Qp0tc0/MOYmCHEIC0pLMpX7CfAuA=
+SIZE (libtorrent-rasterbar-1.2.16.tar.gz) = 4163867
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       21 Jun 2022 02:15:04 -0000
@@ -0,0 +1,25 @@
+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.
+
+Index: Jamfile
+--- Jamfile.orig
++++ Jamfile
+@@ -46,7 +46,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 +756,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
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      21 Jun 2022 02:15:04 -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 21 Jun 2022 02:15:04 -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   21 Jun 2022 02:15:04 -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