Skip to content

Commit

Permalink
Simplify build system to the minimum required. NOTE: Editable mode is…
Browse files Browse the repository at this point in the history
… only supported via `python conanfile.py`
  • Loading branch information
dpad committed Jul 2, 2024
1 parent b39c282 commit 23158d7
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 198 deletions.
33 changes: 14 additions & 19 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import subprocess
import sys
from datetime import datetime
import warnings

import pkg_resources

Expand All @@ -18,7 +17,7 @@
warningColor = '\033[93m'
endColor = '\033[0m'

# TODO: Remove this check (deprecated, same as buildDeprecated flag below).
# TODO: Remove this check (deprecated, same as managePipEnvironment flag below).
try:
from conans import __version__ as conan_version
if int(conan_version[0]) >= 2:
Expand All @@ -43,22 +42,22 @@
"vizInterface": True,
"buildProject": True,

# XXX: Set deprecatedBuild to True to keep the old behaviour of managing the
# `pip` environment directly (upgrading, installing Python packages, etc.).
# This behaviour is deprecated using the new pip-based installation, and
# should only be required for users who are still calling this file with
# `python conanfile.py ...`.
# TODO: Remove all deprecatedBuild behaviour!
"deprecatedBuild": False
# XXX: Set managePipEnvironment to True to keep the old behaviour of
# managing the `pip` environment directly (upgrading, installing Python
# packages, etc.). This behaviour is deprecated using the new pip-based
# installation, and should only be required for users who are still calling
# this file with `python conanfile.py ...`.
# TODO: Remove all managePipEnvironment behaviour!
"managePipEnvironment": True
}
bskModuleOptionsString = {
"autoKey": "", # TODO: Remove, used only for deprecatedBuild.
"autoKey": "", # TODO: Remove, used only for managePipEnvironment.
"pathToExternalModules": "",
"pyLimitedAPI": "",
}
bskModuleOptionsFlag = {
"clean": False,
"allOptPkg": False # TODO: Remove, used only for deprecatedBuild.
"allOptPkg": False # TODO: Remove, used only for managePipEnvironment.
}

# this statement is needed to enable Windows to print ANSI codes in the Terminal
Expand Down Expand Up @@ -98,11 +97,11 @@ class BasiliskConan(ConanFile):


def system_requirements(self):
if not self.options.deprecatedBuild:
if not self.options.managePipEnvironment:
return # Don't need to manage any pip requirements

# TODO: Remove everything here, which only runs if we have set
# deprecatedBuild (i.e. conanfile.py-based build).
# managePipEnvironment (i.e. conanfile.py-based build).

# ensure latest pip is installed
if is_running_virtual_env() or platform.system() == "Windows":
Expand Down Expand Up @@ -288,7 +287,7 @@ def build(self):
cmake.parallel = True
print(statusColor + "Configuring cmake..." + endColor)
cmake.configure()
if self.options.deprecatedBuild:
if self.options.managePipEnvironment:
# TODO: Remove this, it's only needed when conanfile.py is handling pip installations.
self.add_basilisk_to_sys_path()
if self.options.buildProject:
Expand All @@ -313,7 +312,7 @@ def build(self):

def add_basilisk_to_sys_path(self):
print("Adding Basilisk module to python\n")
add_basilisk_module_command = [sys.executable, "-m", "pip", "install", "-e", "deprecatedBuild"]
add_basilisk_module_command = [sys.executable, "-m", "pip", "install", "--no-build-isolation", "-e", "."]
if not is_running_virtual_env() and self.options.autoKey != 's':
add_basilisk_module_command.append("--user")

Expand All @@ -327,9 +326,6 @@ def add_basilisk_to_sys_path(self):
print("This resulted in the stderr: \n%s" % err.decode())

if __name__ == "__main__":
warnings.warn("Installation via 'conanfile.py' is deprecated. Please use `pip` installation instead!", DeprecationWarning)
# TODO: Disable this usage entirely, including all "deprecatedBuild" items.

# make sure conan is configured to use the libstdc++11 by default
# XXX: This needs to be run before dispatching to Conan (i.e. outside of the
# ConanFile object), because it affects the configuration of the first run.
Expand Down Expand Up @@ -405,7 +401,6 @@ def add_basilisk_to_sys_path(self):
for opt, value in bskModuleOptionsFlag.items():
if vars(args)[opt]:
conanCmdString.append(' -o ' + opt + '=True')
conanCmdString.append(' -o deprecatedBuild=True') # TODO: Remove everything that runs with deprecatedBuild!
conanCmdString = ''.join(conanCmdString)
print(statusColor + "Running this conan command:" + endColor)
print(conanCmdString)
Expand Down
10 changes: 0 additions & 10 deletions deprecatedBuild/README.md

This file was deleted.

1 change: 0 additions & 1 deletion deprecatedBuild/dist3

This file was deleted.

54 changes: 0 additions & 54 deletions deprecatedBuild/setup.py

This file was deleted.

16 changes: 11 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools>=64", # For PEP 660 (Allow editable installs from pyproject.toml)
"setuptools>=64", # For PEP 660 (Allow editable installs from pyproject.toml)
"setuptools-scm>=8.0", # Automatically include all Git-controlled files in sdist

# Requirements for building Basilisk through setuptools and conanfile
# Requirements for building Basilisk through conanfile
"conan>=1.46, <2.00.0",
"cmake>=3.26",
"parse>=1.18.0",
"swig==4.2.0.post0" # Known to work with https://github.com/nightlark/swig-pypi/pull/120
]

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

[project]
name = 'Basilisk'
dynamic = ["version", "dependencies", "optional-dependencies"]
Expand All @@ -25,6 +23,14 @@ description = "Basilisk: an Astrodynamics Simulation Framework"
[project.urls]
homepage = 'https://hanspeterschaub.info/basilisk/'

[tool.setuptools]
packages = [] # XXX: Leave blank, populated automatically by setup.py.
include-package-data = true

[tool.setuptools.package-data]
"*" = ["*.so", "*.dll", "*.lib", "*.pyd"] # Include all built objects.
Basilisk = ["supportData/**/*"] # Include all support data.

[tool.setuptools.dynamic]
version = {file = "docs/source/bskVersion.txt"}
dependencies = {file = "requirements.txt"}
Expand Down
Loading

0 comments on commit 23158d7

Please sign in to comment.