Skip to content

Commit 8f79a19

Browse files
dean0x7dhellozee
authored andcommitted
Format all project files with black
1 parent 476b08a commit 8f79a19

File tree

4 files changed

+45
-22
lines changed

4 files changed

+45
-22
lines changed

conanfile.py

+32-21
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ class EmbeddedPython(ConanFile):
1414
url = "https://github.com/lumicks/embedded_python"
1515
settings = "os", "compiler", "build_type", "arch"
1616
options = {
17-
"version": "ANY",
18-
"packages": "ANY",
17+
"version": "ANY",
18+
"packages": "ANY",
1919
"pip_version": "ANY",
2020
"pip_licenses_version": "ANY",
2121
"setuptools_version": "ANY",
2222
"wheel_version": "ANY",
23-
"openssl_variant": ["lowercase", "uppercase"] # see explanation in `build_requirements()`
23+
"openssl_variant": ["lowercase", "uppercase"], # see explanation in `build_requirements()`
2424
}
2525
default_options = {
2626
"packages": None,
2727
"pip_version": "22.1.2",
2828
"pip_licenses_version": "3.5.4",
2929
"setuptools_version": "63.2.0",
3030
"wheel_version": "0.37.1",
31-
"openssl_variant": "lowercase"
31+
"openssl_variant": "lowercase",
3232
}
3333
exports = "embedded_python_tools.py", "embedded_python.cmake"
3434
short_paths = True # some of the pip packages go over the 260 char path limit on Windows
@@ -80,19 +80,20 @@ def pyver(self):
8080

8181
def make_requirements_file(self, extra_packages=None):
8282
"""Create a `requirements.txt` based on `self.options.packages` and return its path
83-
83+
8484
We accept `self.options.packages` as either a space-separated list of packages (as
8585
you would pass to `pip install <packages>`) or the full contents of a `requirements.txt`
8686
file (as you would pass to `pip install -r <file>`). But in either case, we generate
8787
a `requirements.txt` file internally for installation.
8888
89-
The `extra_packages` can be used to add extra packages (as a Python `list`) to be
89+
The `extra_packages` can be used to add extra packages (as a Python `list`) to be
9090
installed in addition to `self.options.packages`.
9191
"""
92+
9293
def split_lines(string):
9394
"""`options.packages` may be encoded as tab, newline or space separated
9495
95-
The `\n` separator doesn't play well with Conan but we need to support
96+
The `\n` separator doesn't play well with Conan but we need to support
9697
it for backward compatibility.
9798
"""
9899
for separator in ["\t", "\n"]:
@@ -115,13 +116,17 @@ def _gather_licenses(self, bootstrap):
115116
116117
We can't run `pip-licenses` in the final environment because it doesn't have `pip`.
117118
So we install the same packages in the bootstrap env and run `pip-licenses` there.
118-
This will dump a bunch of packages into bootstrap but it doesn't matter since we
119+
This will dump a bunch of packages into bootstrap but it doesn't matter since we
119120
won't be using it for anything else afterward.
120121
"""
121-
requirements = self.make_requirements_file(extra_packages=[f"pip-licenses=={self.options.pip_licenses_version}"])
122+
requirements = self.make_requirements_file(
123+
extra_packages=[f"pip-licenses=={self.options.pip_licenses_version}"]
124+
)
122125
self.run(f"{bootstrap} -m pip install --no-warn-script-location -r {requirements}")
123-
self.run(f"{bootstrap} -m piplicenses --with-system --from=mixed --format=plain-vertical"
124-
f" --with-license-file --no-license-path --output-file=package_licenses.txt")
126+
self.run(
127+
f"{bootstrap} -m piplicenses --with-system --from=mixed --format=plain-vertical"
128+
f" --with-license-file --no-license-path --output-file=package_licenses.txt"
129+
)
125130

126131
def build(self):
127132
tools.replace_in_file("embedded_python.cmake", "${self.pyversion}", str(self.pyversion))
@@ -141,9 +146,13 @@ def build(self):
141146
self._gather_licenses(bootstrap)
142147

143148
# Some modules always assume that `setuptools` is installed (e.g. pytest)
144-
requirements = self.make_requirements_file(extra_packages=[f"setuptools=={self.options.setuptools_version}"])
149+
requirements = self.make_requirements_file(
150+
extra_packages=[f"setuptools=={self.options.setuptools_version}"]
151+
)
145152
options = "--ignore-installed --no-warn-script-location"
146-
self.run(f'{bootstrap} -m pip install --no-deps --prefix "{prefix}" {options} -r {requirements}')
153+
self.run(
154+
f'{bootstrap} -m pip install --no-deps --prefix "{prefix}" {options} -r {requirements}'
155+
)
147156

148157
def package(self):
149158
self.copy("embedded_python/*", keep_path=True)
@@ -236,8 +245,8 @@ def _get_source(self):
236245
compiler = self.conanfile.settings.compiler
237246
if "clang" in str(compiler) and tools.Version(self.conanfile.pyversion) < "3.9.8":
238247
tools.replace_in_file(
239-
"src/configure",
240-
"MULTIARCH=$($CC --print-multiarch 2>/dev/null)",
248+
"src/configure",
249+
"MULTIARCH=$($CC --print-multiarch 2>/dev/null)",
241250
"MULTIARCH=''",
242251
strict=False,
243252
)
@@ -263,12 +272,14 @@ def _build(self, dest_dir):
263272
# package. Unlike RUNPATH, RPATH takes precedence over LD_LIBRARY_PATH.
264273
if self.conanfile.settings.os == "Linux":
265274
env_vars["LDFLAGS"] += " -Wl,-rpath,'$$ORIGIN/../lib' -Wl,--disable-new-dtags"
266-
267-
config_args = " ".join([
268-
"--enable-shared",
269-
f"--prefix={dest_dir}",
270-
f"--with-openssl={self._openssl_path}",
271-
])
275+
276+
config_args = " ".join(
277+
[
278+
"--enable-shared",
279+
f"--prefix={dest_dir}",
280+
f"--with-openssl={self._openssl_path}",
281+
]
282+
)
272283

273284
tools.mkdir("./build")
274285
with tools.chdir("./build"), tools.environment_append(env_vars):

embedded_python_tools.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def imports(self):
4545
if os.path.lexists(dst):
4646
try: # to remove any existing junction/symlink
4747
os.remove(dst)
48-
except: # this seems to be the only way to find out this is not a junction
48+
except: # this seems to be the only way to find out this is not a junction
4949
shutil.rmtree(dst)
5050

5151
src = pathlib.Path(conanfile.deps_cpp_info["embedded_python"].rootpath) / "embedded_python"

pyproject.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[tool.black]
2+
line-length = 100
3+
target-version = ['py39']
4+
extend-exclude = '''
5+
(
6+
/(
7+
\.git
8+
| \.github
9+
)/
10+
)
11+
'''

test_package/conanfile.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def configure(self):
2727

2828
def imports(self):
2929
import embedded_python_tools
30+
3031
embedded_python_tools.symlink_import(self, dst="bin/python")
3132
self.copy("licenses/*", dst="licenses", folder=True, ignore_case=True, keep_path=False)
3233

0 commit comments

Comments
 (0)