Skip to content

Conversation

timmysilv
Copy link

Context:
FlamingPy started to depend on strawberryfields and importing pkg_resources (by importing this) raises a deprecation warning. Even more concerning, this repo does not express its direct dependency on setuptools despite requiring it (likely because it was shipped with python by default for the longest time).

Description of the Change:
Replace pkg_resources.resource_filename with pathlib.Path(__file__). The data neighbours the source files so pathlib has no problem getting the job done.

Benefits:

  • Newer versions of Python do not come with setuptools which makes importing strawberryfields fail
  • Other packages (eg. FlamingPy) that depend on strawberryfields can import it without setuptools raising a warning

Possible Drawbacks:
While I'm quite certain that package_data in setup.py doesn't relocate data files, I don't know if there's something in a PEP that says it isn't necessary and some build tools don't respect it.

"package_data": {"strawberryfields": ["backends/data/*", "apps/data/feature_data/*",
"apps/data/sample_data/*"]},

Anyway, installing strawberryfields today does what one would expect:

apps/data/ tree
❯ tree .venv/lib/python3.11/site-packages/strawberryfields/apps/data/
.venv/lib/python3.11/site-packages/strawberryfields/apps/data/
├── __init__.py
├── feature_data
│   ├── MUTAG_exact_fv.npy
│   ├── MUTAG_mat.npy
│   ├── QM9_exact_fv.npy
│   ├── QM9_mat.npy
│   └── QM9_mc_fv.npy
├── feature.py
├── sample_data
│   ├── formic_delta.npz
│   ├── formic_Ud.npz
│   ├── formic_w.npz
│   ├── formic_wp.npz
│   ├── formic.npz
│   ├── MUTAG_0_A.npz
│   ├── MUTAG_0.npz
│   ├── MUTAG_1_A.npz
│   ├── MUTAG_1.npz
│   ├── MUTAG_2_A.npz
│   ├── MUTAG_2.npz
│   ├── MUTAG_3_A.npz
│   ├── MUTAG_3.npz
│   ├── p_hat300-1_A.npz
│   ├── p_hat300-1.npz
│   ├── planted_A.npz
│   ├── planted.npz
│   ├── pyrrole_Lf.npz
│   ├── pyrrole_Li.npz
│   ├── pyrrole_m.npz
│   ├── pyrrole_rf.npz
│   ├── pyrrole_ri.npz
│   ├── pyrrole_U.npz
│   ├── pyrrole_wf.npz
│   ├── pyrrole_wi.npz
│   ├── pyrrole.npz
│   ├── TACE-AS_A.npz
│   ├── TACE-AS.npz
│   ├── water_U.npz
│   ├── water_w.npz
│   └── water.npz
└── sample.py

Related GitHub Issues:
N/A

Copy link

codecov bot commented Jul 21, 2025

Codecov Report

Attention: Patch coverage is 27.27273% with 16 lines in your changes missing coverage. Please review.

Project coverage is 60.67%. Comparing base (9a9a352) to head (fd916d0).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
strawberryfields/apps/data/sample.py 21.05% 15 Missing ⚠️
strawberryfields/apps/data/feature.py 66.66% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (9a9a352) and HEAD (fd916d0). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (9a9a352) HEAD (fd916d0)
7 5
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #758       +/-   ##
===========================================
- Coverage   98.33%   60.67%   -37.66%     
===========================================
  Files          78       78               
  Lines        9603     9539       -64     
===========================================
- Hits         9443     5788     -3655     
- Misses        160     3751     +3591     
Files with missing lines Coverage Δ
strawberryfields/apps/data/feature.py 73.33% <66.66%> (-25.03%) ⬇️
strawberryfields/apps/data/sample.py 65.32% <21.05%> (-34.68%) ⬇️

... and 74 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cc0a0e4...fd916d0. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant