Skip to content

Commit 8c6e900

Browse files
authored
anlylinux builds; use bpstd::string_view for anlylinux image compatibility; publish to PyPI from GA workflow
1 parent 755f4c9 commit 8c6e900

File tree

8 files changed

+63
-29
lines changed

8 files changed

+63
-29
lines changed

.github/workflows/tests+artifacts+pypi.yml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
matrix:
1919
platform: [ubuntu-latest, macos-latest, windows-latest]
20-
python-version: ["3.7", "3.10"]
20+
python-version: ["3.8", "3.10"]
2121
exclude:
2222
- platform: windows-latest
2323
python-version: "3.10"
@@ -61,13 +61,31 @@ jobs:
6161

6262
- run: pytest -v -s -We -p no:unraisableexception tests
6363

64-
- run: python -m build
64+
- if: matrix.platform != 'ubuntu-latest'
65+
run: python -m build
6566

66-
- uses: actions/upload-artifact@v2
67+
- if: matrix.platform != 'ubuntu-latest'
68+
uses: actions/upload-artifact@v2
6769
with:
6870
name: dist
6971
path: dist
7072

73+
- if: matrix.platform == 'ubuntu-latest'
74+
run: python -c "import sys; vi=sys.version_info; print(f'PV={vi.major}{vi.minor}')" >> $GITHUB_ENV
75+
76+
- if: matrix.platform == 'ubuntu-latest'
77+
uses: RalfG/[email protected]
78+
with:
79+
build-requirements: 'setuptools_scm'
80+
python-versions: cp${{ env.PV }}-cp${{ env.PV }}
81+
pre-build-command: 'git config --global --add safe.directory "*"'
82+
83+
- if: matrix.platform == 'ubuntu-latest'
84+
uses: actions/upload-artifact@v2
85+
with:
86+
name: dist
87+
path: dist/*-manylinux*.whl
88+
7189
# - if: ${{ failure() }}
7290
# uses: mxschmitt/action-tmate@v3
7391
# with:
@@ -78,24 +96,28 @@ jobs:
7896
needs: [build]
7997
steps:
8098
- uses: actions/setup-python@v2
81-
- run: pip install twine
99+
- run: pip install twine auditwheel
82100
- uses: actions/download-artifact@v2
83101
with:
84102
name: dist
85103
path: dist
86104
- run: twine check --strict dist/*
105+
- run: for i in dist/*-manylinux*.whl; do auditwheel show $i; done;
87106

88107
dist_upload:
89108
runs-on: ubuntu-latest
90-
if: ${{ github.ref == 'refs/heads/main' }}
91109
needs: [dist_check]
92110
steps:
93111
- uses: actions/download-artifact@v2
94112
with:
95113
name: dist
96114
path: dist
97-
- uses: pypa/gh-action-pypi-publish@master
115+
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
116+
uses: pypa/gh-action-pypi-publish@master
98117
with:
99-
user: __token__
100-
password: pypi-${{ secrets.TEST_PYPI_API_TOKEN }}
118+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
101119
repository_url: https://test.pypi.org/legacy/
120+
- if: startsWith(github.ref, 'refs/tags')
121+
uses: pypa/gh-action-pypi-publish@master
122+
with:
123+
password: ${{ secrets.PYPI_API_TOKEN }}

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@
2222
path = gitmodules/span
2323
url = https://github.com/tcbrindle/span.git
2424
shallow = true
25+
[submodule "gitmodules/string_view-standalone"]
26+
path = gitmodules/string_view-standalone
27+
url = https://github.com/bitwizeshift/string_view-standalone.git
28+
shallow = true

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ target_include_directories(PyPartMC PRIVATE
130130
${CMAKE_SOURCE_DIR}/gitmodules/json/include
131131
${CMAKE_SOURCE_DIR}/gitmodules/pybind11_json/include
132132
${CMAKE_SOURCE_DIR}/gitmodules/span/include
133+
${CMAKE_SOURCE_DIR}/gitmodules/string_view-standalone/include
133134
)
134135
target_compile_definitions(PyPartMC PRIVATE VERSION_INFO=${VERSION_INFO})
135136
target_link_libraries(PyPartMC PRIVATE partmclib)

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ graft gitmodules/pybind11/include/pybind11
5050

5151
graft gitmodules/json/include/nlohmann
5252
include gitmodules/span/include/tcb/span.hpp
53+
graft gitmodules/string_view-standalone/include/bpstd
5354
include gitmodules/pybind11_json/include/pybind11_json/pybind11_json.hpp
5455

5556
include gitmodules/partmc/src/condense_solver.c

gitmodules/string_view-standalone

Submodule string_view-standalone added at fa51c8f

setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ def build_extension(self, ext): # pylint: disable=too-many-branches
124124
# logic and declaration, and simpler if you include description/version in a file.
125125
setup(
126126
name="PyPartMC",
127-
use_scm_version={"local_scheme": "no-local-version", "version_scheme": "post-release"},
127+
use_scm_version={
128+
"local_scheme": lambda _: "",
129+
"version_scheme": "post-release",
130+
# "fallback_version": "0.0.0"
131+
},
128132
author="Sylwester Arabas",
129133
author_email="[email protected]",
130134
description="Python interface to PartMC",

src/fake_spec_file.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Authors: https://github.com/open-atmos/PyPartMC/graphs/contributors #
55
##################################################################################################*/
66

7-
#include <string_view>
7+
#include <bpstd/string_view.hpp>
88
#include <tcb/span.hpp>
99

1010
#include "gimmicks.hpp"
@@ -17,7 +17,7 @@ extern "C"
1717
void c_spec_file_read_real(
1818
const char *name_data, const int *name_size, double *var
1919
) {
20-
gimmick_ptr()->read_value(std::string_view(name_data, *name_size), var);
20+
gimmick_ptr()->read_value(bpstd::string_view(name_data, *name_size), var);
2121
}
2222

2323
/*********************************************************************************/
@@ -26,7 +26,7 @@ extern "C"
2626
void c_spec_file_read_integer(
2727
const char *name_data, const int *name_size, int *var
2828
) {
29-
gimmick_ptr()->read_value(std::string_view(name_data, *name_size), var);
29+
gimmick_ptr()->read_value(bpstd::string_view(name_data, *name_size), var);
3030
}
3131

3232
/*********************************************************************************/
@@ -35,13 +35,13 @@ extern "C"
3535
void c_spec_file_read_logical(
3636
const char *name_data, const int *name_size, bool *var
3737
) {
38-
gimmick_ptr()->read_value(std::string_view(name_data, *name_size), var);
38+
gimmick_ptr()->read_value(bpstd::string_view(name_data, *name_size), var);
3939
}
4040

4141
/*********************************************************************************/
4242

4343
void spec_file_read_string(
44-
const std::string_view &name,
44+
const bpstd::string_view &name,
4545
char* var_data,
4646
int *var_size
4747
) noexcept {
@@ -56,14 +56,14 @@ void c_spec_file_read_string(
5656
int *var_size
5757
) noexcept {
5858
spec_file_read_string(
59-
std::string_view(name_data, *name_size),
59+
bpstd::string_view(name_data, *name_size),
6060
var_data, var_size
6161
);
6262
}
6363

6464
/*********************************************************************************/
6565

66-
void spec_file_open(const std::string_view &filename) {
66+
void spec_file_open(const bpstd::string_view &filename) {
6767
gimmick_ptr()->zoom_in(filename);
6868
}
6969

@@ -73,7 +73,7 @@ void c_spec_file_open(
7373
const int *filename_size
7474
) {
7575
spec_file_open(
76-
std::string_view(filename_data, *filename_size)
76+
bpstd::string_view(filename_data, *filename_size)
7777
);
7878
}
7979

@@ -91,7 +91,7 @@ void c_spec_file_close() {
9191
/*********************************************************************************/
9292

9393
void spec_file_read_timed_real_array_size(
94-
const std::string_view &name,
94+
const bpstd::string_view &name,
9595
int *times_size,
9696
int *vals_size
9797
) {
@@ -107,7 +107,7 @@ void c_spec_file_read_timed_real_array_size(
107107
int *vals_size
108108
) {
109109
spec_file_read_timed_real_array_size(
110-
std::string_view(name_data, *name_size),
110+
bpstd::string_view(name_data, *name_size),
111111
times_size,
112112
vals_size
113113
);
@@ -116,7 +116,7 @@ void c_spec_file_read_timed_real_array_size(
116116
/*********************************************************************************/
117117

118118
void spec_file_read_timed_real_array_data(
119-
const std::string_view &name,
119+
const bpstd::string_view &name,
120120
const tcb::span<double> &times,
121121
const tcb::span<double> &vals
122122
) {
@@ -134,9 +134,9 @@ void c_spec_file_read_timed_real_array_data(
134134
const int *vals_size
135135
) {
136136
spec_file_read_timed_real_array_data(
137-
std::string_view(name_data, *name_size),
138-
tcb::span(times_data, *times_size),
139-
tcb::span(vals_data, *vals_size)
137+
bpstd::string_view(name_data, *name_size),
138+
tcb::span<double>(times_data, *times_size),
139+
tcb::span<double>(vals_data, *vals_size)
140140
);
141141
}
142142

@@ -202,7 +202,7 @@ void c_spec_file_read_real_named_array_data(
202202
spec_file_read_real_named_array_data(
203203
*row,
204204
name_data, name_size,
205-
tcb::span(vals_data, *vals_size)
205+
tcb::span<double>(vals_data, *vals_size)
206206
);
207207
}
208208

src/gimmicks.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <stack>
1313
#include "nlohmann/json.hpp"
1414
#include <tcb/span.hpp>
15+
#include <bpstd/string_view.hpp>
1516

1617
struct Gimmick {
1718
private:
@@ -45,7 +46,7 @@ struct Gimmick {
4546
public:
4647
virtual ~Gimmick() {}
4748

48-
void zoom_in(const std::string_view &sub) noexcept {
49+
void zoom_in(const bpstd::string_view &sub) noexcept {
4950
auto it = this->json->is_array()
5051
? this->json->at(this->json->size()-1).begin()
5152
: this->json->find(sub);
@@ -81,7 +82,7 @@ struct Gimmick {
8182
return this->json->empty();
8283
}
8384

84-
std::size_t n_elements(const std::string_view &name) noexcept {
85+
std::size_t n_elements(const bpstd::string_view &name) noexcept {
8586
for (auto i=0u; i<this->json->size(); ++i) {
8687
for (auto &entry : this->json->at(i).items()) {
8788
if (entry.key() == name)
@@ -106,14 +107,14 @@ struct Gimmick {
106107

107108
template <typename T>
108109
void read_value(
109-
const std::string_view name,
110+
const bpstd::string_view name,
110111
T *var
111112
) {
112113
*var = this->find(name)->get<T>();
113114
}
114115

115116
void read_str(
116-
const std::string_view &name,
117+
const bpstd::string_view &name,
117118
char* var_data,
118119
int* var_size
119120
) noexcept {
@@ -126,7 +127,7 @@ struct Gimmick {
126127
}
127128
auto value = it->is_array()
128129
? name
129-
: it->begin()->get<std::string_view>(); // TODO: is this path used anywhere?
130+
: it->begin()->get<bpstd::string_view>(); // TODO: is this path used anywhere?
130131
if ((int)value.size() > *var_size) {
131132
std::ostringstream oss;
132133
oss << "provided entry \"" << name << "\" has too many characters";

0 commit comments

Comments
 (0)