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

Tristan/build windows #6

Open
wants to merge 8 commits into
base: jw/0.0
Choose a base branch
from

Conversation

tjknoth
Copy link

@tjknoth tjknoth commented Feb 14, 2024

This PR essentially just translates the .sh script to python for use across platforms. This does work on windows (assuming the user has an appropriate build profile set up).

@callendorph
Copy link
Owner

So what happened with the C++17 setting ? I don't remember needing to set that. Here is my default profile that conan found:

➜ cat .conan2/profiles/default
[settings]
arch=x86_64
build_type=Release
compiler=apple-clang
compiler.cppstd=gnu17
compiler.libcxx=libc++
compiler.version=14
os=Macos

build_conan.py Outdated
subprocess.run([CONAN, 'config', 'install', './conan-config'], shell=True,
stdout=subprocess.DEVNULL,
# might want to log this?
subprocess.run([CONAN, 'config', 'install', f'{os.getcwd()}/conan-config']
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya - I think we need to at least check for failure here.

I think as long as the error goes to stdout - then when slm runs the task - it will dump the task output.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind I think it throws an exception on error code. So the script will fail regardless.

print(f'Check logfile \'{CONAN_LOG}\' for progress.')
print()

with open(CONAN_LOG, 'w+') as logfile :
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log setup here is a good idea 👍


# might want something more robust here
try:
os.mkdir(OUTPUT_DIR)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os.makedirs has an option exist_ok
https://docs.python.org/3/library/os.html#os.makedirs

CONAN_HOST_PROFILE = os.environ.get('CONAN_HOST_PROFILE', 'default')
SLM_BUILD_DYNAMIC_LIB = os.environ.get('SLM_BUILD_DYNAMIC_LIB', 'False').capitalize()

def no_conan_profile () :
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use:

(venv) ➜  lbstanza-z3 git:(master) conan profile show -pr asdf    
ERROR: Profile not found: asdf

Here instead of digging around in conan's internals?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

print(f" VIRTUAL_ENV: {os.environ.get('VIRTUAL_ENV')}")

# TODO: is there something smarter to do?
subprocess.run([sys.executable, '-m', 'pip', 'install', '-r' 'requirements.txt'],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least for this repository - this is unnecessary. The requirements.txt file is really only there to support installing conan if it doesn't exist. I think this script is making the assumption that conan is present in the environment - correct?

The wrapper_requirements.txt is not required to build the dependency - it is only needed to generate the Wrapper.stanza file from the Z3 header file.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we move the LBStanzaGenerator and lbstanza_deployer to a pip installable package then this pip install becomes pertinent again.

Comment on lines +53 to +54
print([CONAN, 'config', 'install', f'{os.getcwd()}/conan-config'])
subprocess.run([CONAN, 'config', 'install', f'{os.getcwd()}/conan-config'],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can tell - the conan config install command here is really just installing the lbstanza_deployer and the LBStanzaGenerator into conan.

I think we can move the LBStanzaGenerator into the conanfile.py - Something like:

from stanza import LBStanzaGenerator
...
class StanzaZ3Recipe(ConanFile):
  ...
  generators = "LBStanzaGenerator"

Where the stanza package is a pip installable package that we construct and push to pypi.

For the deployer - I don't know if there is a way to set the deployer in the conanfile.py or in some way that it is discoverable by conan. For example - could we pip install a package with the lbstanza_deployer in it and then pass the full path reference to it on the command line:

--deployer=stanza.lbstanza_deployer

I guess what I'm concerned about is:

  1. This is going to run on every build - increases build time.
  2. If two projects have this same setup and their scripts are different versions - what does Conan do? Are they going to fight ? Is the first/last one that gets installed going to win and then always be used for all the deps ?

else
echo "done."
fi
python3 build_conan.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this into the slm.toml file now that it is just a single line:

libz3.task = { command = "python3 build_conan.py" }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yep definitely.

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