-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trying to fix the macOS PyPy 3.7 error seen in #37
- Loading branch information
Showing
3 changed files
with
138 additions
and
34 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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,134 @@ | ||
From 74ce023ec98a3e2c01a91e8c23fa58cd8ac5e4e3 Mon Sep 17 00:00:00 2001 | ||
From: Axel Huebl <axel.huebl@plasma.ninja> | ||
Date: Fri, 7 Jan 2022 06:28:12 -0800 | ||
Subject: [PATCH] Python: Argv Encoding ASCII | ||
|
||
Since we pass those arguments to argc/argv in C in the end, we might | ||
want to stay with ASCII. Otherwise, the interpretation might not fit | ||
the local encoding. | ||
|
||
Alternatively, we can try encoding to `locale.getpreferredencoding()` | ||
or setting the encoding forced to UTF-8. | ||
--- | ||
Python/pywarpx/_libwarpx.py | 32 ++++++++++++++++---------------- | ||
1 file changed, 16 insertions(+), 16 deletions(-) | ||
|
||
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py | ||
index 9de8227397..925a276985 100755 | ||
--- a/Python/pywarpx/_libwarpx.py | ||
+++ b/Python/pywarpx/_libwarpx.py | ||
@@ -392,14 +392,14 @@ def get_nattr_species(self, species_name): | ||
|
||
''' | ||
return self.libwarpx_so.warpx_nCompsSpecies( | ||
- ctypes.c_char_p(species_name.encode('utf-8'))) | ||
+ ctypes.c_char_p(species_name.encode('ascii'))) | ||
|
||
def amrex_init(self, argv, mpi_comm=None): | ||
# --- Construct the ctype list of strings to pass in | ||
argc = len(argv) | ||
argvC = (_LP_c_char * (argc+1))() | ||
for i, arg in enumerate(argv): | ||
- enc_arg = arg.encode('utf-8') | ||
+ enc_arg = arg.encode('ascii') | ||
argvC[i] = ctypes.create_string_buffer(enc_arg) | ||
|
||
if mpi_comm is None or MPI is None: | ||
@@ -620,7 +620,7 @@ def add_particles(self, species_name, x=None, y=None, z=None, ux=None, uy=None, | ||
attr[:,self.get_particle_comp_index(species_name, key)-3] = vals | ||
|
||
self.libwarpx_so.warpx_addNParticles( | ||
- ctypes.c_char_p(species_name.encode('utf-8')), x.size, | ||
+ ctypes.c_char_p(species_name.encode('ascii')), x.size, | ||
x, y, z, ux, uy, uz, nattr, attr, unique_particles | ||
) | ||
|
||
@@ -642,7 +642,7 @@ def get_particle_count(self, species_name): | ||
|
||
''' | ||
return self.libwarpx_so.warpx_getNumParticles( | ||
- ctypes.c_char_p(species_name.encode('utf-8')) | ||
+ ctypes.c_char_p(species_name.encode('ascii')) | ||
) | ||
|
||
def get_particle_structs(self, species_name, level): | ||
@@ -670,7 +670,7 @@ def get_particle_structs(self, species_name, level): | ||
particles_per_tile = _LP_c_int() | ||
num_tiles = ctypes.c_int(0) | ||
data = self.libwarpx_so.warpx_getParticleStructs( | ||
- ctypes.c_char_p(species_name.encode('utf-8')), level, | ||
+ ctypes.c_char_p(species_name.encode('ascii')), level, | ||
ctypes.byref(num_tiles), ctypes.byref(particles_per_tile) | ||
) | ||
|
||
@@ -710,8 +710,8 @@ def get_particle_arrays(self, species_name, comp_name, level): | ||
particles_per_tile = _LP_c_int() | ||
num_tiles = ctypes.c_int(0) | ||
data = self.libwarpx_so.warpx_getParticleArrays( | ||
- ctypes.c_char_p(species_name.encode('utf-8')), | ||
- ctypes.c_char_p(comp_name.encode('utf-8')), | ||
+ ctypes.c_char_p(species_name.encode('ascii')), | ||
+ ctypes.c_char_p(comp_name.encode('ascii')), | ||
level, ctypes.byref(num_tiles), ctypes.byref(particles_per_tile) | ||
) | ||
|
||
@@ -883,8 +883,8 @@ def get_particle_comp_index(self, species_name, pid_name): | ||
|
||
''' | ||
return self.libwarpx_so.warpx_getParticleCompIndex( | ||
- ctypes.c_char_p(species_name.encode('utf-8')), | ||
- ctypes.c_char_p(pid_name.encode('utf-8')) | ||
+ ctypes.c_char_p(species_name.encode('ascii')), | ||
+ ctypes.c_char_p(pid_name.encode('ascii')) | ||
) | ||
|
||
def add_real_comp(self, species_name, pid_name, comm=True): | ||
@@ -901,8 +901,8 @@ def add_real_comp(self, species_name, pid_name, comm=True): | ||
|
||
''' | ||
self.libwarpx_so.warpx_addRealComp( | ||
- ctypes.c_char_p(species_name.encode('utf-8')), | ||
- ctypes.c_char_p(pid_name.encode('utf-8')), comm | ||
+ ctypes.c_char_p(species_name.encode('ascii')), | ||
+ ctypes.c_char_p(pid_name.encode('ascii')), comm | ||
) | ||
|
||
def get_particle_boundary_buffer_size(self, species_name, boundary): | ||
@@ -925,7 +925,7 @@ def get_particle_boundary_buffer_size(self, species_name, boundary): | ||
|
||
''' | ||
return self.libwarpx_so.warpx_getParticleBoundaryBufferSize( | ||
- ctypes.c_char_p(species_name.encode('utf-8')), | ||
+ ctypes.c_char_p(species_name.encode('ascii')), | ||
self.get_boundary_number(boundary) | ||
) | ||
|
||
@@ -958,7 +958,7 @@ def get_particle_boundary_buffer_structs(self, species_name, boundary, level): | ||
particles_per_tile = _LP_c_int() | ||
num_tiles = ctypes.c_int(0) | ||
data = self.libwarpx_so.warpx_getParticleBoundaryBufferStructs( | ||
- ctypes.c_char_p(species_name.encode('utf-8')), | ||
+ ctypes.c_char_p(species_name.encode('ascii')), | ||
self.get_boundary_number(boundary), level, | ||
ctypes.byref(num_tiles), ctypes.byref(particles_per_tile) | ||
) | ||
@@ -1005,16 +1005,16 @@ def get_particle_boundary_buffer(self, species_name, boundary, comp_name, level) | ||
num_tiles = ctypes.c_int(0) | ||
if comp_name == 'step_scraped': | ||
data = self.libwarpx_so.warpx_getParticleBoundaryBufferScrapedSteps( | ||
- ctypes.c_char_p(species_name.encode('utf-8')), | ||
+ ctypes.c_char_p(species_name.encode('ascii')), | ||
self.get_boundary_number(boundary), level, | ||
ctypes.byref(num_tiles), ctypes.byref(particles_per_tile) | ||
) | ||
else: | ||
data = self.libwarpx_so.warpx_getParticleBoundaryBuffer( | ||
- ctypes.c_char_p(species_name.encode('utf-8')), | ||
+ ctypes.c_char_p(species_name.encode('ascii')), | ||
self.get_boundary_number(boundary), level, | ||
ctypes.byref(num_tiles), ctypes.byref(particles_per_tile), | ||
- ctypes.c_char_p(comp_name.encode('utf-8')) | ||
+ ctypes.c_char_p(comp_name.encode('ascii')) | ||
) | ||
|
||
particle_data = [] |
This file contains 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