Skip to content

Commit

Permalink
setup optional installation for julia pkgs
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhu2017 committed Aug 18, 2024
1 parent 85dec00 commit 556db03
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ or
pip install --upgrade git+https://github.com/MaterSim/PyXtal.git@master
```

If you want to add the Julia package install (required by the use of `pyxtal.lego` module), please use

```sh
INSTALL_JULIA=1 pip install pyxtal
```

To check if the installation is successful, run the following script,
```python

from juliacall import Main as jl
jl.seval("using CrystalNets")
print("Success")
```

## Citation

### General PyXtal
Expand Down
35 changes: 28 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
from distutils.core import setup
#from os import path
import setuptools # noqa
from setuptools import setup
from setuptools.command.install import install
import os

#this_directory = path.abspath(path.dirname(__file__))
#with open(path.join(this_directory, "README.md"), encoding="utf-8") as f:
# long_description = f.read()
class CustomInstallCommand(install):
def run(self):
# Check if the custom environment variable is set
if os.getenv("INSTALL_JULIA", "0") == "1":
print("CustomInstallCommand: Installing Julia packages...")
try:
from juliacall import Main as jl
jl.seval("using Pkg")
jl.seval('Pkg.add(Pkg.PackageSpec(name="CrystalNets", uuid="7952bbbe-a946-4118-bea0-081a0932faa9"))')
print("CrystalNets has been installed successfully.")
except ImportError:
print("juliacall is not installed. Skipping Julia package installation.")
except Exception as e:
print(f"An error occurred during Julia package installation: {e}")
sys.exit(1) # Optionally, stop the installation if this step fails
else:
print("CustomInstallCommand: Skipping Julia package installation.")

# Run the standard install process
install.run(self)

with open("README.md") as fh:
long_description = fh.read()
Expand Down Expand Up @@ -41,8 +58,8 @@
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
setup_requires=["juliacall>=0.9.0"],
install_requires=[
"juliacall",
"spglib>=1.10.4",
"pymatgen>=2024.3.1",
"pandas>=2.0.2",
Expand All @@ -60,6 +77,10 @@
"molecules": ["openbabel", "pybel"],
"test": ["wheel", "pytest", "coverage", "pytest-cov", "monty>=2024.2.26"],
},
cmdclass={
'install': CustomInstallCommand,
},
python_requires=">=3.9",
license="MIT",
)

0 comments on commit 556db03

Please sign in to comment.