{"id":13577399,"url":"https://github.com/ntpsec/ntpsec","last_synced_at":"2025-04-05T11:32:50.048Z","repository":{"id":37693201,"uuid":"44414987","full_name":"ntpsec/ntpsec","owner":"ntpsec","description":"The Network Time Protocol suite, refactored   GitHub is a mirror of https://gitlab.com/NTPsec/ntpsec","archived":false,"fork":false,"pushed_at":"2024-11-03T21:06:29.000Z","size":65789,"stargazers_count":259,"open_issues_count":3,"forks_count":38,"subscribers_count":24,"default_branch":"master","last_synced_at":"2024-11-03T22:17:55.756Z","etag":null,"topics":["ntp","ntp-amplification","ntp-client","ntp-library","ntp-protocol","ntp-server","ntpclient-library","ntpd","ntpdate"],"latest_commit_sha":null,"homepage":"https://ntpsec.org/","language":"C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ntpsec.png","metadata":{"files":{"readme":"README-PYTHON","changelog":"NEWS.adoc","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSES/Apache-2.0.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":"https://commerce.coinbase.com/checkout/a3d8cf79-58c1-4923-9d8d-f3f92c8d0554","patreon":"ntpsec","liberapay":"ntpsec"}},"created_at":"2015-10-16T22:55:57.000Z","updated_at":"2024-11-03T21:06:33.000Z","dependencies_parsed_at":"2022-09-15T11:22:21.708Z","dependency_job_id":"464c8987-18ed-4c02-807e-ad732a749bc0","html_url":"https://github.com/ntpsec/ntpsec","commit_stats":null,"previous_names":[],"tags_count":1047,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntpsec%2Fntpsec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntpsec%2Fntpsec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntpsec%2Fntpsec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ntpsec%2Fntpsec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ntpsec","download_url":"https://codeload.github.com/ntpsec/ntpsec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223186616,"owners_count":17102497,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ntp","ntp-amplification","ntp-client","ntp-library","ntp-protocol","ntp-server","ntpclient-library","ntpd","ntpdate"],"created_at":"2024-08-01T15:01:21.108Z","updated_at":"2025-04-05T11:32:50.035Z","avatar_url":"https://github.com/ntpsec.png","language":"C","funding_links":["https://commerce.coinbase.com/checkout/a3d8cf79-58c1-4923-9d8d-f3f92c8d0554","https://patreon.com/ntpsec","https://liberapay.com/ntpsec"],"categories":["C"],"sub_categories":[],"readme":"If you are trying to debug something like:\n\n  ImportError: No module named ntp\n\nor:\n\n  ImportError: No module named gps\n\nyou have come to the right place.\n\nWarning: Every distribution handles Python slightly differently.  It\nalso varies a lot by distribution version.  So grab your distribution\ndocumentation as you read this.  Expect the examples here to differ\nfrom what you see on your system.\n\nWhen building NTPSec for installation, the install procedure asks the\ncurrent python for the proper location to install the python modules.\nOn most distributions the default location where we install our python\nlibraries is:\n\n  /usr/local/lib/pythonX.Y/site-packages/\n\nwhere X and Y are the python version numbers.  Y may be suffixed with\n't' for threaded python versions.\n\nWhy does NTPSec install into /usr/local?\n\nLook at the Filesystem Hierarchy Standard [FHS].  Specifically Version\n3, Chapter 4:\n\n    4.9.1. Purpose\n\n    The /usr/local hierarchy is for use by the system administrator\n    when installing software locally. It needs to be safe from being\n    overwritten when the system software is updated. It may be used for\n    programs and data that are shareable amongst a group of hosts, but\n    not found in /usr.\n\nThe NTPSec build procedure, by default, is for \"nstalling software\nlocally\", so we install into /usr/local, not /usr. /usr is reserved for\nthe \"system software\".\n\nUnfortunately, that's not on the default search path of several\nOSes/distros, in particular Fedora, NetBSD, Gentoo, etc..\n(Fixed in Fedora 39, Sep-2023, ??)\n\nPython has search paths [PATHS] that are used to find library modules\nwhen you import them.  You can see your search paths for Python 2 with:\n\n    alice ~ # python2 -m site\n    sys.path = [\n        '/root',\n        '/usr/local/lib/python3.12/site-packages',\n        '/usr/lib64/python27.zip',\n        '/usr/lib64/python2.7',\n        '/usr/lib64/python2.7/plat-linux2',\n        '/usr/lib64/python2.7/lib-tk',\n        '/usr/lib64/python2.7/lib-old',\n        '/usr/lib64/python2.7/lib-dynload',\n        '/usr/lib64/python2.7/site-packages',\n    ]\n    USER_BASE: '/root/.local' (doesn't exist)\n    USER_SITE: '/root/.local/lib64/python2.7/site-packages' (doesn't exist)\n    ENABLE_USER_SITE: True\n\nOr for Python 3:\n\n    kong ~ # python3 -m site\n    sys.path = [\n        '/root',\n        '/usr/local/lib/python3.13t/site-packages',\n        '/usr/lib/python313t.zip',\n        '/usr/lib/python3.13t',\n        '/usr/lib/python3.13t/lib-dynload',\n        '/usr/lib/python3.13t/site-packages',\n    ]\n    USER_BASE: '/root/.local' (exists)\n    USER_SITE: '/root/.local/lib/python3.13t/site-packages' (doesn't exist)\n    ENABLE_USER_SITE: True\n\nWhat is the difference between 'site-packages' and 'dist-packages'?\n\nThis is where pip enters the discussion.  Some (Debian derived) distros\nhave the system installed (apt) call pip to install some system python\nmodules.  In that case:\n\n1. Drectly installed (apt) system python packages go in:\n\n     /usr/lib/pythonX.Y/\n\n2. Indirectly installed (apt called pip)  python packages go in\n\n    /usr/lib/pythonX.Y/dist-packages/\n\n3. User installed (user called pip) python packages go in\n\n    /usr/local/lib/pythonX.Y/dist-packages/\n\n4. User installed (user compiled) python packages go in\n\n    /usr/local/lib/pythonX.Y/site-packages/\n\nSo dist-packages means the package is managed by pip.  Split into\nwhen the system installed using pip, or the user installed using pip.\n\nAnd site-packages means the package is not managed by the system (apt)\nor by pip.  That would be user compilef NTPSec and gpsd.\n\nMore detail at [DEVIANT]\n\nThere are several ways to make user compiled and installed packages\nwork.\n\n1: You can modify the location where waf will install the libraries.\nFor NetBSD, something like this should work:\n\n  ./waf configure \\\n    --pythondir=/usr/pkg/lib/python2.7/site-packages \\\n    --pythonarchdir=/usr/pkg/lib/python2.7/site-packages \\\n    ...\n\nYou need to specify it at configure time.  Install time is too late.\n\nNote: Distros do not want users installing modules in the\ndistro reserved areas.  It violates the FHS.\n\n2: You can setup your PYTHONPATH with something like this:\n\n  export PYTHONPATH=/usr/local/lib/python3.13t/site-packages\n\nSee [PATHS].\n\nFor bash, you can add that line to your .bashrc or the system\n/etc/bashrc If you don't put it in the system file, all users will have\nto do this, every time they login login.  Including root if root uses\nany ntp scripts.\n\n3: You can add to the default search path by setting up a .pth file\nwith something like this:\n\n  echo /usr/local/lib64/python3.11/site-packages \u003e \\\n    /usr/lib/python3.11/site-packages/ntpsec.pth\n\nThis works for all users, including root.\nNote that the pth file must be on the default Python search path.\n\nOTOH if you run into something like:\n\n    Traceback (most recent call last):\n      File \"/usr/bin/ntpdig\", line 419, in \u003cmodule\u003e\n        timeout=timeout)\n      File \"/usr/bin/ntpdig\", line 109, in queryhost\n        keyid, keytype, passwd)\n      File \"/usr/lib/python3/dist-packages/ntp/packet.py\", line 1747, in compute_mac\n        if not ntp.ntpc.checkname(keytype):\n    AttributeError: module 'ntp.ntpc' has no attribute 'checkname'\n\nThen you probably want to either uninstall the previous Python extension, or\ninstall one after 1.1.9 (798b93) by adding the '--enable-pylib ext' option\nwithout quotes.\n\nOTOH if you are running into something like:\n\n    Traceback (most recent call last):\n    File \"/usr/bin/ntpdig\", line 19, in \u003cmodule\u003e\n        import ntp.packet\n    File \"/usr/lib/python3/dist-packages/ntp/packet.py\", line 219, in \u003cmodule\u003e\n        import ntp.ntpc\n    File \"/usr/lib/python3/dist-packages/ntp/ntpc.py\", line 52, in \u003cmodule\u003e\n        _ntpc = _importado()\n    File \"/usr/lib/python3/dist-packages/ntp/ntpc.py\", line 38, in _importado\n        return _dlo(ntpc_paths)\n    File \"/usr/lib/python3/dist-packages/ntp/ntpc.py\", line 49, in _dlo\n        raise OSError(\"Can't find %s library\" % LIB)\n    OSError: Can't find ntpc library\n\nThat means that ntpc.py looked for libntpc.so in the usual places and could\nnot find it.  If it is being installed to the wrong location on your platform,\nyou can correct the install location using: waf configure --libdir=  If you\nare intentionally installing to a non-default location, you can modify the\ndynamic linker's search path globally (e.g. /etc/ld.so.conf or\n/etc/ld.so.conf.d/) or in your environment (e.g. LD_LIBRARY_PATH).\n\nOn some platforms, it is necessary to run ldconfig after installing libraries.\nThis is normally done by the waf install step, but it may have failed.  When\nusing a temporary --destdir (e.g. as part of package builds), ldconfig must be\nrun manually after the library is installed to its final location.\n\nWhat about \"virtuaal environments\"?\n\nVirtual Environments (venv) [VENV] are a way for a user to install\npython version 3 modules for a specific user, and specific use, without\ninterfering with other modules installed by the specific user, or the\nsystem wide python.  Since NTPSec, and gpsd, are intended to be used by\nroot, and all users, on a system, it is not appropriate to use install\nthem into a venv.\n\nHow do 'python', 'python2' and 'python3' differ?\n\nUpstream tackles this issue in Python Enhancement Proposal (PEP) 394,\nnamed 'The “python” Command on Unix-Like Systems'[PEP394].  Be\ncareful to use the latest PEP 394 version, they keep changing their\nminds.\n\n    \"Depending on a distribution or system configuration, python may or\n    may not be installed. If python is installed its target interpreter\n    may refer to python2 or python3. \"\n\nSo, no help at all.  But well worth reading the entire PEP.  You need to\nrefer to your distributions documentation, if you can find it.\n\nWhen in doubt, since python2 is, still, almost dead, use python3.\n\nSadly, every distribution has a sightly different answer to changing the\npython linkage.  Changing an existing python link often has unintended\nconsequences.\n\nUbuntu: Ubuntu does not trust the sysadmin to understand symlinks.\nTo point python to python3:\n\n    apt install python-is-python3\n\nTo point python to python2:\n\n    apt install python-is-python2\n\nGentoo: Gentoo allows the user to configure what Python version the\n'python' command points to with this command:\n\n    eselect python list\n\n\nTODO: \n\nLook into using .pth files to avoid much of this mess.\n\nReferences:\n\n[FHS] Filesystem Hierarchy Standard Version 3.0\n      https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html\n\n[DEVIANT]  Debian Python Wiki -- Deviations from upstream\n           https://wiki.debian.org/Python#Deviations_from_upstream\n\n[PATHS] The Module Search Path\n        https://docs.python.org/2/tutorial/modules.html#the-module-search-path\n        https://docs.python.org/3/tutorial/modules.html#the-module-search-path\n\n[VENV] venv — Creation of virtual environments¶\n       https://docs.python.org/3/library/venv.html\n\n[PEP394] PEP 394 – The “python” Command on Unix-Like Systems\n         https://peps.python.org/pep-0394/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntpsec%2Fntpsec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fntpsec%2Fntpsec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntpsec%2Fntpsec/lists"}