From bcfa62a5b560335d1c1d210a8eebd2d4a6f99591 Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Thu, 9 Nov 2023 16:28:03 +0000 Subject: [PATCH] update packaging to use toml --- .pre-commit-config.yaml | 4 +- CMakeLists.txt | 23 ------- MANIFEST.in | 6 -- bld.bat | 2 - build.sh | 1 - buildconfig/CMake/Bootstrap.cmake | 8 --- buildconfig/CMake/CommonSetup.cmake | 61 ------------------ buildconfig/CMake/FindGitLFS.cmake | 29 --------- conda_build_config.yaml | 2 - environment.yml | 5 +- install-requirements.txt | 5 -- meta.yaml | 38 ------------ scripts/__init__.py | 0 scripts/test.py | 3 - setup-requirements.txt | 0 setup.cfg | 11 ---- setup.py | 96 ----------------------------- test-requirements.txt | 2 - 18 files changed, 4 insertions(+), 292 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 MANIFEST.in delete mode 100644 bld.bat delete mode 100644 build.sh delete mode 100644 buildconfig/CMake/Bootstrap.cmake delete mode 100644 buildconfig/CMake/CommonSetup.cmake delete mode 100644 buildconfig/CMake/FindGitLFS.cmake delete mode 100644 conda_build_config.yaml delete mode 100644 install-requirements.txt delete mode 100644 meta.yaml delete mode 100644 scripts/__init__.py delete mode 100644 scripts/test.py delete mode 100644 setup-requirements.txt delete mode 100644 setup.cfg delete mode 100644 setup.py delete mode 100644 test-requirements.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9ac5fa67..5e8e76c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ default_language_version: repos: # Run fast code improvement/checks before running PR specific helpers. - repo: https://github.com/pre-commit/pre-commit-hooks.git - rev: v4.3.0 + rev: v4.4.0 hooks: - id: trailing-whitespace args: [--markdown-linebreak-ext=md] @@ -15,7 +15,7 @@ repos: exclude: 'EVSVesuvio/experiments/original_inputs|unpackaged' - repo: https://gitlab.com/pycqa/flake8.git - rev: 5.0.4 + rev: 6.1.0 hooks: - id: flake8 args: ['--config', 'config.flake8'] diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index ec084d62..00000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -# CMake version check. -cmake_minimum_required(VERSION 3.16) - -# Define the project name. -project(EVSVesuvio) - -# Policy settings -if(POLICY CMP0022) - cmake_policy(SET CMP0022 NEW) -endif() - -if(POLICY CMP0074) - cmake_policy(SET CMP0074 NEW) -endif() - -# Add the path to our custom 'find' modules -set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/buildconfig/CMake") - -# Bootstrap any dependencies -include(Bootstrap) - -# Cross-platform setup -include(CommonSetup) \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 9b422cb4..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -include setup-requirements.txt -include install-requirements.txt -include test-requirements.txt -include MANIFEST.in -recursive-include EVSvesuvio/vesuvio_analysis/ip_files *.OPJ *.par *.DAT *.DAT3 *.DAT6 *.txt -recursive-include EVSvesuvio/experiments *.NXS *.nxs *.npz *.txt \ No newline at end of file diff --git a/bld.bat b/bld.bat deleted file mode 100644 index 417479da..00000000 --- a/bld.bat +++ /dev/null @@ -1,2 +0,0 @@ -"%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt -if errorlevel 1 exit 1 \ No newline at end of file diff --git a/build.sh b/build.sh deleted file mode 100644 index 845daf47..00000000 --- a/build.sh +++ /dev/null @@ -1 +0,0 @@ -$PYTHON setup.py install --single-version-externally-managed --record=record.txt \ No newline at end of file diff --git a/buildconfig/CMake/Bootstrap.cmake b/buildconfig/CMake/Bootstrap.cmake deleted file mode 100644 index 9bdb9add..00000000 --- a/buildconfig/CMake/Bootstrap.cmake +++ /dev/null @@ -1,8 +0,0 @@ -### Configure required dependencies if necessary -# Find git for everything -if(WIN32) - set(_git_requires 1.9.5) -endif() -find_package(Git ${_git_requires}) - -set(MSVC_PYTHON_EXECUTABLE_DIR $ENV{CONDA_PREFIX}) \ No newline at end of file diff --git a/buildconfig/CMake/CommonSetup.cmake b/buildconfig/CMake/CommonSetup.cmake deleted file mode 100644 index b3e9655f..00000000 --- a/buildconfig/CMake/CommonSetup.cmake +++ /dev/null @@ -1,61 +0,0 @@ -### Put hooks from tracked /.githooks into .git/hooks -# First need to find the top-level directory of the git repository -execute_process( - COMMAND ${GIT_EXECUTABLE} rev-parse --show-toplevel - OUTPUT_VARIABLE GIT_TOP_LEVEL - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} -) -# N.B. The variable comes back from 'git describe' with a line feed on the end, so we need to lose that -string(REGEX MATCH "(.*)[^\n]" GIT_TOP_LEVEL ${GIT_TOP_LEVEL}) -# Prefer symlinks on platforms that support it so we don't rely on cmake running to be up-to-date On Windows, we -# have to copy the file -if(WIN32) - execute_process( - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${GIT_TOP_LEVEL}/.githooks/commit-msg ${GIT_TOP_LEVEL}/.git/hooks - ) -else() - execute_process( - COMMAND ${CMAKE_COMMAND} -E create_symlink ${GIT_TOP_LEVEL}/.githooks/commit-msg - ${GIT_TOP_LEVEL}/.git/hooks/commit-msg - ) -endif() - -### Set up pre-commit, adds script to .git/hooks -# Windows should use downloaded ThirdParty version of pre-commit.cmd Everybody else should find one in their PATH -find_program( - PRE_COMMIT_EXE - NAMES pre-commit - HINTS ~/.local/bin/ "${MSVC_PYTHON_EXECUTABLE_DIR}/Scripts/" -) -if(NOT PRE_COMMIT_EXE) - message(FATAL_ERROR "Failed to find pre-commit ensure conda environment is active") -endif() -if(WIN32) - execute_process( - COMMAND "${PRE_COMMIT_EXE}" install --overwrite - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE PRE_COMMIT_RESULT - ) - if(NOT PRE_COMMIT_RESULT EQUAL "0") - message(FATAL_ERROR "Pre-commit install failed with ${PRE_COMMIT_RESULT}") - endif() - # Create pre-commit script wrapper to use mantid third party python for pre-commit - file(TO_CMAKE_PATH $ENV{CONDA_PREFIX} CONDA_SHELL_PATH) - file(RENAME "${PROJECT_SOURCE_DIR}/.git/hooks/pre-commit" "${PROJECT_SOURCE_DIR}/.git/hooks/pre-commit-script.py") - file( - WRITE "${PROJECT_SOURCE_DIR}/.git/hooks/pre-commit" - "#!/usr/bin/env sh\n${CONDA_SHELL_PATH}/Scripts/wrappers/conda/python.bat ${PROJECT_SOURCE_DIR}/.git/hooks/pre-commit-script.py" - ) -else() # linux as osx - execute_process( - COMMAND bash -c "${PRE_COMMIT_EXE} install" - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - RESULT_VARIABLE STATUS - ) - if(STATUS AND NOT STATUS EQUAL 0) - message( - FATAL_ERROR - "Pre-commit tried to install itself into your repository, but failed to do so. Is it installed on your system?" - ) - endif() - endif() \ No newline at end of file diff --git a/buildconfig/CMake/FindGitLFS.cmake b/buildconfig/CMake/FindGitLFS.cmake deleted file mode 100644 index 16c27050..00000000 --- a/buildconfig/CMake/FindGitLFS.cmake +++ /dev/null @@ -1,29 +0,0 @@ -# .rst: FindGitLFS -# ---------- -# -# The module defines the following variables: -# -# :: -# -# GITLFS_EXECUTABLE - path to git-lfs command line client GITLFS_FOUND - true if the command line client was found -# -# Example usage: -# -# :: -# -# find_package(GitLFS) if(GITLFS_FOUND) message("git found: ${GITLFS_EXECUTABLE}") endif() - -set(gitlfs_names git-lfs) - -find_program( - GITLFS_EXECUTABLE - NAMES ${gitlfs_names} - PATH_SUFFIXES Git/bin Git/mingw64/bin - DOC "git-lfs command line client" -) -mark_as_advanced(GITLFS_EXECUTABLE) - -# Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if all listed variables are TRUE - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GitLFS REQUIRED_VARS GITLFS_EXECUTABLE) diff --git a/conda_build_config.yaml b/conda_build_config.yaml deleted file mode 100644 index 86b425ec..00000000 --- a/conda_build_config.yaml +++ /dev/null @@ -1,2 +0,0 @@ -python: - - 3.8 diff --git a/environment.yml b/environment.yml index 3a1387c0..12a9178a 100644 --- a/environment.yml +++ b/environment.yml @@ -7,10 +7,9 @@ channels: dependencies: - flake8 - conda-wrappers - - pre-commit==2.15 - - cmake=3.19.*|>=3.21.0 + - pre-commit==2.15 #review this - coverage - - mantid==6.6.0 + - mantid==6.7.0 #review this - matplotlib - iminuit - h5py diff --git a/install-requirements.txt b/install-requirements.txt deleted file mode 100644 index a079717c..00000000 --- a/install-requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -python==3.8.* -matplotlib -iminuit -h5py -jacobi==0.4.2 diff --git a/meta.yaml b/meta.yaml deleted file mode 100644 index 2735ebf6..00000000 --- a/meta.yaml +++ /dev/null @@ -1,38 +0,0 @@ - {% set version_tag = environ.get('GIT_DESCRIBE_TAG', '0.0.0') %} - {% set version_number = environ.get('GIT_DESCRIBE_NUMBER', '0') | string %} - {% set version_number = '_' + version_number if version_number != '0' else '' %} - - {% set version = version_tag + version_number %} - -package: - name: EVSvesuvio - version: {{ version }} - -source: - git_url: ./ - -requirements: - host: - - python {{ python }} - - build: - - setuptools - - run: - - python {{ python }} - - mantid>=6.4.0 - - matplotlib - - iminuit - - h5py - - mock - - jacobi==0.4.2 #pinned untill 0.5.0 is proven - -test: - imports: - - EVSvesuvio - -about: - home: https://github.com/mantidproject/vesuvio - license: GPL-3.0-or-later - summary: Vesuvio is an instrument that performs Neuton Compton Scattering, based at ISIS, RAL, UK. This code processes raw output data to determine - nuclear kinetic energies and moment distributions. diff --git a/scripts/__init__.py b/scripts/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/scripts/test.py b/scripts/test.py deleted file mode 100644 index bf4772b8..00000000 --- a/scripts/test.py +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env python3 -def print_test(): - print("test") diff --git a/setup-requirements.txt b/setup-requirements.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index c64147e6..00000000 --- a/setup.cfg +++ /dev/null @@ -1,11 +0,0 @@ -[coverage:run] -branch=1 -source=.. - -[coverage:report] -omit= - *tests* - *unpackaged* -show_missing = True -skip_empty = True -#fail_under = 85 # disabled during development \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index e14b3d89..00000000 --- a/setup.py +++ /dev/null @@ -1,96 +0,0 @@ -""" -EVSVesuvio -============= - -#ABOUT HERE -""" -from __future__ import print_function - -import fnmatch -import os - -from setuptools import find_packages, setup - -from EVSVesuvio import __project_url__, __version__ - -# ============================================================================== -# Constants -# ============================================================================== -NAME = 'EVSVesuvio' -THIS_DIR = os.path.dirname(__file__) -_package_dirs = ['ip_files', 'experiments'] -_package_exts = ['.OPJ', '.par', '.DAT', '.DAT3', '.DAT6', '.txt', '.NXS', '.nxs', '.np'] - - -# ============================================================================== -# Package requirements helper -# ============================================================================== - -def read_requirements_from_file(filepath): - """Read a list of requirements from the given file and split into a - list of strings. It is assumed that the file is a flat - list with one requirement per line. - :param filepath: Path to the file to read - :return: A list of strings containing the requirements - """ - with open(filepath, 'rU') as req_file: - return req_file.readlines() - - -def get_package_data(): - """Return data_files in a platform dependent manner""" - package_data = [] - package_dir = os.path.join(THIS_DIR, NAME) - for root, dirnames, filenames in os.walk(package_dir): - if [dir for dir in _package_dirs if dir in root]: - for ext in _package_exts: - for filename in fnmatch.filter(filenames, f'*{ext}'): - package_data.append(os.path.relpath(os.path.join(root, filename), start=package_dir)) - return {NAME: package_data} - - -# ============================================================================== -# Setup arguments -# ============================================================================== -setup_args = dict(name=NAME, - version=__version__, - description='determine nuclear kinetic energies and moment distributions from Neutron Compton Scattering data', - author='The Mantid Project', - author_email='mantid-help@mantidproject.org', - url=__project_url__, - packages=find_packages(), - package_data=get_package_data(), - # Install this as a directory - zip_safe=False, - classifiers=['Operating System :: MacOS', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: POSIX :: Linux', - 'Programming Language :: Python :: 3.8', - 'Development Status :: 4 - Beta', - 'Topic :: Scientific/Engineering']) - -# ============================================================================== -# Setuptools deps -# ============================================================================== -# Running setup command requires the following dependencies -setup_args['setup_requires'] = read_requirements_from_file(os.path.join(THIS_DIR, 'setup-requirements.txt')) - -# User installation requires the following dependencies -install_requires = setup_args['install_requires'] = \ - read_requirements_from_file(os.path.join(THIS_DIR, 'install-requirements.txt')) -# Testing requires -setup_args['tests_require'] = read_requirements_from_file(os.path.join(THIS_DIR, 'test-requirements.txt')) \ - + install_requires - -# ============================================================================== -# Scripts -# ============================================================================== -# Scripts to be callable from command line -setup_args['entry_points'] = {'console_scripts': - ['run_test=scripts.test:print_test', ], - } - -# ============================================================================== -# Main setup -# ============================================================================== -setup(**setup_args) diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index 3419d264..00000000 --- a/test-requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -mock>=2.0 -coverage \ No newline at end of file