Skip to content

Commit 16f6feb

Browse files
authored
Use whoami instead of users for better compatibility (#128)
1 parent 4e04682 commit 16f6feb

File tree

8 files changed

+51
-33
lines changed

8 files changed

+51
-33
lines changed

.github/workflows/python-release.yml

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
target: ${{ matrix.target }}
3535
args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml
3636
sccache: 'true'
37+
manylinux: auto
3738
- name: Upload wheels
3839
uses: actions/upload-artifact@v4
3940
with:

.github/workflows/python-test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373
with:
7474
args: --release --out dist --find-interpreter --manifest-path python/Cargo.toml
7575
sccache: 'true'
76+
manylinux: auto
7677

7778
- name: Upload wheels
7879
if: github.ref == 'refs/heads/master'

.github/workflows/rust-test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ jobs:
2727
matrix:
2828
os:
2929
- ubuntu-latest
30-
# - macos-11
31-
# - windows-latest
30+
- macos-latest
31+
- windows-latest
3232
runs-on: ${{ matrix.os }}
3333

3434
steps:
@@ -58,7 +58,7 @@ jobs:
5858
matrix:
5959
os:
6060
- ubuntu-latest
61-
# - macos-11
61+
# - macos-latest
6262
# - windows-latest
6363
runs-on: ${{ matrix.os }}
6464
env:

Cargo.lock

+28-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ cipher = "0.4"
2121
crc = "3.2"
2222
ctr = "0.9"
2323
des = "0.8"
24-
# Just used for benchmarks
25-
fs-hdfs3 = { version = "0.1.12", optional = true }
2624
futures = "0.3"
2725
g2p = "1"
2826
hex = "0.4"
@@ -42,9 +40,13 @@ socket2 = "0.5"
4240
thiserror = { workspace = true }
4341
tokio = { workspace = true, features = ["rt", "rt-multi-thread", "net", "io-util", "macros", "sync", "time"] }
4442
url = "2"
45-
users = { version = "0.11", default-features = false }
4643
uuid = { version = "1", features = ["v4"] }
4744
which = { version = "4", optional = true }
45+
whoami = "1"
46+
47+
[target.'cfg(unix)'.dependencies]
48+
# Just used for benchmarks
49+
fs-hdfs3 = { version = "0.1.12", optional = true }
4850

4951
[build-dependencies]
5052
prost-build = { version = "0.12", optional = true }

rust/benches/io.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::collections::HashSet;
22

3+
#[allow(unused_imports)]
34
use bytes::{Buf, BufMut, BytesMut};
45
use criterion::*;
5-
use hdfs::hdfs::get_hdfs;
66
use hdfs_native::{
77
minidfs::{DfsFeatures, MiniDfs},
88
Client, WriteOptions,
@@ -49,8 +49,9 @@ fn bench(c: &mut Criterion) {
4949
})
5050
});
5151
group.sample_size(50);
52+
#[cfg(unix)]
5253
group.bench_function("read-libhdfs", |b| {
53-
let fs = get_hdfs().unwrap();
54+
let fs = hdfs::hdfs::get_hdfs().unwrap();
5455
b.iter(|| {
5556
let mut buf = BytesMut::zeroed(ints_to_write * 4);
5657
let mut bytes_read = 0;
@@ -79,8 +80,9 @@ fn bench(c: &mut Criterion) {
7980
.iter(|| async { reader.read_range(0, reader.file_length()).await.unwrap() })
8081
});
8182
group.sample_size(50);
83+
#[cfg(unix)]
8284
group.bench_function("read-libhdfs", |b| {
83-
let fs = get_hdfs().unwrap();
85+
let fs = hdfs::hdfs::get_hdfs().unwrap();
8486
b.iter(|| {
8587
let mut buf = BytesMut::zeroed(ints_to_write * 4);
8688
let mut bytes_read = 0;
@@ -120,8 +122,9 @@ fn bench(c: &mut Criterion) {
120122
})
121123
});
122124
group.sample_size(10);
125+
#[cfg(unix)]
123126
group.bench_function("write-libhdfs", |b| {
124-
let fs = get_hdfs().unwrap();
127+
let fs = hdfs::hdfs::get_hdfs().unwrap();
125128
b.iter(|| {
126129
let mut buf = buf.clone();
127130
let writer = fs.create_with_overwrite("/bench-write", true).unwrap();
@@ -154,8 +157,9 @@ fn bench(c: &mut Criterion) {
154157
})
155158
});
156159
group.sample_size(10);
160+
#[cfg(unix)]
157161
group.bench_function("write-libhdfs", |b| {
158-
let fs = get_hdfs().unwrap();
162+
let fs = hdfs::hdfs::get_hdfs().unwrap();
159163
b.iter(|| {
160164
let mut buf = buf.clone();
161165
let writer = fs

rust/benches/rpc.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::collections::HashSet;
22

33
use criterion::*;
4-
use hdfs::hdfs::get_hdfs;
54
use hdfs_native::{minidfs::MiniDfs, Client, WriteOptions};
65

76
fn bench(c: &mut Criterion) {
@@ -25,14 +24,14 @@ fn bench(c: &mut Criterion) {
2524
.unwrap();
2625
});
2726

28-
let fs = get_hdfs().unwrap();
29-
3027
let mut group = c.benchmark_group("rpc");
3128
group.bench_function("getFileInfo-native", |b| {
3229
b.to_async(&rt)
3330
.iter(|| async { client.get_file_info("/bench").await.unwrap() })
3431
});
32+
#[cfg(unix)]
3533
group.bench_function("getFileInfo-libhdfs", |b| {
34+
let fs = hdfs::hdfs::get_hdfs().unwrap();
3635
b.iter(|| fs.get_file_status("/bench").unwrap())
3736
});
3837
}

rust/src/security/user.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::fs;
66
use std::io;
77
use std::path::PathBuf;
88

9-
use users::get_current_username;
9+
use whoami::username;
1010

1111
use crate::proto::common::CredentialsProto;
1212
use crate::proto::common::TokenProto;
@@ -333,13 +333,7 @@ impl User {
333333
}
334334

335335
pub(crate) fn get_simpler_user() -> UserInfo {
336-
let effective_user = env::var(HADOOP_USER_NAME).ok().unwrap_or_else(|| {
337-
get_current_username()
338-
.unwrap()
339-
.to_str()
340-
.unwrap()
341-
.to_string()
342-
});
336+
let effective_user = env::var(HADOOP_USER_NAME).ok().unwrap_or_else(username);
343337
UserInfo {
344338
real_user: None,
345339
effective_user: Some(effective_user),

0 commit comments

Comments
 (0)