Skip to content

Commit

Permalink
Update the project to use pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
Luthaf committed Dec 5, 2020
1 parent 11fd576 commit 716c3fe
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 78 deletions.
File renamed without changes.
18 changes: 11 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ if(NOT ${CHFL_PY_INTERNAL_CHEMFILES})
find_package(chemfiles CONFIG QUIET 0.9)
endif()

file(REMOVE ${CMAKE_BINARY_DIR}/external.py)
file(REMOVE ${CMAKE_BINARY_DIR}/external.pyc)
file(REMOVE ${PROJECT_SOURCE_DIR}/chemfiles/external.py)
file(REMOVE ${PROJECT_SOURCE_DIR}/chemfiles/external.py)

if(${chemfiles_FOUND})
set(CHEMFILES_VERSION "${chemfiles_VERSION}")
Expand All @@ -25,10 +25,9 @@ if(${chemfiles_FOUND})
"Define CHFL_PY_INTERNAL_CHEMFILES=ON to use use the internal chemfiles."
)
endif()
file(WRITE ${CMAKE_BINARY_DIR}/external.py
file(WRITE ${PROJECT_SOURCE_DIR}/chemfiles/external.py
"EXTERNAL_CHEMFILES = \"${CHEMFILES_LOCATION}\"\n"
)
install(FILES ${CMAKE_BINARY_DIR}/external.py DESTINATION ".")
else()
# Use the git submodule
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/lib/CMakeLists.txt")
Expand All @@ -40,7 +39,12 @@ else()

message(STATUS "Using internal chemfiles from ${CMAKE_CURRENT_SOURCE_DIR}/lib")
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries instead of static ones" FORCE)
add_subdirectory(lib)
file(READ lib/VERSION CHEMFILES_VERSION)
string(STRIP ${CHEMFILES_VERSION} CHEMFILES_VERSION)
add_subdirectory(lib EXCLUDE_FROM_ALL)

add_custom_target(build_chemfiles ALL)
add_dependencies(build_chemfiles chemfiles)
install(TARGETS chemfiles
LIBRARY DESTINATION "chemfiles"
RUNTIME DESTINATION "chemfiles"
)
endif()
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ recursive-include chemfiles *
recursive-include lib *
prune lib/tests
prune lib/doc
include requirements.txt
include CMakeLists.txt
include README.md
include LICENSE
Expand Down
6 changes: 4 additions & 2 deletions chemfiles/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
lib/
include/
external.py

*.dylib
*.so
*.dll
10 changes: 5 additions & 5 deletions chemfiles/clib.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ def __call__(self):
def _lib_path():
if EXTERNAL_CHEMFILES:
return EXTERNAL_CHEMFILES
root = os.path.dirname(__file__)
root = os.path.abspath(os.path.dirname(__file__))
if sys.platform.startswith("darwin"):
return os.path.join(root, "lib", "libchemfiles.dylib")
return os.path.join(root, "libchemfiles.dylib")
elif sys.platform.startswith("linux"):
return os.path.join(root, "lib", "libchemfiles.so")
return os.path.join(root, "libchemfiles.so")
elif sys.platform.startswith("win"):
candidates = [
os.path.join(root, "bin", "libchemfiles.dll"), # MinGW
os.path.join(root, "bin", "chemfiles.dll"), # MSVC
os.path.join(root, "libchemfiles.dll"), # MinGW
os.path.join(root, "chemfiles.dll"), # MSVC
]
for path in candidates:
if os.path.isfile(path):
Expand Down
5 changes: 0 additions & 5 deletions dev-requirements.txt

This file was deleted.

22 changes: 22 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[build-system]
requires = ["setuptools", "wheel", "scikit-build"] #, "cmake", "ninja"]
build-backend = "setuptools.build_meta"

[tool.tox]
legacy_tox_ini = """
[tox]
skipsdist = True
[testenv]
; this is required on windows to ensure the compiler finds the standard lib
; files (kernel32.lib, etc.) and headers
passenv = LIB INCLUDE LIBPATH
setenv =
CHFL_PY_INTERNAL_CHEMFILES = 1
commands =
pip install -e .
discover -p "*.py" tests
deps =
discover
numpy
"""
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

6 changes: 4 additions & 2 deletions scripts/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ rm -rf _skbuild
rm -rf dist
rm -rf MANIFEST
rm -rf chemfiles.egg-info
rm -rf chemfiles/lib
rm -rf chemfiles/include

rm -rf chemfiles/*.dylib
rm -rf chemfiles/*.so
rm -rf chemfiles/*.dll
rm -rf chemfiles/external.py
31 changes: 31 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[metadata]
name = chemfiles
long_description = file: README.md
long_description_content_type = text/markdown

license_files = LICENSE
author = Guillaume Fraux
author_email = [email protected]
description = Read and write computational chemistry files
keywords = chemistry computational cheminformatics files formats
url = http://github.com/chemfiles/chemfiles.py
classifiers =
Development Status :: 4 - Beta
Environment :: Console
Intended Audience :: Developers
Intended Audience :: Science/Research
License :: OSI Approved :: BSD License
Operating System :: MacOS :: MacOS X
Operating System :: Microsoft :: Windows
Operating System :: Unix
Programming Language :: Python :: 2
Programming Language :: Python :: 3
Topic :: Scientific/Engineering :: Chemistry
Topic :: Software Development :: Libraries :: Python Modules
Topic :: Utilities

[options]
zip_safe = False

[bdist_wheel]
universal = 1
91 changes: 49 additions & 42 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# -*- coding=utf-8 -*-
import chemfiles
import sys
from wheel.bdist_wheel import bdist_wheel
from skbuild import setup

import sys
import os
import re


# Read the version from chemfiles/__init__.py without importing chemfiles
__version__ = re.search(
r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]', open("chemfiles/__init__.py").read()
).group(1)


class universal_wheel(bdist_wheel):
# Workaround until https://github.com/pypa/wheel/issues/185 is resolved
Expand All @@ -12,49 +20,48 @@ def get_tag(self):
return ("py2.py3", "none") + tag[2:]


with open("requirements.txt", "r") as fd:
requirements = list(filter(bool, (line.strip() for line in fd)))
if sys.hexversion >= 0x03040000:
requirements = list(filter(lambda r: r != "enum34", requirements))
install_requires = ["numpy"]
if sys.hexversion < 0x03040000:
install_requires.append("enum34")


# scikit-build options
cmake_args = []
if sys.platform.startswith("darwin"):
cmake_args.append("-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9")

if os.getenv("CHFL_PY_INTERNAL_CHEMFILES"):
cmake_args.append("-DCHFL_PY_INTERNAL_CHEMFILES=ON")


def _get_lib_ext():
if sys.platform.startswith("win32"):
ext = ".dll"
elif sys.platform.startswith("darwin"):
ext = ".dylib"
elif sys.platform.startswith("linux"):
ext = ".so"
else:
raise Exception("Unknown operating system: %s" % sys.platform)
return ext

long_description = ""
with open("README.md", "r") as fd:
for line in fd:
# remove github badges
if not line.startswith("[!["):
long_description += line

setup(
name="chemfiles",
long_description=long_description,
long_description_content_type="text/markdown",
version=chemfiles.__version__,
author="Guillaume Fraux",
author_email="[email protected]",
description="Read and write chemistry trajectory files",
keywords="chemistry computational cheminformatics files formats",
url="http://github.com/chemfiles/chemfiles.py",
packages=["chemfiles"],
zip_safe=False,
install_requires=requirements,
setup_requires=["scikit-build"],
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: Unix",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Chemistry",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities",
],
cmake_install_dir="chemfiles",
cmake_args=['-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.9'],
version=__version__,
install_requires=install_requires,
cmdclass={"bdist_wheel": universal_wheel},
# cmake_install_dir="chemfiles",
cmake_args=cmake_args,
packages=["chemfiles"],
package_data={
"chemfiles": [
"*" + _get_lib_ext(),
"bin/*" + _get_lib_ext(),
]
},
exclude_package_data={
"chemfiles": [
"include/*",
]
},
)
12 changes: 0 additions & 12 deletions tox.ini

This file was deleted.

0 comments on commit 716c3fe

Please sign in to comment.