Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: restructure directory #71

Merged
merged 2 commits into from
Sep 1, 2023
Merged

Conversation

Zhaoyilunnn
Copy link
Collaborator

What Changed

Restructure the directory. Moved quafu to the root directory from src.

.
|-- _skbuild
|   `-- linux-x86_64-3.10
|-- dist
|-- examples
|   `-- quantum_rl
|-- pyquafu.egg-info
|-- quafu
|   |-- __pycache__
|   |-- algorithms
|   |-- backends
|   |-- benchmark
|   |-- circuits
|   |-- dagcircuits
|   |-- elements
|   |-- exceptions
|   |-- pulses
|   |-- qfasm
|   |-- results
|   |-- simulators
|   |-- synthesis
|   |-- tasks
|   |-- users
|   |-- utils
|   `-- visualisation
|-- src
|   |-- qfvm
|   `-- qfvm_gpu
|-- tests
|   `-- quafu
`-- thirdparty
    `-- Eigen3

Why this change

The skbuild package has some bugs in enabling development mode. See scikit-build/scikit-build#1025. A workaround is to use python setup.py develop.

However, previously python modules and C++ source codes are all located under src directory.
And thus in previous setup.py, we specified the package_dir field as {'': 'src'}.
When using python setup.py develop it find the egg_base based on distribution's package_dir member (code pointer), normally {'': 'src'} will take effect and the egg_path will be set to src.

Unfortunately, skbuild has some other bugs, it overrides the distributions package_dir and {'': 'src'} is shown to be missing, causing the failure of setting the correct egg_path and always set the egg_path as ..

As a result, I think currently the best practice in developing python/c++ hybrid projects is to put python modules in the root directory and put c++ source code in the src directory.

I just checked that qiskit-aer follows the same practice.

Testing

python setup.py develop && pytest tests/
python setup.py install && pytest tests/
pip install . && pytest tests/

All these methods of installing pyquafu works fine

@Zhaoyilunnn Zhaoyilunnn merged commit ccd8ee9 into ScQ-Cloud:master Sep 1, 2023
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.

2 participants