Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
HDembinski committed Sep 2, 2022
1 parent 14e6600 commit b1580c9
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
MANIFEST
.DS_Store
var
build
Expand Down
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ if(MSVC)
target_compile_options(_core PRIVATE /bigobj)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
else()
target_compile_options(_core PRIVATE -fvisibility=hidden -Wall
-Wno-self-assign-overloaded)
target_compile_options(_core PRIVATE -Wall -Wno-self-assign-overloaded)
endif()
set_target_properties(_core PROPERTIES VISIBILITY_INLINES_HIDDEN ON)
target_compile_definitions(_core PRIVATE HEPMC3_HEPEVT_NMXHEP=10000)
3 changes: 0 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
HepMC3 code in path src/HepMC3 is distributed under GPL-v3, see
src/HepMC3/LICENCE. The rest of the code is covered by the following license:

BSD 3-Clause License

Copyright (c) 2018, Hans Dembinski
Expand Down
69 changes: 69 additions & 0 deletions LICENSES_bundled
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
The pyhepmc repository and source distributions bundle a number of libraries that
are compatibly licensed. We list these here.

Name: HepMC3
Files: extern/HepMC3/*
License: LGPL-v3
For details, see extern/HepMC3/LICENCE

Name: pybind11
Files: extern/pybind11/*
License:
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>, All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Name: cpp-member-accessor
Files: extern/cpp-member-accessor/*
License: MIT
For details, see extern/cpp-member-accessor/LICENSE

Name: Boost Mp11
Files: extern/mp11/*
License:
Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
4 changes: 1 addition & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ recursive-include extern/cpp-member-accessor/include *.hpp
recursive-include extern/mp11/include *.hpp
include extern/pybind11/CMakeLists.txt
include extern/pybind11/tools/*.cmake
include extern/pybind11/LICENSE
include extern/HepMC3/LICENCE
include extern/cpp-member-accessor/LICENSE
include cmake_ext.py
include CMakeLists.txt
include LICENSE
include pyproject.toml
include README.rst
include setup.cfg
include setup.py
include setup_utils.py
16 changes: 4 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pyhepmc
=======

A Pythonic wrapper for the HepMC3 C++ library.
A Pythonic wrapper for the `HepMC3 C++ library <http://hepmc.web.cern.ch/hepmc>`_.

.. image:: https://scikit-hep.org/assets/images/Scikit--HEP-Project-blue.svg
:target: https://scikit-hep.org
Expand All @@ -27,15 +27,7 @@ However, building from source is also easy. External software is not required. J

**pyhepmc is Pythonic and Jupyter notebook-friendly**

pyhepmc is a hand-crafted mapping of C++ code to Python, see documentation for details. Python idioms are supported where appropriate. The classes are designed to render well in Jupyter notebooks.

- C++ methods which act like properties are represented as properties,
e.g. ``GenParticle::set_status`` and ``GenParticle::status`` are mapped to a single
``GenParticle.status`` field in Python.
- Tuples and lists are implicitly convertible to ``FourVector`` and ``ToolInfo`` objects.
- Vectors of objects on the C++ side are mapped to Python lists.
- ``Reader`` and ``Writer`` classes support the context manager protocol. ``Reader`` objects can be iterated over.
- A convenient ``open`` function is provided for reading and writing HepMC files.
pyhepmc is a hand-crafted mapping of C++ code to Python, see documentation for details. Python idioms are supported where appropriate. The classes are designed to render well in Jupyter notebooks. IO is simplified. Events can be visualized in Jupyter notebooks.

**pyhepmc supports visualizations powered by graphviz**

Expand All @@ -54,9 +46,9 @@ We aim for 100% coverage, not quite there yet.
Documentation
-------------

pyhepmc mirrors the C++ interface of the `HepMC3 library, which is documented here <http://hepmc.web.cern.ch/hepmc>`_. The documentation is mostly copied from HepMC3 and available as Python docstrings, so you can use Python's ``help()`` browser to learn about the API. Alternatively, you can consult our online reference generated from these docstrings.
pyhepmc largely mirrors the C++ interface of the `HepMC3 library, which is documented here <http://hepmc.web.cern.ch/hepmc>`_. The documentation has been copied from HepMC3 where appropriate (. It is available as Python docstrings, so you can use Python's ``help()`` browser to learn about the API. Alternatively, you can consult `our online reference generated from these docstrings <https://scikit-hep.org/pyhepmc/>`_.

License
-------

pyhepmc is covered by the BSD 3-clause license, see the ``LICENSE`` file for details. This license only applies to the pyhepmc code. The connected external libraries HepMC3 and pybind11 are covered by other licenses, as described in their respective ``LICENSE`` files.
pyhepmc is covered by the BSD 3-clause license, but its main functionality comes from bundled software which is released under different licenses, see the files ``LICENSE`` and ``LICENSE_bundled`` in the source directory for details.
10 changes: 6 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ long_description_content_type = text/x-rst
url = https://github.com/scikit-hep/pyhepmc
project_urls =
Documentation = https://scikit-hep.org/pyhepmc/
license_files = LICENSE, extern/pybind11/LICENSE, extern/HepMC3/LICENSE
license = BSD 3-Clause
license_files =
LICENSE
classifiers =
Programming Language :: Python :: 3
Development Status :: 5 - Production
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Development Status :: 4 - Beta
Programming Language :: Python :: 3
Operating System :: MacOS
Operating System :: POSIX
Operating System :: Unix
Operating System :: Windows
Topic :: Scientific/Engineering
Intended Audience :: Developers

Expand Down
13 changes: 11 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
import sys
from pathlib import Path
from setuptools import setup
import sys
from distutils.command.sdist import sdist

cdir = Path(__file__).parent.absolute()

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


class sdist_mod(sdist):
def run(self):
with merge_license_files():
sdist.run(self)


setup(
zip_safe=False,
use_scm_version=True,
setup_requires=["setuptools_scm"],
ext_modules=[CMakeExtension("pyhepmc._core")],
cmdclass={"build_ext": CMakeBuild},
cmdclass={"build_ext": CMakeBuild, "sdist": sdist_mod},
)
28 changes: 28 additions & 0 deletions setup_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from contextlib import contextmanager


@contextmanager
def merge_license_files():
"""
Merge LICENSE.txt and LICENSES_bundled.txt for sdist creation.
This follows the approach of Scipy and is to keep LICENSE in repo as an
exact BSD 3-clause, to make GitHub state correctly how pyhepmc is licensed.
"""

l1 = "LICENSE"
l2 = "LICENSES_bundled"

with open(l1, "r") as f:
content1 = f.read()

with open(l2, "r") as f:
content2 = f.read()

with open(l1, "w") as f:
f.write(content1 + "\n\n" + content2)

yield

with open(l1, "w") as f:
f.write(content1)

0 comments on commit b1580c9

Please sign in to comment.