Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add python 3.12 to the build and drop python 3.8 #4716

Merged
merged 29 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/basic-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
max-parallel: 60
matrix:
os: [ubuntu-20.04]
python-version: [3.8, 3.9, '3.10', '3.11']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we dropping 3.9 from the basic tests as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add this back. 3.9 is past EOL, but we can remove later after the docker / venv images are also updated and pycbc live is moved to a newer python version. I believe those are the hangups for 3.9.

python-version: ['3.9', '3.10', '3.11', '3.12']
test-type: [unittest, search, docs]
steps:
- uses: actions/checkout@v3
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ jobs:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: '3.10'
- name: Install cibuildwheel
run: python -m pip install cibuildwheel
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BUILD: cp38-* cp39-* cp310-* cp311-*
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-*
CIBW_SKIP: "*musllinux*"
CIBW_ARCHS_MACOS: x86_64 arm64
- uses: actions/upload-artifact@v2
Expand All @@ -40,10 +40,10 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: '3.10'
- uses: actions/download-artifact@v2
with:
path: ./
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/inference-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: '3.10'
- name: install condor
run: |
wget -qO - https://research.cs.wisc.edu/htcondor/ubuntu/HTCondor-Release.gpg.key | sudo apt-key add -
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/mac-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
max-parallel: 4
matrix:
os: [macos-12]
python-version: [3.8, 3.9, '3.10', '3.11']
python-version: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -25,5 +25,4 @@ jobs:
pip install --upgrade pip setuptools "tox<4.0.0"
- name: run basic pycbc test suite
run: |
sudo chmod -R 777 /usr/local/miniconda/
tox -e py-unittest
2 changes: 1 addition & 1 deletion .github/workflows/search-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: '3.10'
- name: install condor
run: |
wget -qO - https://research.cs.wisc.edu/htcondor/ubuntu/HTCondor-Release.gpg.key | sudo apt-key add -
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tmpltbank-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: '3.10'
- name: install condor
run: |
wget -qO - https://research.cs.wisc.edu/htcondor/ubuntu/HTCondor-Release.gpg.key | sudo apt-key add -
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tut-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
max-parallel: 60
matrix:
os: [ubuntu-20.04]
python-version: [3.8, 3.9, '3.10', '3.11']
python-version: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: '3.10'
- name: install condor
run: |
wget -qO - https://research.cs.wisc.edu/htcondor/ubuntu/HTCondor-Release.gpg.key | sudo apt-key add -
Expand Down
4 changes: 2 additions & 2 deletions bin/all_sky_search/pycbc_cut_merge_triggers_to_tmpltbank
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ Reduce a MERGE triggers file to a reduced template bank
"""

import logging
import imp
import argparse
import numpy
import h5py
import pycbc
from pycbc.io import HFile
from pycbc import load_source

parser = argparse.ArgumentParser(description=__doc__)
pycbc.add_common_pycbc_options(parser)
Expand All @@ -50,7 +50,7 @@ pycbc.init_logging(opt.verbose)

bank_fd = HFile(opt.full_template_bank, 'r')

modl = imp.load_source('filter_func', opt.filter_func_file)
modl = load_source('filter_func', opt.filter_func_file)
func = modl.filter_tmpltbank
bool_arr = func(bank_fd)

Expand Down
4 changes: 2 additions & 2 deletions bin/all_sky_search/pycbc_reduce_template_bank
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ Reduce a template bank using some input parameter cuts

import numpy
import logging
import imp
import argparse
import pycbc
from pycbc.io import HFile
from pycbc import load_source

parser = argparse.ArgumentParser(description=__doc__)
pycbc.add_common_pycbc_options(parser)
Expand All @@ -48,7 +48,7 @@ pycbc.init_logging(opt.verbose)

bank_fd = HFile(opt.input_bank, 'r')

modl = imp.load_source('filter_func', opt.filter_func_file)
modl = load_source('filter_func', opt.filter_func_file)
func = modl.filter_tmpltbank
bool_arr = func(bank_fd)

Expand Down
5 changes: 2 additions & 3 deletions bin/pycbc_banksim_match_combine
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ a set of injection files. The *order* of the injection files *must* match the
bank files, and the number of injections in each must correspond one-to-one.
"""

import imp
import argparse
import numpy as np

Expand All @@ -33,7 +32,7 @@ from pycbc import pnutils
from pycbc.waveform import TemplateBank
from pycbc.io.ligolw import LIGOLWContentHandler
from pycbc.io.hdf import HFile

from pycbc import load_source

__author__ = "Ian Harry <[email protected]>"
__version__ = pycbc.version.git_verbose_msg
Expand Down Expand Up @@ -137,7 +136,7 @@ for val in trig_par_list:
f['trig_params/{}'.format(val)] = trig_params[val]

if options.filter_func_file:
modl = imp.load_source('filter_func', options.filter_func_file)
modl = load_source('filter_func', options.filter_func_file)
func = modl.filter_injections
bool_arr = func(inj_params['mass1'], inj_params['mass2'],
inj_params['spin1z'], inj_params['spin2z'])
Expand Down
15 changes: 15 additions & 0 deletions pycbc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import logging
import random
import string
import importlib.util
import importlib.machinery
from datetime import datetime as dt

try:
Expand Down Expand Up @@ -227,3 +229,16 @@ def gps_now():
from astropy.time import Time

return float(Time.now().gps)

# This is needed as a backwards compatibility. The function was removed in
# python 3.12.
def load_source(modname, filename):
loader = importlib.machinery.SourceFileLoader(modname, filename)
spec = importlib.util.spec_from_file_location(modname, filename,
loader=loader)
module = importlib.util.module_from_spec(spec)
# The module is always executed and not cached in sys.modules.
# Uncomment the following line to cache the module.
# sys.modules[module.__name__] = module
loader.exec_module(module)
return module
14 changes: 2 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
[build-system]
requires = ["setuptools",
"wheel",
"cython>=3.0.0",
"numpy==1.16.0; python_version <= '3.7'",
"numpy==1.17.3; python_version == '3.8'",
"numpy==1.19.3; python_version == '3.9'",
"numpy==1.21.4; python_version =='3.10'",
"numpy==1.23.4; python_version=='3.11'",
"numpy; python_version >= '3.12'",
"cython>=0.29.21",
"numpy>=2.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change PR title to indicate that this now makes pycbc require numpy 2 as well as dropping python versions?

Copy link
Contributor

@titodalcanton titodalcanton Jul 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it actually necessary to require Numpy 2? As far as I understood it was supposed to maintain some level of backward compatibility.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't require numpy 2.0. However, to work with 2.0 it must be built with 2.0. They have added in 2.0 the ability for ABI to be backwards compatible, so when it is built with 2.0 it will still work with 1.XX.

See

https://numpy.org/devdocs/dev/depending_on_numpy.html#numpy-2-0-specific-advice

That's why i did not update the setup.py or requirements file at hte same time, only the pyproject.toml which dictates how the build itself is done.

]

# To ensure the best compatibility, try to match the numpy reqs
# where possible to the following used by scipy and the minimum
# of our normal numpy requirements in setup.py
# https://github.com/scipy/oldest-supported-numpy/blob/master/setup.cfg
1 change: 1 addition & 0 deletions requirements-igwn.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# For LDG service access
ligo-proxy-utils
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this needed for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spxiwh That's a question for you all actually. If it's not needed we can remove it. However, it was hard coded in the workflow whereas if it is needed it should be in the requirements rather than installed by hand.

ciecplib[kerberos] >= 0.7.0
dqsegdb2 >= 1.1.4
amqplib
Expand Down
103 changes: 24 additions & 79 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
"""

import sys
import os, subprocess, shutil
import os, subprocess
import platform

from distutils.command.clean import clean as _clean

from setuptools import Extension, setup, Command
from setuptools.command.build_ext import build_ext as _build_ext
from setuptools import find_packages
Expand Down Expand Up @@ -83,27 +81,6 @@ def run(self):

_build_ext.run(self)


# Add swig-generated files to the list of things to clean, so they
# get regenerated each time.
class clean(_clean):
def finalize_options (self):
_clean.finalize_options(self)
self.clean_files = []
self.clean_folders = ['docs/_build']
def run(self):
_clean.run(self)
for f in self.clean_files:
try:
os.unlink(f)
print('removed ' + f)
except:
pass

for fol in self.clean_folders:
shutil.rmtree(fol, ignore_errors=True)
print('removed ' + fol)

def get_version_info():
"""Get VCS info and write version info to version.py.
"""
Expand Down Expand Up @@ -192,7 +169,6 @@ def run(self):
cmdclass = {
'build_docs': build_docs,
'build_gh_pages': build_gh_pages,
'clean': clean,
'build_ext': cbuild_ext
}

Expand All @@ -209,12 +185,21 @@ def run(self):
# do the actual work of building the package
VERSION = get_version_info()

cythonext = ['waveform.spa_tmplt',
'waveform.utils',
'types.array',
'filter.matchedfilter',
'vetoes.chisq']
cythonext = ['pycbc.waveform.spa_tmplt_cpu',
'pycbc.waveform.utils_cpu',
'pycbc.types.array_cpu',
'pycbc.filter.matchedfilter_cpu',
'pycbc.vetoes.chisq_cpu',
"pycbc.fft.fftw_pruned_cython",
"pycbc.events.eventmgr_cython",
"pycbc.events.simd_threshold_cython",
"pycbc.filter.simd_correlate_cython",
"pycbc.waveform.decompress_cpu_cython",
"pycbc.inference.models.relbin_cpu",
]
ext = []

libraries = ['m'] # Some platforms / toolchains don't implicitly link this
cython_compile_args = ['-O3', '-w', '-ffast-math',
'-ffinite-math-only']

Expand All @@ -233,57 +218,18 @@ def run(self):
cython_compile_args += ["-stdlib=libc++"]
cython_link_args += ["-stdlib=libc++"]


for name in cythonext:
e = Extension("pycbc.%s_cpu" % name,
["pycbc/%s_cpu.pyx" % name.replace('.', '/')],
fname = name.replace('.', '/')
e = Extension(name,
[f"{fname}.pyx"],
language='c++',
extra_compile_args=cython_compile_args,
extra_link_args=cython_link_args,
libraries=libraries,
compiler_directives={'embedsignature': True})
ext.append(e)

# Not all modules work like this:
e = Extension("pycbc.fft.fftw_pruned_cython",
["pycbc/fft/fftw_pruned_cython.pyx"],
extra_compile_args=cython_compile_args,
extra_link_args=cython_link_args,
compiler_directives={'embedsignature': True})
ext.append(e)
e = Extension("pycbc.events.eventmgr_cython",
["pycbc/events/eventmgr_cython.pyx"],
extra_compile_args=cython_compile_args,
extra_link_args=cython_link_args,
compiler_directives={'embedsignature': True})
ext.append(e)
e = Extension("pycbc.events.simd_threshold_cython",
["pycbc/events/simd_threshold_cython.pyx"],
language='c++',
extra_compile_args=cython_compile_args,
extra_link_args=cython_link_args,
compiler_directives={'embedsignature': True})
ext.append(e)
e = Extension("pycbc.filter.simd_correlate_cython",
["pycbc/filter/simd_correlate_cython.pyx"],
language='c++',
extra_compile_args=cython_compile_args,
extra_link_args=cython_link_args,
compiler_directives={'embedsignature': True})
ext.append(e)
e = Extension("pycbc.waveform.decompress_cpu_cython",
["pycbc/waveform/decompress_cpu_cython.pyx"],
language='c++',
extra_compile_args=cython_compile_args,
extra_link_args=cython_link_args,
compiler_directives={'embedsignature': True})
ext.append(e)
e = Extension("pycbc.inference.models.relbin_cpu",
["pycbc/inference/models/relbin_cpu.pyx"],
language='c++',
extra_compile_args=cython_compile_args,
extra_link_args=cython_link_args,
compiler_directives={'embedsignature': True})
ext.append(e)


setup(
name = 'PyCBC',
version = VERSION,
Expand All @@ -292,7 +238,7 @@ def run(self):
long_description_content_type='text/markdown',
author = 'The PyCBC team',
author_email = '[email protected]',
url = 'http://www.pycbc.org/',
url = 'http://pycbc.org/',
download_url = f'https://github.com/gwastro/pycbc/tarball/v{VERSION}',
keywords = [
'ligo',
Expand All @@ -313,14 +259,13 @@ def run(self):
'pycbc.neutron_stars': find_files('pycbc/neutron_stars')
},
ext_modules = ext,
python_requires='>=3.7',
python_requires='>=3.9',
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Intended Audience :: Science/Research',
'Natural Language :: English',
'Topic :: Scientific/Engineering',
Expand Down
1 change: 0 additions & 1 deletion tools/docker_build_dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ if [ "x${PYCBC_CONTAINER}" == "xpycbc_rhel_virtualenv" ]; then
yum clean all
yum makecache
yum -y install openssl-devel
yum -y install ligo-proxy-utils
yum -y install python3-virtualenv
yum -y install hdf5-static libxml2-static zlib-static libstdc++-static cfitsio-static glibc-static swig fftw-static gsl-static --skip-broken

Expand Down
Loading
Loading