-
Notifications
You must be signed in to change notification settings - Fork 11
Modernise the build system #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Joseph-Edwards
merged 19 commits into
libsemigroups:v1
from
Joseph-Edwards:update-build-system
May 13, 2025
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
217985e
Move libsemigroups_pybind11 to src
Joseph-Edwards 7b03cf8
Create build_tools package
Joseph-Edwards 3fe86a7
Modernise packaging
Joseph-Edwards eeddad0
Revert ruff changes
Joseph-Edwards 2e14a67
Update dev environment
Joseph-Edwards 864570d
Add comments
Joseph-Edwards 72bfde4
Update .gitignore
Joseph-Edwards 3d96a93
Add comments
Joseph-Edwards 96cebcc
Update requirements.txt with pipreqs
Joseph-Edwards 4e7ec6c
Delete unused environment files
Joseph-Edwards 9258e5f
Fix requirements
Joseph-Edwards f3f0a6e
Fix package path
Joseph-Edwards 7baf7d3
Better linting in workflows
Joseph-Edwards 85aa040
Try and fix requirements.txt again
Joseph-Edwards 430b3d3
Add comments
Joseph-Edwards e80a576
make lint fails if any linting step fails
Joseph-Edwards 766e28c
Update pytest config options
Joseph-Edwards 654ce28
Use ruff and pylint on same files
Joseph-Edwards 60f3d39
Remove metaclass
Joseph-Edwards File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,3 +20,4 @@ docs/source/api/Transf.rst | |
| gh-pages/ | ||
| htmlcov | ||
| .cache | ||
| src/libsemigroups_pybind11/_version.py | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| include src/*.hpp | ||
| graft src | ||
| include tests/*.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| # Copyright (c) 2021-2024 J. D. Mitchell | ||
| # | ||
| # Distributed under the terms of the GPL license version 3. | ||
| # | ||
| # The full license is in the file LICENSE, distributed with this software. | ||
|
|
||
| """ | ||
| This module provides some tools for building libsemigroups_pybind11. | ||
| """ | ||
|
|
||
| import re | ||
| from packaging import version | ||
| import pkgconfig | ||
|
|
||
|
|
||
| def minimum_libsemigroups_version(): | ||
| """ | ||
| Returns the minimum required version of libsemigroups required to make | ||
| this work. | ||
| """ | ||
| return "3.0.0" | ||
|
|
||
|
|
||
| def libsemigroups_version(): | ||
| "Get the version of libsemigroups installed using pkg-config." | ||
|
|
||
| vers = pkgconfig.modversion("libsemigroups") | ||
| if re.search(r"\d+\.\d+\.\d+-\d+-\w{7}", vers): | ||
| # i.e. supplied is of the form: 1.1.0-6-g8b04c08 | ||
| vers = re.search(r"\d+\.\d\.+\d+-\d+", vers).group(0) | ||
| return vers | ||
|
|
||
|
|
||
| def compare_version_numbers(supplied, required): | ||
| """Returns True if supplied >= required""" | ||
|
|
||
| if isinstance(supplied, str) and isinstance(required, str): | ||
| if "dev" in supplied: | ||
| print( | ||
| ( | ||
| "\033[93mWarning: You are using a development version of libsemigroups. This " | ||
| "may cause undocumented behaviour\033[0m" | ||
| ) | ||
| ) | ||
| return True | ||
| return version.parse(supplied) >= version.parse(required) | ||
| raise TypeError( | ||
| f"expected (string, string), got a ({supplied.__name__}, {required.__name__})" | ||
| ) | ||
|
|
||
|
|
||
| def extra_link_args() -> str: | ||
| """Find extra link args""" | ||
| libs_only_L = pkgconfig.libs( # pylint: disable=invalid-name | ||
| "libsemigroups" | ||
| ) | ||
| # The above pkgconfig query can return an empty string (this also happens on | ||
| # the command line). This happens, for example, using pkg-config version 1.8.0 | ||
| # on ArchLinux. CN 27/10/2021 | ||
|
|
||
| assert ( | ||
| len(libs_only_L) == 0 or libs_only_L[:2] == "-L" | ||
| ), "The first two characters of the library path to the libsemigroups.so etc should be '-L'" | ||
|
|
||
| libs_only_L = [ # pylint: disable=invalid-name | ||
| x for x in libs_only_L.split(" ") if x.startswith("-L") | ||
| ] | ||
|
|
||
| if len(libs_only_L) == 0: | ||
| libs_only_L = ["-L/usr/lib"] # pylint: disable=invalid-name | ||
| return libs_only_L | ||
|
|
||
|
|
||
| def ld_library_path() -> str: | ||
| """Construct the LD_LIBRARY_PATH""" | ||
| return ":".join([x[2:] for x in extra_link_args()]) | ||
|
|
||
|
|
||
| def validate_libsemigroups(): | ||
| DISCLAIMER = """ | ||
| (You should not see this message unless you are installing | ||
| libsemigroups_pybind11 from its sources. If you are not installing from the | ||
| sources, please raise an issue at: | ||
| https://github.com/libsemigroups/libsemigroups_pybind11)""" | ||
|
|
||
| if not pkgconfig.exists("libsemigroups"): | ||
| raise ImportError( | ||
| f"""cannot locate the libsemigroups library. | ||
| For more information about installing the libsemigroups library see | ||
| https://libsemigroups.github.io/libsemigroups_pybind11/install.html. | ||
|
|
||
| If libsemigroups is installed, then it cannot be located by pkg-config, | ||
| perhaps you should add the directory containing `libsemigroups.pc' to the | ||
| \"PKG_CONFIG_PATH\". The file `libsemigroups.pc' might be in one of the | ||
| following directories: | ||
| * /usr/local/lib/pkgconfig | ||
| * $CONDA_PREFIX/lib/pkgconfig if your active conda environment has pkgconfig | ||
| installed, and libsemigroups was installed with conda/mamba in this | ||
| environment. | ||
| {DISCLAIMER}""" | ||
| ) | ||
|
|
||
| if not compare_version_numbers( | ||
| libsemigroups_version(), minimum_libsemigroups_version() | ||
| ): | ||
| raise ImportError( | ||
| f"libsemigroups version at least {minimum_libsemigroups_version()}" | ||
| + f" is required, found {libsemigroups_version()}" | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #!/bin/bash | ||
|
Joseph-Edwards marked this conversation as resolved.
|
||
|
|
||
| if [[ $# -ne 0 ]]; then | ||
| bold "error expected 0 arguments, got $#!" | ||
| exit 1 | ||
| fi | ||
|
|
||
| exit_code=0 | ||
| python_files="setup.py tests/*.py src/libsemigroups_pybind11/*.py src/libsemigroups_pybind11/**/*.py docs/source/*.py docs/source/**/*.py" | ||
|
|
||
| echo "Linting with ruff . . ." | ||
| ruff check $python_files || ((exit_code = 1)) | ||
|
|
||
| echo "Linting with pylint . . ." | ||
| pylint $python_files || ((exit_code = 1)) | ||
|
|
||
| echo "Linting with cpplint . . ." | ||
| cpplint src/*.hpp src/*.cpp || ((exit_code = 1)) | ||
|
|
||
| exit $exit_code | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.