From eee35e8ea60bc6bcd6553b00aca7bc8827cfe19b Mon Sep 17 00:00:00 2001 From: "Kevin R. Thornton" Date: Tue, 9 Apr 2024 10:28:59 -0700 Subject: [PATCH] remove setup.py --- .github/workflows/ubuntu.yml | 7 +- .github/workflows/wheels.yml | 4 +- doc/misc/changelog.md | 2 + setup.py | 141 ----------------------------------- 4 files changed, 7 insertions(+), 147 deletions(-) delete mode 100644 setup.py diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index b6f2ba609..472c26f19 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -104,7 +104,7 @@ jobs: python -m pip install --user --upgrade setuptools wheel python -m pip install --user -r requirements/development.txt # For sdist validation - python -m pip install --user --upgrade twine + python -m pip install --user --upgrade twine build # Needed so that we don't affect building any pip dependencies with these flags - name: Set CPPFLAGS for C++ builds @@ -147,14 +147,13 @@ jobs: - name: Validate the sdist run: | - python setup.py sdist - python setup.py check + python -m build -s . + #python setup.py check python -m twine check dist/*.tar.gz rm -rf dist/*.tar.gz - name: Test pip install from dist in fresh venv run: | - python -m pip install build python -m build -o dist -w . cd dist python -m venv venv diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index e46e81468..d7a8168bf 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -32,8 +32,8 @@ jobs: - name: Build sdist shell: bash run: | - python -m pip install --upgrade pip setuptools - python setup.py sdist + python -m pip install --upgrade pip build + python -m build -s . - name: Upload sdist uses: actions/upload-artifact@v4 diff --git a/doc/misc/changelog.md b/doc/misc/changelog.md index bc4770ef9..572d4956d 100644 --- a/doc/misc/changelog.md +++ b/doc/misc/changelog.md @@ -18,6 +18,8 @@ Build system PR {pr}`1284` * Remove boutique arguments from `setup.py`. PR {pr}`1288` +* Remove `setup.py`. + PR {pr}`1291` CI and deployment diff --git a/setup.py b/setup.py deleted file mode 100644 index 9fdd762b9..000000000 --- a/setup.py +++ /dev/null @@ -1,141 +0,0 @@ -import glob -import os -import platform -import re -import subprocess -import sys -from distutils.version import LooseVersion - -from setuptools import Extension, setup -from setuptools.command.build_ext import build_ext - - -class CMakeExtension(Extension): - def __init__(self, name, sourcedir=""): - Extension.__init__(self, name, sources=[]) - self.sourcedir = os.path.abspath(sourcedir) - - -class CMakeBuild(build_ext): - def run(self): - try: - out = subprocess.check_output(["cmake", "--version"]) - except OSError: - raise RuntimeError( - "CMake must be installed to build the following extensions: " - + ", ".join(e.name for e in self.extensions) - ) - - if platform.system() == "Windows": - cmake_version = LooseVersion( - re.search(r"version\s*([\d.]+)", out.decode()).group(1) - ) - if cmake_version < "3.1.0": - raise RuntimeError("CMake >= 3.1.0 is required on Windows") - - for ext in self.extensions: - self.build_extension(ext) - - def build_extension(self, ext): - extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name))) - parent = os.path.abspath(os.path.dirname(".")) - cmake_args = [ - "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + extdir, - "-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=" + parent + "/lib/", - "-DCMAKE_BUILD=OFF", - ] - - cfg = "Release" - - build_args = ["--config", cfg] - - if platform.system() == "Windows": - cmake_args += [ - "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}".format(cfg.upper(), extdir) - ] - if sys.maxsize > 2**32: - cmake_args += ["-A", "x64"] - build_args += ["--", "/m"] - else: - cmake_args += ["-DCMAKE_BUILD_TYPE=" + cfg] - build_args += ["--", "-j2"] - - env = os.environ.copy() - env["CXXFLAGS"] = '{} -DVERSION_INFO=\\"{}\\"'.format( - env.get("CXXFLAGS", ""), self.distribution.get_version() - ) - - if not os.path.exists(self.build_temp): - os.makedirs(self.build_temp) - - subprocess.check_call( - ["cmake", ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env - ) - subprocess.check_call( - ["cmake", "--build", "."] + build_args, cwd=self.build_temp - ) - - -PKGS = [ - "fwdpy11", - "fwdpy11.conditional_models", - "fwdpy11.tskit_tools", - "fwdpy11._functions", - "fwdpy11._types", -] - -ext_modules = [ - CMakeExtension("fwdpy11._fwdpy11"), -] - - -# Figure out the headers we need to install: -generated_package_data = {} -for root, dirnames, filenames in os.walk("fwdpy11/headers"): - if ( - "testsuite" not in root - and "examples" not in root - and "python_examples" not in root - ): - g = glob.glob(root + "/*.hh") - if len(g) > 0: - replace = root.replace("/", ".") - # If there's a header file, we add the directory as a package - if replace not in PKGS: - PKGS.append(replace) - generated_package_data[replace] = ["*.hh"] - g = glob.glob(root + "/*.hpp") - if len(g) > 0: - replace = root.replace("/", ".") - # If there's a header file, we add the directory as a package - if replace not in PKGS: - PKGS.append(replace) - try: - if "*.hpp" not in generated_package_data[replace]: - generated_package_data[replace].append("*.hpp") - except: # NOQA - generated_package_data[replace] = ["*.hpp"] - g = glob.glob(root + "/*.tcc") - if len(g) > 0: - replace = root.replace("/", ".") - # If there's a template implementation file, - # we add the directory as a package - if replace not in PKGS: - PKGS.append(replace) - try: - if "*.tcc" not in generated_package_data[replace]: - generated_package_data[replace].append("*.tcc") - except: # NOQA - generated_package_data[replace] = ["*.tcc"] - -if platform.system() == "Darwin": - generated_package_data["fwdpy11"] = ["lib*.dylib"] -else: - generated_package_data["fwdpy11"] = ["lib*.so"] - -setup( - ext_modules=ext_modules, - cmdclass={"build_ext": CMakeBuild}, - packages=PKGS, - package_data=generated_package_data, -)