How to create my own Python Primesieve port

Saj Goonatilleke saj at redu.cx
Thu May 7 03:40:55 UTC 2026


On Thu, 7 May 2026, at 11:15, Kenneth Wolcott wrote:
> How to create my own Python Primesieve port? (how to use upt?)
>
> I've done some research (obviously more research is required!)
> regarding using "upt" to "port" a Python package to a MacPorts port.
>
> I seems like I need to install the following MacPorts ports: "upt" and
> "py413-upt-macports". But I think I need a Python "frontend"...

You are over-thinking the problem.

I have never heard of upt.  Don't need that.

Many people have added many ports to MacPorts over time.  You may use this body of work as your guide.  Find some existing port that is mechanically similar to what you want, then adapt the existing Portfile to suit your specific problem.

Is this what you are after?
https://pypi.org/project/primesieve/

primesieve (the underlying C++ library) already exists in MacPorts, so we can skip that part.  In fact, all of our dependencies already exist in MacPorts, so this should not be too hard.  (Though it might be polite to bump the primesieve port; it is a bit old.)

The primesieve Python library looks like a cython wrapper.  So we can flick through the MacPorts ports tree and find some existing cython wrapper-y thing to use as our guide.  py-murmurhash will do.

Start by copying the py-murmurhash/Portfile to a new py-primesieve/Portfile.

Then read the MacPorts documentation as you go.
https://guide.macports.org/chunked/reference.html
https://guide.macports.org/chunked/reference.portgroup.html#reference.portgroup.github

I have no idea what I am doing.  Nevertheless, by referencing the existing body of work in MacPorts, even I was able to get something working in short order.

% port echo installed and '*primesieve*'
primesieve                     @12.4_0 
py314-primesieve               @2.3.4_0

% python3
Python 3.14.4 (main, Apr  9 2026, 13:21:25) [Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from primesieve import *
>>> nth_prime(10)
29

Here is the rough Portfile.  There might be bugs; I did not test it comprehensively.

(This upstream did once use GitHub Releases in the past, however their most recent tagged releases were not published to GitHub Releases.)

-- 8< --
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem                           1.0
PortGroup           python           1.0
PortGroup           github           1.0

name                py-primesieve
github.setup        shlomif primesieve-python 2.3.4 v
github.tarball_from archive
revision            0

checksums           rmd160  635f628e7f31f998bf8ffbcceb7609ae0b8acd0d \
                    sha256  23db5d5f91af2d8939473524c7612286076a199a75817390265774ed95c62aef \
                    size    11375

license             MIT

maintainers         nomaintainer

description         put words here
long_description    {*}${description}

python.versions     310 311 312 313 314

depends_lib         port:primesieve

if {${name} ne ${subport}} {
    depends_lib-append \
        port:py${python.version}-cython
}
-- >8 --


More information about the macports-users mailing list