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

Migrate from LFS #75

Merged
merged 91 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
3e98df8
Commit for PR
jncots Oct 7, 2022
e30659c
Functions for downloading db files
jncots Oct 7, 2022
c3e74f4
Add tqdm to installation requirements
jncots Oct 7, 2022
171302a
Add requests library as a requirement
jncots Oct 7, 2022
749a918
wip
HDembinski Oct 7, 2022
2a4b420
wip
HDembinski Oct 7, 2022
c435f58
wip
HDembinski Oct 9, 2022
1bdf7f0
fixes
HDembinski Oct 9, 2022
49b00e3
fix
HDembinski Oct 9, 2022
8ae609a
fixes
HDembinski Oct 9, 2022
31e37d1
fixes
HDembinski Oct 10, 2022
2711d46
speed up test by reducing energy
HDembinski Oct 10, 2022
955e784
nicer name for test, expand comment
HDembinski Oct 10, 2022
4a45d0a
merge main
HDembinski Oct 12, 2022
a775527
we can do without the warning
HDembinski Oct 12, 2022
377838c
fix
HDembinski Oct 12, 2022
271335b
code simplification, adding daugther info to pythia8
HDembinski Oct 13, 2022
4524375
proper parent selection, fixes for to_hepmc3 and IO
HDembinski Oct 13, 2022
21f977f
skip rather than xfail
HDembinski Oct 13, 2022
34f90af
fix manifest
HDembinski Oct 14, 2022
f93c7fc
fix
HDembinski Oct 14, 2022
4c40509
fix
HDembinski Oct 14, 2022
ab129bb
epos tests
HDembinski Oct 14, 2022
0a0ac8d
temporary fix of test
HDembinski Oct 14, 2022
3216c3b
fix
HDembinski Oct 14, 2022
e7ac805
fix
HDembinski Oct 14, 2022
2f2b8e8
fix
HDembinski Oct 14, 2022
40978f8
fix
HDembinski Oct 14, 2022
7f1b21a
cancel in progress
HDembinski Oct 14, 2022
3f50197
Merge branch 'main' into migrate_from_lfs
HDembinski Oct 15, 2022
e0e722f
fix
HDembinski Oct 17, 2022
982e644
Bye bye DPMJETII :'|
afedynitch Oct 19, 2022
60354af
Removed antique eclipse-style tag at file header
afedynitch Oct 19, 2022
7b1cecc
Change pybind11 submodule from https to ssh
afedynitch Oct 19, 2022
285248c
Exclude build dir from MANIFEST
afedynitch Oct 19, 2022
a107577
Add more Pythia8 tests and warn on event rejection
afedynitch Oct 19, 2022
36ecb47
Mold support for GCC<12 dropped
afedynitch Oct 19, 2022
3606235
removed interaction model def
afedynitch Oct 19, 2022
265bcb5
Fixes epos interface to to comply with nuclear PDG ids (#81)
afedynitch Oct 19, 2022
94fac4b
add root writing example
HDembinski Oct 19, 2022
7a7b7eb
trouble-shooting advice for readme
HDembinski Oct 19, 2022
708993c
make parton shower filter public
HDembinski Oct 19, 2022
1516d09
Removed a comment
afedynitch Oct 19, 2022
2d40b9a
move example to correct folder
HDembinski Oct 19, 2022
e8be9c5
suppress numba warning
HDembinski Oct 20, 2022
f59eb8a
pythia8 data files to lfs, test for select_parents
HDembinski Oct 24, 2022
7cb644e
Add lazy downloading and zip extraction
jncots Oct 24, 2022
3b3d0fe
Merge branch 'pythia8' into migrate_from_lfs
jncots Oct 25, 2022
2846ef6
Improved lazy downloading
jncots Oct 25, 2022
846d9c6
Add lazy downloading to models
jncots Oct 25, 2022
439b92f
Change implementation of data files check
jncots Oct 26, 2022
5ce7c9a
Fix path
jncots Oct 26, 2022
a408670
Add check for files to models
jncots Oct 26, 2022
899f712
Merge branch 'main' into migrate_from_lfs
jncots Oct 26, 2022
90ac0aa
Add iamdata_content.json
jncots Oct 26, 2022
a5ccd41
Another version of lazy downloading
jncots Oct 28, 2022
441114f
Change models to use _check_data_dir
jncots Oct 28, 2022
9f68589
Rename _check_data_dir to _cached_data_dir
jncots Oct 28, 2022
2ef33e7
Add url and remove data files
jncots Nov 1, 2022
0f85860
Ignore files in iamdata
jncots Nov 1, 2022
f1fc953
Check tests with data files
jncots Nov 1, 2022
d1831ac
Remove xfail tests on ci
jncots Nov 1, 2022
90665e1
no_proxy to fix problem with Mac
jncots Nov 1, 2022
be5f500
Exclude DPMJET-III from hepmc
jncots Nov 1, 2022
e78e79e
fixing tests
HDembinski Nov 2, 2022
86219cb
whitespace
HDembinski Nov 2, 2022
b90e425
attempt to simplify the path comparison
HDembinski Nov 2, 2022
905e087
Fix small issues
jncots Nov 4, 2022
92f6c23
Add Windows to tests
jncots Nov 4, 2022
d17d2a8
Change to check_call to call
jncots Nov 4, 2022
e6bb40c
Removing -A from cmake_args
jncots Nov 4, 2022
f46a6c1
Move definitions in config
jncots Nov 7, 2022
f17874d
Fixes for Windows
jncots Nov 7, 2022
50da674
Add dlfcn library
jncots Nov 8, 2022
b237629
Small fix
jncots Nov 8, 2022
c7e2a1f
Fix for target_link_libraries
jncots Nov 8, 2022
9347eb0
Check build only for Windows
jncots Nov 8, 2022
6cc2eed
Change install prefix
jncots Nov 8, 2022
43f9fdb
Add additional paths
jncots Nov 8, 2022
76aa9d3
Change library to link with
jncots Nov 8, 2022
32638d7
Add flag to cxx on Windows
jncots Nov 8, 2022
b70f098
Add linking to _pythia8
jncots Nov 8, 2022
1e2cac1
Check if static works
jncots Nov 8, 2022
0995034
Check with all models
jncots Nov 8, 2022
3d30c24
Remove static
jncots Nov 8, 2022
9da8779
Exclude Pythia8 on Windows
jncots Nov 10, 2022
e499c4e
Move directory names from config to models
jncots Nov 10, 2022
a218a58
Change to pass tests
jncots Nov 14, 2022
3560486
Move paths to class variables
jncots Nov 14, 2022
da49635
Remove paths to data from config.py
jncots Nov 14, 2022
47c5410
Move url to class variable
jncots Nov 14, 2022
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
199 changes: 0 additions & 199 deletions .gitattributes

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ jobs:
with:
user: __token__
password: ${{secrets.pypi_password}}

26 changes: 23 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
matrix:
include:
## TODO cannot test on windows for now, fortran compiler is not found
# - os: windows-latest
# python-version: "3.10"
- os: windows-latest
python-version: "3.10"

- os: macos-latest
python-version: "3.7"

# version number must be string, otherwise 3.10 becomes 3.1
# # version number must be string, otherwise 3.10 becomes 3.1
- os: ubuntu-latest
python-version: "3.9"
fail-fast: false
Expand Down Expand Up @@ -61,4 +61,24 @@ jobs:
version: 11
- run: python -m pip install --upgrade pip
- run: python -m pip install --prefer-binary -v .[test]
if: ${{ matrix.os != 'windows-latest' }}


- if: ${{ matrix.os == 'windows-latest' }}
run: |
curl -LJO https://github.com/dlfcn-win32/dlfcn-win32/archive/refs/heads/master.zip
unzip dlfcn-win32-master.zip
python -m pip install cmake
cmake -S ./dlfcn-win32-master -B ./build_dlfcn -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release
cmake --build ./build_dlfcn
cmake --install ./build_dlfcn

- run: python -m pip install --prefer-binary -v .[test]
if: ${{ matrix.os == 'windows-latest' }}
env:
CMAKE_GENERATOR: "MinGW Makefiles"
FC: ${{ steps.setup-fortran.outputs.fc }}

- run: python -m pytest -vv
env:
no_proxy: '*'
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ examples/*.root
tests/*.dat
extra.cfg
pythia*.tgz
impy-?.?.?
impy-?.?.?
src/impy/iamdata
63 changes: 55 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ add_compile_definitions(NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION)
# generator automatically runs the preprocessor on all Fortran files
set(CMAKE_Fortran_FLAGS_RELEASE -O3)


# CMake sets -fPIC etc. automatically, add only unusual options
if (UNIX)
add_compile_options(
Expand All @@ -95,7 +96,15 @@ if (UNIX)
add_compile_options(
$<$<COMPILE_LANGUAGE:Fortran>:-Wno-argument-mismatch>)
endif()
else() # intel
else() # Windows MinGW!
add_compile_options(
-Wno-uninitialized
-w
$<$<COMPILE_LANGUAGE:Fortran>:-std=legacy>
$<$<COMPILE_LANGUAGE:Fortran>:-fno-second-underscore>
$<$<COMPILE_LANGUAGE:Fortran>:-fallow-argument-mismatch>
$<$<COMPILE_LANGUAGE:CXX>:-fpermissive>
)
# TODO
# set(FLAGS -fast -fpe0)
# set(FLAGSF90 ${FLAGS} -ffree-form -Wobsolescent -fno-second-underscore)
Expand Down Expand Up @@ -253,6 +262,7 @@ f2py_add_module(_qgsII04
${impy_definitions}
)

if (NOT WIN32)
### urqmd34
set(urqmd34_sources
1fluid bessel delpart getmass hepcmp iso numrec pythia6409
Expand Down Expand Up @@ -284,6 +294,7 @@ f2py_add_module(_urqmd34
COMPILE_DEFS
${impy_definitions}
)
endif()

### pythia6
f2py_add_module(_pythia6
Expand Down Expand Up @@ -324,7 +335,7 @@ f2py_add_module(_pythia6
# To strengthen this position, we compile the original Pythia-8 code into
# a shared library to which we only link. This makes clear where the boundary
# between impy and Pythia-8 is.

if (NOT WIN32)
file(GLOB pythia8_sources ${cpp_dir}/pythia8307/src/*.cc)

add_library(libpythia8 SHARED ${pythia8_sources})
Expand All @@ -335,6 +346,18 @@ target_compile_definitions(libpythia8 PRIVATE XMLDIR="")

pybind11_add_module(_pythia8 ${cpp_dir}/_pythia8.cpp)
target_link_libraries(_pythia8 PRIVATE libpythia8)
endif()


# This part is needed when we figure out the problem with
# building Pythia8 on Windows
# if (WIN32)
# find_package(dlfcn-win32 REQUIRED)
# set(CMAKE_DL_LIBS dlfcn-win32::dl)
# target_link_libraries(libpythia8 PRIVATE ${CMAKE_DL_LIBS})
# target_link_libraries(_pythia8 PRIVATE ${CMAKE_DL_LIBS})
# target_link_libraries(_pythia8 PRIVATE "-static")
# endif()

### sophia
f2py_add_module(_sophia
Expand Down Expand Up @@ -412,13 +435,39 @@ list(FILTER dpmjetIII191_sources EXCLUDE REGEX PYR\.f)
# cmake does not like filenames with parantheses, but some Fortran files
# include those. As a workaround, we generate modified source files and
# renamed copies of the headers. Not elegant, but works. 🤷‍♂️


### dpmjetIII191
file(GLOB dpmjetIII191_sources
${fortran_dir}/dpmjetIII-19.1/src/phojet/*.f
${fortran_dir}/dpmjetIII-19.1/src/pythia/*.f
${fortran_dir}/dpmjetIII-19.1/src/dpmjet/*.f
)

list(FILTER dpmjetIII191_sources EXCLUDE REGEX DT_RNDM\.f)
list(FILTER dpmjetIII191_sources EXCLUDE REGEX DT_RNDMST\.f)
list(FILTER dpmjetIII191_sources EXCLUDE REGEX DT_RNDMTE\.f)
list(FILTER dpmjetIII191_sources EXCLUDE REGEX PYR\.f)
# cmake does not like filenames with parantheses, but some Fortran files
# include those. As a workaround, we generate modified source files and
# renamed copies of the headers. Not elegant, but works. 🤷‍♂️


# Workaround to workaround :) Windows don't like long lists
# User temporary file to keep long lists
set(temp_dpmjet_file temp.dpmjetIII191)
string(REPLACE ";" " " temp_dpmjet_str "${dpmjetIII191_sources}")
file(WRITE ${temp_dpmjet_file} "${temp_dpmjet_str}")

execute_process(
COMMAND
${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/dpmjetIII191_workaround.py
${CMAKE_CURRENT_BINARY_DIR} ${fortran_dir}/dpmjetIII-19.1/include
${dpmjetIII191_sources}
OUTPUT_VARIABLE dpmjetIII191_modded_sources
${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/dpmjetIII191_workaround.py
${CMAKE_CURRENT_BINARY_DIR}
${fortran_dir}/dpmjetIII-19.1/include
${CMAKE_SOURCE_DIR}/${temp_dpmjet_file}
)
file(READ ${temp_dpmjet_file} dpmjetIII191_modded_sources)
file(REMOVE ${temp_dpmjet_file})


f2py_add_module(_dpmjetIII191
Expand All @@ -439,7 +488,6 @@ f2py_add_module(_dpmjetIII191
${fortran_dir}/dpmjetIII-19.1/include/phojet
${fortran_dir}/dpmjetIII-19.1/include/dpmjet
${fortran_dir}/dpmjetIII-19.1/include/pythia
# ${fortran_dir}/dpmjetIII-19.1/include/flinclude
${CMAKE_CURRENT_BINARY_DIR}/include
COMPILE_DEFS
${impy_definitions}
Expand All @@ -464,7 +512,6 @@ f2py_add_module(_phojet191
${fortran_dir}/dpmjetIII-19.1/include/phojet
${fortran_dir}/dpmjetIII-19.1/include/dpmjet
${fortran_dir}/dpmjetIII-19.1/include/pythia
# ${fortran_dir}/dpmjetIII-19.1/include/flinclude
${CMAKE_CURRENT_BINARY_DIR}/include
COMPILE_DEFS
${impy_definitions}
Expand Down
7 changes: 7 additions & 0 deletions F2Py.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ function (f2py_add_module target_name)
PRIVATE ${F2PY_ADD_MODULE_COMPILE_DEFS})
endif()
target_compile_options(${target_name} PRIVATE -cpp)
# Link dll statically in Windows
# It can be potentially a PROBLEM!!!
# But this is the only way found to build a working library on Windows.
# However, on Linux and MacOS, it throws an error at the linking stage.
if (WIN32)
target_link_libraries(${target_name} PUBLIC "-static")
jncots marked this conversation as resolved.
Show resolved Hide resolved
endif()
set_property(TARGET ${target_name} PROPERTY SUFFIX ${PYTHON_MODULE_EXTENSION})
# must be a string, so that empty string works correcty
set_property(TARGET ${target_name} PROPERTY PREFIX "${PYTHON_MODULE_PREFIX}")
Expand Down
40 changes: 21 additions & 19 deletions cmake_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@

cwd = Path(__file__).parent


# Normal print does not work while CMakeBuild is running
def force_print(msg):
subp.run(["echo", msg])


def cache_value(key, s):
m = re.search(key + r":[A-Z]+=([^\s]*)", s)
m = re.search(key + r":[A-Z]+=(.*)" + "$", s, flags=re.MULTILINE)
assert m, f"{key} is not a cached cmake variable"
return m.group(1)

Expand Down Expand Up @@ -87,6 +88,7 @@ def build_extension(self, ext):

build_args = ["--config", cfg] # needed by some generators, e.g. on Windows

# if cmake_generator in ("Unix Makefiles", "MinGW Makefiles", "MSYS Makefiles"):
if self.compiler.compiler_type == "msvc":
# CMake allows an arch-in-generator style for backward compatibility
contains_arch = any(x in cmake_generator for x in ("ARM", "Win64"))
Expand All @@ -102,9 +104,9 @@ def build_extension(self, ext):
"win-arm32": "ARM",
"win-arm64": "ARM64",
}[self.plat_name]
cmake_args += ["-A", arch]
# cmake_args += ["-A", arch]

cmake_args += [f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{cfg.upper()}={extdir}"]
# cmake_args += [f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{cfg.upper()}={extdir}"]

elif sys.platform.startswith("darwin"):
# Cross-compile support for macOS - respect ARCHFLAGS if set
Expand All @@ -128,22 +130,22 @@ def build_extension(self, ext):
if cmake_cache.exists():
with cmake_cache.open() as f:
s = f.read()
cached_generator = cache_value("CMAKE_GENERATOR", s)
cached_cfg = cache_value("CMAKE_BUILD_TYPE", s)
disagreement = []
for arg in cmake_args:
if arg.startswith("-D"):
key, value = arg[2:].split("=")
cached_value = cache_value(key, s)
disagreement.append(value != cached_value)
if any(
disagreement
+ [
(cmake_generator and cached_generator != cmake_generator),
cached_cfg != cfg,
]
):
cmake_cache.unlink()
cached_generator = cache_value("CMAKE_GENERATOR", s)
cached_cfg = cache_value("CMAKE_BUILD_TYPE", s)
disagreement = [
(cmake_generator and cached_generator != cmake_generator),
cached_cfg != cfg,
]
for arg in cmake_args:
if arg.startswith("-D"):
key, value = arg[2:].split("=")
cached_value = cache_value(key, s)
# Change \ to / in case of Windows
disagreement.append(
Path(value).absolute() != Path(cached_value).absolute()
)
if any(disagreement):
cmake_cache.unlink()

# run cmake setup only once
if not cmake_cache.exists():
Expand Down
11 changes: 7 additions & 4 deletions dpmjetIII191_workaround.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import re
import sys
import shutil
import os

this_program = Path(sys.argv[0]).name

Expand All @@ -22,14 +21,16 @@
for fn in Path(d).rglob("*.f"):
src.append(fn)
else:
cmake_binary_dir, inc_dir, *src = sys.argv[1:]
with Path(sys.argv[3]).open() as f:
src = f.read().split()
cmake_binary_dir, inc_dir = sys.argv[1:3]

src = [Path(x) for x in src]
inc_dir = Path(inc_dir)
cmake_binary_dir = Path(cmake_binary_dir)

dst_include = cmake_binary_dir / "include"
dst_include.mkdir(exist_ok=True)
dst_include.mkdir(parents=True, exist_ok=True)
for fn in inc_dir.rglob("(*)"):
shutil.copy(fn, dst_include / fn.name[1:-1])

Expand Down Expand Up @@ -64,4 +65,6 @@
out = list(map(str, unchanged))
out += list(map(str, modded))

sys.stdout.write(";".join(out))

with open(sys.argv[3], "w") as f:
f.write(";".join(out).replace("\\", "/"))
20 changes: 13 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
from setuptools import setup
import sys
import subprocess as subp
import platform
import os

cwd = Path(__file__).parent

sys.path.append(str(cwd))
from cmake_ext import CMakeExtension, CMakeBuild # noqa: E402

if (cwd / ".git").exists():
# make sure that submodules are up-to-date,
# it is a common error to forget this when
# switching between development branches
subp.check_call(["git", "submodule", "update"])
if not os.environ.get("CI", False):
if (cwd / ".git").exists():
# make sure that submodules are up-to-date,
# it is a common error to forget this when
# switching between development branches
subp.check_call(["git", "submodule", "update"])

models = [
"eposlhc",
Expand All @@ -23,7 +26,6 @@
"qgs01",
"qgsII03",
"qgsII04",
"urqmd34",
"pythia6",
"sophia",
"dpmjet306",
Expand All @@ -32,9 +34,13 @@
"phojet193",
"dpmjetIII191",
"dpmjetIII193",
"pythia8",
]

# urqmd34 doesn't build correctly on Windows
if platform.system() != "Windows":
models.append("urqmd34")
models.append("pythia8")

# for convenience, support building extra models via extra.cfg
# extra.cfg is not tracked by git, so can be freely modified
# extra.cfg example:
Expand Down
2 changes: 1 addition & 1 deletion src/f2py/_eposlhc-f2pywrappers.f
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
C -*- fortran -*-
C This file is autogenerated with f2py (version:1.23.1)
C This file is autogenerated with f2py (version:2)
C It contains Fortran 77 wrappers to fortran functions.

subroutine f2pywrapidtrafo (idtrafof2pywrap, code1, code2, i
Expand Down
5 changes: 2 additions & 3 deletions src/f2py/_eposlhc.pyf
Original file line number Diff line number Diff line change
Expand Up @@ -8956,6 +8956,5 @@ python module _eposlhc ! in
end interface
end python module _eposlhc

! This file was auto-generated with f2py (version:1.23.1).
! See:
! https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e
! This file was auto-generated with f2py (version:2).
! See http://cens.ioc.ee/projects/f2py2e/
Loading