Skip to content

Commit 6c29847

Browse files
EZoniax3l
andauthored
Packaging for PyPI (#18)
### Overview Add necessary files and structure to create the package for the Python Package Index (PyPI). - [x] Add LICENSE file, copied from https://github.com/BLAST-ImpactX/impactx/blob/development/LICENSE.txt - [x] Add `pyproject.toml` Close #17. ### To do - [x] Test build: build with `python3 -m build` locally - [x] Test upload: upload to TestPyPI - [x] Test installation: install and import locally See #18 (comment) for a quick overview of how I tested this. --------- Co-authored-by: Axel Huebl <[email protected]>
1 parent 0d7fea5 commit 6c29847

File tree

11 files changed

+111
-20
lines changed

11 files changed

+111
-20
lines changed

LICENSE

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
PALS Python Copyright (c) 2025, The Regents of the University of California,
2+
through Lawrence Berkeley National Laboratory (subject to receipt of
3+
any required approvals from the U.S. Dept. of Energy). All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
(1) Redistributions of source code must retain the above copyright notice,
9+
this list of conditions and the following disclaimer.
10+
11+
(2) Redistributions in binary form must reproduce the above copyright
12+
notice, this list of conditions and the following disclaimer in the
13+
documentation and/or other materials provided with the distribution.
14+
15+
(3) Neither the name of the University of California, Lawrence Berkeley
16+
National Laboratory, U.S. Dept. of Energy nor the names of its contributors
17+
may be used to endorse or promote products derived from this software
18+
without specific prior written permission.
19+
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
POSSIBILITY OF SUCH DAMAGE.
32+
33+
You are under no obligation whatsoever to provide any bug fixes, patches,
34+
or upgrades to the features, functionality or performance of the source
35+
code ("Enhancements") to anyone; however, if you choose to make your
36+
Enhancements available either publicly, or directly to Lawrence Berkeley
37+
National Laboratory, without imposing a separate written license agreement
38+
for such Enhancements, then you hereby grant the following license: a
39+
non-exclusive, royalty-free perpetual license to install, use, modify,
40+
prepare derivative works, incorporate into other computer software,
41+
distribute, and sublicense such enhancements or derivative works thereof,
42+
in binary and source code form.

examples/fodo.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
import yaml
55

66
# Add the parent directory to sys.path
7-
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
7+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../src/")))
88

9-
from schema.MagneticMultipoleParameters import MagneticMultipoleParameters
10-
11-
from schema.DriftElement import DriftElement
12-
from schema.QuadrupoleElement import QuadrupoleElement
13-
14-
from schema.Line import Line
9+
from pals_schema.MagneticMultipoleParameters import MagneticMultipoleParameters
10+
from pals_schema.DriftElement import DriftElement
11+
from pals_schema.QuadrupoleElement import QuadrupoleElement
12+
from pals_schema.Line import Line
1513

1614

1715
def main():

pyproject.toml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[build-system]
2+
requires = ["setuptools >= 77", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "pals_schema"
7+
version = "25.08"
8+
dependencies = [
9+
"pydantic",
10+
"pyyaml",
11+
"toml",
12+
]
13+
requires-python = ">=3.9"
14+
authors = [
15+
{ name="Axel Huebl", email="[email protected]" },
16+
{ name="Edoardo Zoni", email="[email protected]" },
17+
]
18+
maintainers = [
19+
{ name="Axel Huebl", email="[email protected]" },
20+
{ name="Edoardo Zoni", email="[email protected]" },
21+
]
22+
description = "Python implementation for the Particle Accelerator Lattice Standard (PALS)"
23+
readme = "README.md"
24+
license = "BSD-3-Clause-LBNL"
25+
license-files = ["LICEN[CS]E*"]
26+
classifiers = [
27+
"Development Status :: 5 - Production/Stable",
28+
"Framework :: Pydantic :: 2",
29+
"Intended Audience :: Developers",
30+
"Intended Audience :: Science/Research",
31+
"Natural Language :: English",
32+
"Programming Language :: Python :: 3",
33+
"Programming Language :: Python :: 3.9",
34+
"Programming Language :: Python :: 3.10",
35+
"Programming Language :: Python :: 3.11",
36+
"Programming Language :: Python :: 3.12",
37+
"Programming Language :: Python :: 3.13",
38+
"Operating System :: OS Independent",
39+
"Topic :: Scientific/Engineering",
40+
"Topic :: Software Development",
41+
]
42+
43+
[project.optional-dependencies]
44+
test = ["pytest"]
45+
46+
[project.urls]
47+
Documentation = "https://pals-project.readthedocs.io"
48+
Repository = "https://github.com/campa-consortium/pals-python"
49+
Issues = "https://github.com/campa-consortium/pals-python/issues"
File renamed without changes.
File renamed without changes.

schema/Line.py renamed to src/pals_schema/Line.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from pydantic import BaseModel, ConfigDict, Field, field_validator
22
from typing import Annotated, List, Literal, Union
33

4-
from schema.BaseElement import BaseElement
5-
from schema.ThickElement import ThickElement
6-
from schema.DriftElement import DriftElement
7-
from schema.QuadrupoleElement import QuadrupoleElement
4+
from pals_schema.BaseElement import BaseElement
5+
from pals_schema.ThickElement import ThickElement
6+
from pals_schema.DriftElement import DriftElement
7+
from pals_schema.QuadrupoleElement import QuadrupoleElement
88

99

1010
class Line(BaseModel):
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)