Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sudo mv /tmp/timezone /etc/timezone

# Prepare the version file
echo "Flux Version for pypi is ${FLUX_VERSION}"
sed -i "s/package_version = \"develop\"/package_version = \"$FLUX_VERSION\"/" setup.py
sed -i "s/version = \"0.0.0\"/version = \"$FLUX_VERSION\"/" pyproject.toml

here=$(pwd)
sudo apt-get update
Expand Down
56 changes: 56 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[build-system]

# These correspond to setup_requires
requires = [
"setuptools>=42",
"wheel",
"cffi>=1.1"
]

# Use setuptools
build-backend = "setuptools.build_meta"

[project]
name = "flux-python"
version = "0.0.0"
description = "Python bindings for the flux resource manager API"
readme = "README.md"
keywords = ["flux", "job manager", "workload manager", "orchestration", "hpc"]
license.file = "LICENSE"

# Corresponds to the `classifiers` argument
classifiers = [
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"Programming Language :: C++",
"Programming Language :: Python",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
"Operating System :: Unix",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]

# Corresponds to install_requires
dependencies = [
"cffi>=1.1",
"pyyaml"
]

[project.urls]
Homepage = "https://github.com/flux-framework/flux-python"
Repository = "https://github.com/flux-framework/flux-python"

# Corresponds to extras_require
[project.optional-dependencies]
dev = [
"pyyaml",
"jsonschema",
"docutils",
"black",
"IPython"
]
142 changes: 67 additions & 75 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,7 @@

from setuptools import find_packages
from setuptools import setup as _setup
from distutils.core import setup, Command

# Metadata
package_name = "flux-python"
package_version = "develop"
package_description = "Python bindings for the flux resource manager API"
package_url = "https://github.com/flux-framework/flux-python"
package_keywords = "flux, job manager, workload manager, orchestration, hpc"

try:
with open("README.md") as filey:
package_long_description = filey.read()
except Exception:
package_long_description = package_description

# Setup variables for dependencies
cffi_dep = "cffi>=1.1"
from distutils.core import setup

# src/bindings/python
root = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -57,7 +41,37 @@ def find_flux():
return os.path.dirname(os.path.dirname(os.path.realpath(path)))


flux_root = find_flux()
def is_info_command():
"""
Check if we're running a command that only needs package metadata
and doesn't require Flux to be installed.
"""
info_commands = {
"egg_info",
"sdist",
"--classifiers",
"--description",
"--fullname",
"--help",
"--help-commands",
"--keywords",
"--licence",
"--license",
"--long-description",
"--name",
"--url",
"--version",
}
# This is akin to calling --help
if len(sys.argv) == 1 and sys.argv[0] == "setup.py":
return True
return any(cmd in sys.argv for cmd in info_commands)


# Only find flux if we're not running an info command
flux_root = None
if not is_info_command():
flux_root = find_flux()

# Module specific default options files. Format strings below will be populated
# after receiving the custom varibles from the user
Expand Down Expand Up @@ -316,11 +330,11 @@ def check_header(self, f, including_path="."):
"""
with open(f, "r") as header:
for l in header.readlines():
m = re.search('#include\s*"([^"]*)"', l)
m = re.search(r'#include\s*"([^"]*)"', l)
if m:
nf = find_first(self.search, m.group(1), including_path)
self.process_header(nf, os.path.dirname(os.path.abspath(nf)))
if not re.match("#\s*include", l):
if not re.match(r"#\s*include", l):
self.mega_header += l

# Flag as checked
Expand All @@ -335,68 +349,46 @@ def setup():
global security_include
global has_flux_security

# Always set the install root to the environment
set_envar("FLUX_INSTALL_ROOT", flux_root)

# The flux security path should be in the same root, under includes
security_include = os.path.join(flux_root, "include", "flux", "security")
has_flux_security = True
if not os.path.exists(security_include):
print(f"Cannot find flux security under expected path {security_include}")
has_flux_security = False

# We only want this to run on creating the tarball or install
command = sys.argv[1]
print(f"Command is {command}")
prepare = PrepareFluxHeaders(flux_root)
prepare.run()

# Request to install additional modules (we always do core0
# We also have to remove the setup.py flags that aren't known
cffi_modules = ["src/_core_build.py:ffi"]
for build_type in build_types:
# If we don't have flux security
if build_type == "security" and not has_flux_security:
continue
# We always include / require core (may not be necessary)
if build_type == "core":
continue
cffi_modules.append("src/_%s_build.py:ffi" % build_type)

print("cffi_modules:\n%s" % "\n".join(cffi_modules))
if is_info_command():
cffi_modules = None
else:
# Always set the install root to the environment
set_envar("FLUX_INSTALL_ROOT", flux_root)

# The flux security path should be in the same root, under includes
security_include = os.path.join(flux_root, "include", "flux", "security")
has_flux_security = True
if not os.path.exists(security_include):
print(f"Cannot find flux security under expected path {security_include}")
has_flux_security = False

# We only want this to run on creating the tarball or install
command = sys.argv[1]
print(f"Command is {command}")
prepare = PrepareFluxHeaders(flux_root)
prepare.run()

# Request to install additional modules (we always do core0
# We also have to remove the setup.py flags that aren't known
cffi_modules = ["src/_core_build.py:ffi"]
for build_type in build_types:
# If we don't have flux security
if build_type == "security" and not has_flux_security:
continue
# We always include / require core (may not be necessary)
if build_type == "core":
continue
cffi_modules.append("src/_%s_build.py:ffi" % build_type)

print("cffi_modules:\n%s" % "\n".join(cffi_modules))

# This assumes relative location of Flux install
# Now with cffi for final install
_setup(
name=package_name,
version=package_version,
description=package_description,
long_description=package_long_description,
long_description_content_type="text/markdown",
keywords=package_keywords,
url=package_url,
setup_requires=[cffi_dep],
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=[cffi_dep, "pyyaml"],
extras_require={
"dev": ["pyyaml", "jsonschema", "docutils", "black", "IPython"]
},
classifiers=[
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
"Programming Language :: C++",
"Programming Language :: Python",
"Topic :: Software Development",
"Topic :: Scientific/Engineering",
"Operating System :: Unix",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
],
url="https://github.com/flux-framework/flux-python",
cffi_modules=cffi_modules,
)

Expand Down