Skip to content

Commit

Permalink
Fix creating RPM packages (#248)
Browse files Browse the repository at this point in the history
* update the build-script to allow parallel builds

Well, doesn't really do much right now since it's just
one file being compiled - but maybe it will matter in the future.

Also make it so the "install" command doesn't actually build anything,
and just installs. Update the README to promote usage of the build.sh
script
Also remove the installation instruction for PyPi - it's not up there
yet.

* fix bdist_rpm not including pyslurm.pyx

Just do a recursive include of all .pyx .pxd .pxi .h files
  • Loading branch information
tazend authored Jan 3, 2023
1 parent 7b370f7 commit da978a6
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 34 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ graft tests
graft doc
graft pyslurm/slurm
graft pyslurm/pydefines
include pyslurm/alps_cray.h
recursive-include pyslurm *.pyx *.px[di] *.h
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,18 @@ By default, it is searched inside `/usr/include` for the Header files and in
For Slurm installations in different locations, you will need to provide
the corresponding paths to the necessary files.

You can specify these Paths with environment variables, for example:
You can specify these Paths with environment variables (recommended), for example:

```shell
export SLURM_INCLUDE_DIR=/opt/slurm/22.05/include
export SLURM_LIB_DIR=/opt/slurm/22.05/lib
```

Then you can proceed to install PySlurm, for example:

```shell
pip install pyslurm==22.05.0
```

Or by cloning the repository:
Then you can proceed to install PySlurm, for example by cloning the Repository:

```shell
git clone https://github.com/PySlurm/pyslurm.git && cd pyslurm
python setup.py install
scripts/build.sh

# Or simply with pip
pip install .
Expand Down
28 changes: 20 additions & 8 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
#!/bin/bash
set -e

###################################
# Build PySlurm
###################################
usage() { echo "Usage: $0 [-j jobs]" 1>&2; exit 1; }

cd pyslurm
echo "---> Building PySlurm..."
python$PYTHON setup.py build
# Option to allow parallel build
OPT_JOBS=1

echo "---> Installing PySlurm..."
python$PYTHON setup.py install
PYTHON_VERSION=3

while getopts ":j:" o; do
case "${o}" in
j)
OPT_JOBS=${OPTARG}
;;
*)
usage
;;
esac
done

shift $((OPTIND-1))

python"$PYTHON_VERSION" setup.py build -j "$OPT_JOBS"
python"$PYTHON_VERSION" setup.py install
13 changes: 4 additions & 9 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@ docs=build_sphinx
[bdist_rpm]
release = 1
packager = Giovanni Torres <[email protected]>
doc_files = CONTRIBUTORS.rst
README.rst
THANKS.rst
doc_files = README.md
doc/
examples/
build_requires = python-devel >= 2.7
Cython >= 0.19
python-sphinx >= 1.1
slurm-devel >= 17.11.5
python-nose
requires = slurm-slurmd slurm-slurmdbd
build_requires = python3-devel >= 3.6
slurm-devel >= 22.05.0
requires = slurm
use_bzip2 = 1

[build_sphinx]
Expand Down
17 changes: 10 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,8 @@ def parse_setuppy_commands():
cleanup_build()
return False

build_cmd = ('install', 'sdist', 'build', 'build_ext', 'build_py',
'build_clib', 'build_scripts', 'bdist_wheel', 'bdist_rpm',
'build_src', 'bdist_egg', 'develop')
build_cmd = ('build', 'build_ext', 'build_py', 'build_clib',
'build_scripts', 'bdist_wheel', 'build_src', 'bdist_egg', 'develop')

for cmd in build_cmd:
if cmd in args:
Expand All @@ -318,10 +317,14 @@ def setup_package():
build_it = parse_setuppy_commands()

if build_it:
if "sdist" not in sys.argv:
parse_slurm_args()
slurm_sanity_checks()
cythongen()
parse_slurm_args()
slurm_sanity_checks()
cythongen()

if "install" in sys.argv:
parse_slurm_args()
slurm_sanity_checks()
metadata["ext_modules"] = make_extensions()

setup(**metadata)

Expand Down

0 comments on commit da978a6

Please sign in to comment.