如何将可执行文件与库文件分开? [英] How do I separate my executable files from my library files?

查看:76
本文介绍了如何将可执行文件与库文件分开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仍然没有得到我满意的答案.如果您的Python或PHP项目有一个不错的系统,请提交一些答案.

我的PHP和Python项目遇到管理问题.它们都有两种代码文件:应在控制台或Web浏览器中运行的文件,以及应包含在其他文件中以扩展功能的文件.当我的项目成长为大型命名空间或模块树后,它开始使我所有文件夹中的可执行"文件和库文件与相同文件扩展名并排放置,使人迷惑.如果PHP和Python是预编译语言,则这些文件将具有main函数.

I'm having a management issue with my PHP and Python projects. They both have two kinds of code files: files that should be run in the console or web browser, and files that should be included from other files to extend functionality. After my projects grow into large namespace or module trees, it starts getting disorienting that "executable" files and library files lay side by side with the same file extensions in all my folders. If PHP and Python were pre-compile languages, this would be the files with the main function.

例如,图片我有一个命名空间com.mycompany.map.address,其中包含多个.py或.php文件,具体取决于项目.它包含用于不同类型地址的模型以及用于处理地址的大量功能.但是除此之外,它还将包含一些从终端运行的可执行文件,为用户提供搜索地址的工具,并可能从数据库等中添加和删除地址.

For example, picture I have the namespace com.mycompany.map.address which contained multiple .py or .php files depending on the project. It would contain models for different kinds of addresses and tons of functions for working with addresses. But in addition, it would contain some executable files that runs from the terminal, providing a user tools for searching for addresses, and perhaps adding and removing addresses from a database or such.

我想要一种将此类可执行文件与命名空间树中大量代码文件区分开的方法

I want a way of distinguish such executable files from the tons and tons of code files in my namespace trees

如果文件具有单独的文件扩展名,则不会有问题.但是由于它们没有,所以我想我应该分开文件夹或其他东西,但是我不知道如何命名它们.在PHP中,我可以执行将PHP配置为解析不同文件扩展名的hack解决方案,例如,我的项目可以包含phpsphpx文件.

If the files had separate file extensions this wouldn't be a problem. But since they don't, I'm thinking I should separate folders or something, but I don't know what to name them. In PHP I could perform the hack solution of configuring PHP to parse different file extensions, so my project could contain phps or phpx files, for instance.

如果有人对如何处理此问题有一些独立于语言的建议,我将不胜感激.这也可能适用于C语言,其中一个项目可能会编译成许多可执行文件.如何将包含main函数的源文件与其余文件分开?

If anyone has some language-independent advice on how to handle this issue, I'd appreciate it. This could also apply to languages such as C, where one project might compile into many executable files. How should one separate the source files containing main functions from the rest of them?

推荐答案

以某种方式(按名称,扩展名,位置)分隔它们.


示例:

Separate them somehow (by name, by extension, by location).


Example:

这是我们的测试自动化系统的布局(为清晰起见,手动对输出进行了排序):

Here's the layout of our test automation system (output is manually sorted for clarity):

$ ls -1 automation
atf               \ two major homebrew libraries, with many submodules
atflib            / 

atfconfig         configuration files in .py form
configuration     \ configuration files in .ini form
res_manager       /

test_scripts      - scripts to be invoked directly

然后将automation文件夹放置到PYTHONPATH中,并且可以将import atf.<smth>放置在任何位置. 要运行测试,我们将其更改为test_scripts.

Then we place the automation folder into PYTHONPATH and can import atf.<smth> anywhere. To run tests, we change into test_scripts.

这篇关于如何将可执行文件与库文件分开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆